Skip to content

Commit fe47c79

Browse files
committed
Use a configuration task instead of task graph check.
1 parent a7f0d70 commit fe47c79

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

gradle/assemble.gradle

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,38 @@ task checkDuplicateDependencies(description: 'Checks the dependency graph for mu
4343
}
4444
}
4545

46-
task populateDependencies(type: Sync) {
47-
into homeLibDir
48-
includeEmptyDirs = false
46+
task configurePopulateDependencies << {
47+
def projectNames = rootProject.subprojects*.name
48+
49+
ext {
50+
baseCachesDir = "$gradle.gradleUserHomeDir/caches"
51+
cacheDir = "$baseCachesDir/artifacts-8"
52+
metadata = "$cacheDir/module-metadata"
53+
filestore = "$cacheDir/filestore"
54+
}
4955

50-
// Only configure this task if we are indeed going to run it because it forces a resolution of all of the subproject
51-
// dependencies which is very costly and we want to avoid it if we aren't going to run this task. Because we do this
52-
// after the task graph is ready we have to add the explicit dependency on the configurations as per above.
53-
gradle.taskGraph.whenReady { taskGraph ->
54-
if (taskGraph.hasTask(':populateDependencies')) {
55-
def projectNames = rootProject.subprojects*.name
56-
57-
ext.baseCachesDir = "$gradle.gradleUserHomeDir/caches"
58-
ext.cacheDir = "$baseCachesDir/artifacts-8"
59-
ext.metadata = "$cacheDir/module-metadata"
60-
ext.filestore = "$cacheDir/filestore"
61-
62-
libsConfigurations.each { configuration ->
63-
configuration.resolvedConfiguration.resolvedArtifacts.each { artifact ->
64-
def dependency = artifact.moduleVersion.id
65-
into("$dependency.group/$dependency.name/jars") {
66-
from artifact.file // this will trigger the actual download if necessary
67-
}
68-
69-
if (!projectNames.contains(dependency.name)) {
70-
def base = "${dependency.group}/${dependency.name}/${dependency.version}"
71-
from ("${metadata}/${base}") {
72-
include "*.ivy.xml"
73-
eachFile { it.path = "$dependency.group/$dependency.name/ivy-${dependency.version}.xml" }
74-
}
75-
}
56+
libsConfigurations.each { configuration ->
57+
configuration.resolvedConfiguration.resolvedArtifacts.each { artifact ->
58+
def dependency = artifact.moduleVersion.id
59+
if (!projectNames.contains(dependency.name)) {
60+
populateDependencies.into("$dependency.group/$dependency.name/jars") {
61+
from artifact.file // this will trigger the actual download if necessary
62+
}
63+
64+
populateDependencies.from ("${metadata}/${dependency.group}/${dependency.name}/${dependency.version}") {
65+
include "*.ivy.xml"
66+
eachFile { it.path = "$dependency.group/$dependency.name/ivy-${dependency.version}.xml" }
7667
}
7768
}
7869
}
7970
}
8071
}
8172

73+
task populateDependencies(type: Sync, dependsOn: configurePopulateDependencies) {
74+
into homeLibDir
75+
includeEmptyDirs = false
76+
}
77+
8278
// Can't use sync task here because this directory contains other things as well.
8379
task sourcesJars(type: Sync) {
8480
into homeSrcDir

0 commit comments

Comments
 (0)