Skip to content

Commit cc1eea7

Browse files
committed
Fix shadowJar/jar race for overriding embedded-runtime JARs
On Travis CI builds, the normal "jar" task would run after "shadowJar", which overwrote the correct JAR with a corrupted, empty version. Now, the default task is disabled & extended with a delegate to shadow.
1 parent 752c5b0 commit cc1eea7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

android-junit5-embedded-runtime/build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ dependencies {
3131
shadowJar {
3232
// Remove '-all' suffix from the generated JAR
3333
classifier = null
34+
version = VERSION_NAME
3435
}
3536

36-
build.finalizedBy shadowJar
37-
publish.dependsOn shadowJar
37+
// Replace the default JAR task with the "shadow version",
38+
// to avoid accidentally overriding it with the empty, non-shadowed JAR
39+
// upon deploying a version to users via Bintray or Sonatype OSS
40+
jar.enabled = false
41+
jar.dependsOn shadowJar
3842

3943
// ------------------------------------------------------------------------------------------------
4044
// Deployment Setup
@@ -83,8 +87,7 @@ def verifyJarNotEmpty = {
8387
// Manually verify that the JAR file isn't "empty"
8488
// before attempting the upload. This happens on accidental
8589
// upload attempts without first deploying the shadowJar.
86-
def jarFileName = file("$buildDir/libs/${project.name}-${VERSION_NAME}.jar")
87-
def jarFile = new JarFile(jarFileName)
90+
def jarFile = new JarFile(shadowJar.archivePath)
8891
if (jarFile.getEntry("com") == null) {
8992
throw new AssertionError("The embedded-runtime JAR is empty!")
9093
}
@@ -106,7 +109,6 @@ project.configure(project) {
106109
}
107110
}
108111
publish.doFirst verifyJarNotEmpty
109-
110112
} else {
111113
// Configure deployment of release versions to Bintray
112114
project.bintray {

0 commit comments

Comments
 (0)