Skip to content

Commit

Permalink
Fix shadowJar/jar race for overriding embedded-runtime JARs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mannodermaus committed Nov 2, 2017
1 parent 752c5b0 commit cc1eea7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions android-junit5-embedded-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ dependencies {
shadowJar {
// Remove '-all' suffix from the generated JAR
classifier = null
version = VERSION_NAME
}

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

// ------------------------------------------------------------------------------------------------
// Deployment Setup
Expand Down Expand Up @@ -83,8 +87,7 @@ def verifyJarNotEmpty = {
// Manually verify that the JAR file isn't "empty"
// before attempting the upload. This happens on accidental
// upload attempts without first deploying the shadowJar.
def jarFileName = file("$buildDir/libs/${project.name}-${VERSION_NAME}.jar")
def jarFile = new JarFile(jarFileName)
def jarFile = new JarFile(shadowJar.archivePath)
if (jarFile.getEntry("com") == null) {
throw new AssertionError("The embedded-runtime JAR is empty!")
}
Expand All @@ -106,7 +109,6 @@ project.configure(project) {
}
}
publish.doFirst verifyJarNotEmpty

} else {
// Configure deployment of release versions to Bintray
project.bintray {
Expand Down

0 comments on commit cc1eea7

Please sign in to comment.