我有两个项目是依赖项:A,B。(没有子项目,但是 EXTERNAL项目)
我的第三个项目C,取决于A和B。
我已经以这种方式定义了settings.gradle:
settings.gradle
rootProject.name = 'project_C'
include ':common_library'
project(":project_A").projectDir = file("../project_A")
include ':project_A'
project(":project_B").projectDir = file("../project_B")
build.gradle
// ************** Include dependencies as local .jars
implementation fileTree(include: ['*.jar'], dir: 'lib')
// ************** Compile the project on which this depends on
implementation project(':project_A')
implementation project(':project_B')
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
// *********** MODIFY the standard JAR task, including Main file (for executable jars) and pack all it's dependencies
jar {
from {
(configurations.runtime).collect {
configurations.runtime.filter( {! (it.name =~ /.*\.pom/ )}).collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
manifest {
attributes "Main-Class": "Main"
}
}
此时,它成功构建。
但是当我尝试以jar形式执行它时,它给了我与 project_A 和 project_B 相关的“不包括依赖项” 的错误。类。
有人已经解决了这个问题? 谢谢!