Skip to content

Commit a22f2cf

Browse files
authored
Merge pull request #1338 from NativeScript/bektchiev/fix-sbg-jars-deps
fix(build): Correct dependencies of `cleanupAllJars` gradle task
2 parents e6caf4b + b49b016 commit a22f2cf

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test-app/app/build.gradle

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ task ensureMetadataOutDir {
449449

450450
def explodeAar(File compileDependency, File outputDir) {
451451
logger.info("explodeAar: Extracting ${compileDependency.path} -> ${outputDir.path}")
452-
452+
453453
if (compileDependency.name.endsWith(".aar")) {
454454
java.util.jar.JarFile jar = new java.util.jar.JarFile(compileDependency)
455455
Enumeration enumEntries = jar.entries()
@@ -476,7 +476,7 @@ def explodeAar(File compileDependency, File outputDir) {
476476

477477
def md5(String string) {
478478
MessageDigest digest = MessageDigest.getInstance("MD5") ;
479-
digest.update(string.bytes);
479+
digest.update(string.bytes);
480480
return new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0');
481481
}
482482

@@ -494,7 +494,7 @@ class EmptyRunnable implements Runnable {
494494

495495
// Discover all jars and dynamically create tasks for the extraction of each of them
496496
def allJars = []
497-
afterEvaluate { project ->
497+
afterEvaluate { project ->
498498
def buildType = project.selectedBuildType == "release" ? "Release" : "Debug"
499499
def jars = []
500500
Pattern pattern = Pattern.compile("^(.+)${buildType}CompileClasspath\$")
@@ -515,11 +515,18 @@ afterEvaluate { project ->
515515

516516
def taskName = "extract_${jar.name}_to_${destDir}"
517517
logger.debug("Creating dynamic task ${taskName}")
518+
519+
// Add discovered jars as dependencies of cleanupAllJars.
520+
// This is cruicial for cloud builds because they are different
521+
// on each incremental build (as each time the gradle user home
522+
// directory is a randomly generated string)
523+
cleanupAllJars.inputs.files jar
524+
518525
task "${taskName}" (type: WorkerTask) {
519526
dependsOn cleanupAllJars
520527
extractAllJars.dependsOn it
521528

522-
// This dependency seems redundant but probably due to some Gradle issue with workers,
529+
// This dependency seems redundant but probably due to some Gradle issue with workers,
523530
// without it `runSbg` sporadically starts before all extraction tasks have finished and
524531
// fails due to missing JARs
525532
runSbg.dependsOn it
@@ -544,10 +551,10 @@ afterEvaluate { project ->
544551
}
545552

546553
task cleanupAllJars {
547-
// Ideally we would depend on the list of all discovered jars, but we cannot discover them before
548-
// the execution phase of the build begins, so instead we depend on the list of libs directories that might
549-
// contain aar or jar files.
554+
// We depend on the list of libs directories that might contain aar or jar files
555+
// and on the list of all discovered jars
550556
inputs.files(pluginDependencies)
557+
551558
outputs.files cleanupAllJarsTimestamp
552559

553560
doLast {

0 commit comments

Comments
 (0)