我有一个多项目构建,其中包含多个依赖于一个jar模块的war模块.
war和jar模块都依赖于Spring,Hibernate等库,这些依赖项在war模块上定义为provideCompile,在jar上定义为compile.
问题是当JetGradle更新依赖关系时,所有工件都有错误,因为工件需要jar模块的依赖关系.
我想使用以下任何一种解决方案:
将库包含在服务器的lib文件夹中,让Intellij按照提供的方式处理它们.
以某种方式将库包含在项目范围库中,因此即使在更新了gradle依赖项之后,intellij也会将它们放在所有工件上.
另一方面,从一开始我的方法就完全错了.
war模块中的依赖关系定义为:
providedCompile 'org.slf4j:slf4j-log4j12:1.7.5' providedCompile 'org.slf4j:jcl-over-slf4j:1.7.5' ... compile(project(':jarModule')) {transitive = false} ...
jar模块中的依赖项定义为:
... compile 'org.slf4j:slf4j-log4j12:1.7.5' compile 'org.slf4j:jcl-over-slf4j:1.7.5' ...
Adrian Lopez.. 22
我发现的最佳解决方案是使用Gradle配置文件中的以下代码从jar模块设置传递"编译"依赖项:
apply plugin: 'idea' configurations { provided provided.extendsFrom(compile) } idea { module { scopes.PROVIDED.plus += configurations.provided } }
对于Gradle 2.0+,修改最后一位如下:
idea { module { scopes.PROVIDED.plus += [configurations.provided] } }
此解决方案使用Intellij Gradle插件以及Gradle中的构思任务
我根据这个网址上的信息得到了这个解决方案:https : //github.com/Netflix/RxJava/pull/145 http://www.gradle.org/docs/current/dsl/org.gradle.plugins. ide.idea.model.IdeaModule.html
我希望这有助于其他人
我发现的最佳解决方案是使用Gradle配置文件中的以下代码从jar模块设置传递"编译"依赖项:
apply plugin: 'idea' configurations { provided provided.extendsFrom(compile) } idea { module { scopes.PROVIDED.plus += configurations.provided } }
对于Gradle 2.0+,修改最后一位如下:
idea { module { scopes.PROVIDED.plus += [configurations.provided] } }
此解决方案使用Intellij Gradle插件以及Gradle中的构思任务
我根据这个网址上的信息得到了这个解决方案:https : //github.com/Netflix/RxJava/pull/145 http://www.gradle.org/docs/current/dsl/org.gradle.plugins. ide.idea.model.IdeaModule.html
我希望这有助于其他人