【发布时间】:2021-06-17 19:39:17
【问题描述】:
我正在使用 gradle 6.4.1。
在我的build.gradle 文件中,我应用了许多插件,例如 mkdocs、sonar 等。
另外,我有以下部分:
allprojects {
group = 'blah'
version = '1.0'
apply plugin: 'checkstyle'
repositories {
jcenter()
maven {
url = "${artifactory_url}libs-release-local"
credentials {
username = "${artifactory_user}"
password = "${artifactory_key}"
}
}
}
ext {
springCloudVersion = "Hoxton.SR10"
}
apply plugin: "blah.java"
task allDeps(type: DependencyReportTask) {}
task getRunTimeDeps(type: Copy) {
from sourceSets.main.runtimeClasspath
into 'runtime/'
doFirst {
ant.delete(dir: 'runtime')
ant.mkdir(dir: 'runtime')
}
doLast {
ant.delete(dir: 'runtime')
}
}
}
这意味着我尝试在构建之前创建一些任务来解决依赖关系。
然后,我运行以下命令以尝试下载所有项目依赖项:
gradle dependencies
gradle --info allDeps
gradle --info getRunTimeDeps
我可以看到下载了许多依赖项。稍后,我运行:
gradle --info build
我可以看到 gradle 下载了一堆额外的依赖项。例如:
> Task :sub_project:compileJava
Downloading https://jcenter.bintray.com/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar to /tmp/gradle_download9086773233498314888bin
Downloading https://jcenter.bintray.com/org/hibernate/hibernate-core/5.4.30.Final/hibernate-core-5.4.30.Final.jar to /tmp/gradle_download7503997830142702838bin
Downloading https://jcenter.bintray.com/org/jboss/jandex/2.2.3.Final/jandex-2.2.3.Final.jar to /tmp/gradle_download7604295797727562679bin
Downloading https://jcenter.bintray.com/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.11.0/jackson-module-jaxb-annotations-2.11.0.jar to /tmp/gradle_download16534853131601223061bin
Downloading https://jcenter.bintray.com/org/javassist/javassist/3.27.0-GA/javassist-3.27.0-GA.jar to /tmp/gradle_download3958588894727834776bin
我不明白为什么之前任务中没有下载依赖项,但有时我看到插件中的依赖项也没有下载。
如何执行任务并获得构建任务所需的一切,例如 build 任务不必下载东西?
【问题讨论】: