@@ -449,7 +449,7 @@ task ensureMetadataOutDir {
449
449
450
450
def explodeAar (File compileDependency , File outputDir ) {
451
451
logger. info(" explodeAar: Extracting ${ compileDependency.path} -> ${ outputDir.path} " )
452
-
452
+
453
453
if (compileDependency. name. endsWith(" .aar" )) {
454
454
java.util.jar.JarFile jar = new java.util.jar.JarFile (compileDependency)
455
455
Enumeration enumEntries = jar. entries()
@@ -476,7 +476,7 @@ def explodeAar(File compileDependency, File outputDir) {
476
476
477
477
def md5 (String string ) {
478
478
MessageDigest digest = MessageDigest . getInstance(" MD5" ) ;
479
- digest. update(string. bytes);
479
+ digest. update(string. bytes);
480
480
return new BigInteger (1 , digest. digest()). toString(16 ). padLeft(32 , ' 0' );
481
481
}
482
482
@@ -494,7 +494,7 @@ class EmptyRunnable implements Runnable {
494
494
495
495
// Discover all jars and dynamically create tasks for the extraction of each of them
496
496
def allJars = []
497
- afterEvaluate { project ->
497
+ afterEvaluate { project ->
498
498
def buildType = project. selectedBuildType == " release" ? " Release" : " Debug"
499
499
def jars = []
500
500
Pattern pattern = Pattern . compile(" ^(.+)${ buildType} CompileClasspath\$ " )
@@ -515,11 +515,18 @@ afterEvaluate { project ->
515
515
516
516
def taskName = " extract_${ jar.name} _to_${ destDir} "
517
517
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
+
518
525
task " ${ taskName} " (type : WorkerTask ) {
519
526
dependsOn cleanupAllJars
520
527
extractAllJars. dependsOn it
521
528
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,
523
530
// without it `runSbg` sporadically starts before all extraction tasks have finished and
524
531
// fails due to missing JARs
525
532
runSbg. dependsOn it
@@ -544,10 +551,10 @@ afterEvaluate { project ->
544
551
}
545
552
546
553
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
550
556
inputs. files(pluginDependencies)
557
+
551
558
outputs. files cleanupAllJarsTimestamp
552
559
553
560
doLast {
0 commit comments