配置Gradle,支持provided范围的依赖。
错误信息
1 2 3 4 5 6
| Error:(121, 0) Build script error, unsupported Gradle DSL method found: 'provided()'! Possible causes could be: - you are using Gradle version where the method is absent (<a href="open_gradle_settings">Fix Gradle settings</a>) - you didn't apply Gradle plugin which provides the method (<a href="apply_gradle_plugin">Apply Gradle plugin</a>) - or there is a mistake in a build script (<a href="goto_source">Goto source</a>)
|
Intelj Idea配置
已验证好用。
在build.gradle中的project内部加入以下语句
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| apply plugin: 'idea' configurations { provided } sourceSets { main.compileClasspath += configurations.provided test.compileClasspath += configurations.provided test.runtimeClasspath += configurations.provided } idea { module { scopes.PROVIDED.plus += [ configurations.provided ] } }
|
Eclipse配置
未验证
在build.gradle中的project内部加入以下语句
1 2 3 4 5 6 7 8 9 10 11 12 13
| apply plugin: 'eclipse' configurations { provided } sourceSets { main.compileClasspath += configurations.provided test.compileClasspath += configurations.provided test.runtimeClasspath += configurations.provided } eclipse.classpath.plusConfigurations += configurations.provided
|
参考文档
- Stack Over Flow