[英]gradle subProject configuration dependencies not being add to war
I have a main project that depends on 2 subProjects. 我有一个主要项目取决于2个子项目。 All 3 projects have a custom configuration called server.
所有3个项目都有一个名为server的自定义配置。
When I have the following war task, only the dependencies in the main project configuration.server are being added to the war. 当我执行以下战争任务时,仅将主项目configuration.server中的依赖项添加到战争中。
task fatWar(type: War) {
archiveName = "arms-fat.war"
classpath configurations.server
classpath configurations.compile
}
How do I add the subProject server configuration dependencies to the war? 如何将subProject服务器配置依赖项添加到war中?
EDIT: 编辑:
Here are some snippets of my build files for context. 这是我的构建文件上下文的一些片段。
rootProject build.gradle rootProject build.gradle
configurations {
server
}
dependencies {
server 'org.glassfish.jersey.media:jersey-media-multipart:2.22.2'
...
}
task fatWar(type: War) {
archiveName = "arms-fat.war"
classpath configurations.server
classpath configurations.compile
}
subProject build.gradle 子项目build.gradle
configurations {
server
}
dependencies {
server 'mysql:mysql-connector-java:5.1.38'
...
}
When I run the fatWar task, the mysql-connector.jar, among others are not bundled in the war 当我运行fatWar任务时,战争中未捆绑mysql-connector.jar等
实际上,“ classpath”是属性,而不是方法,因此请用一个值替换为“ configurations.server + configurations.compile”的两个分配。
I was able to solve this (thanks to the link David provided) with the following: 我可以通过以下方法解决此问题(由于David提供了链接):
subprojects.each { subproject -> evaluationDependsOn( subproject.path ) }
task fatWar(type: War) {
archiveName = "arms-fims-fat.war"
subprojects.each { subproject ->
project.configurations.server.dependencies.addAll(subproject.configurations.server.dependencies)
}
classpath configurations.server
classpath configurations.compile
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.