Reputation: 2508
I am using gradle 6.4.1.
In my build.gradle
file, I apply many plugins, like mkdocs, sonar, etc.
Also, I have the following section on it:
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')
}
}
}
This means I tried to create some tasks to resolve dependencies before build.
Then, I run the following commands in an attempt to download all project dependencies:
gradle dependencies
gradle --info allDeps
gradle --info getRunTimeDeps
I can see many dependencies are downloaded. Later on, I run:
gradle --info build
and I can see gradle downloading a bunch of additional dependencies.For instance:
> 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
I don't understand why the dependencies weren't downloaded in the tasks before, but some times I see dependencies from plugins, which are also not downloaded.
How can I execute a task and get everything needed to build my task, such as that build
task won't have to download a thing?
Upvotes: 1
Views: 1556
Reputation: 7590
I would assume that the allDeps
task you made should resolve (and thereby download) all configurations where possible. So I don't really understand if you see additional files being downloaded afterward when compiling. Maybe the plugins you use do not properly declare configurations or dependencies in the configuration phase?
But the other task getRunTimeDeps
you made only downloads some of them as it doesn't consider the configurations than the ones contributing to the runtimeClasspath
. Configurations like compileOnly
, annotationProcessor
and testImplementation
will not be included. So maybe try something like this instead:
// Groovy DSL, root project
allprojects {
task cacheDeps {
doLast {
configurations.each { conf ->
if (conf.isCanBeResolved()) {
conf.resolve()
}
}
}
}
}
Upvotes: 1
Reputation: 11
have you tried the following?
./gradlew build --refresh-dependencies
Upvotes: 0