更新时间:2022-12-12 22:06:28
很抱歉,您的回复很晚,如果您仍然需要这样的示例,请参见以下示例.
Sorry for the late response, if you still need something like this here is an example.
apply plugin: "groovy"
repositories {
mavenCentral()
}
configurations {
projectDep
libraryDep
}
project('core') {
apply plugin: "java"
}
dependencies {
projectDep project(':core')
libraryDep 'my.project:project:0.1.0'
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
compile 'org.codehaus.groovy:groovy-all:2.4.5'
testCompile "org.testng:testng:6.8.21"
}
jar {
from configurations.libraryDep
}
task projectJar(type: Jar) {
appendix = 'project'
from sourceSets.main.output, configurations.projectDep, configurations.runtime
}
那么您有2个jar任务. jar会从compile,runtime和libraryDep中获取所有已声明的依赖项,而projectJar会从compile,runtime和projectDep中获取.
You have then 2 jar tasks. The jar takes all declared dependencies from compile,runtime and libraryDep and the projectJar takes compile,runtime and projectDep.
希望这会有所帮助.