Skip to content

Commit d8c229a

Browse files
committed
More test docs & a guard around future accidental uploads of empty runtime JARs
1 parent 9bad031 commit d8c229a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

android-junit5-embedded-runtime/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.jar.JarFile
2+
13
buildscript {
24
repositories {
35
jcenter()
@@ -77,6 +79,17 @@ task copyPom(type: Copy) {
7779

7880
publish.dependsOn copyPom
7981

82+
def verifyJarNotEmpty = {
83+
// Manually verify that the JAR file isn't "empty"
84+
// before attempting the upload. This happens on accidental
85+
// upload attempts without first deploying the shadowJar.
86+
def jarFileName = file("$buildDir/libs/${project.name}-${VERSION_NAME}.jar")
87+
def jarFile = new JarFile(jarFileName)
88+
if (jarFile.getEntry("com") == null) {
89+
throw new AssertionError("The embedded-runtime JAR is empty!")
90+
}
91+
}
92+
8093
project.configure(project) {
8194
if (project.version.endsWith("-SNAPSHOT")) {
8295
// Configure deployment of snapshot versions to Sonatype OSS
@@ -92,6 +105,8 @@ project.configure(project) {
92105
}
93106
}
94107
}
108+
publish.doFirst verifyJarNotEmpty
109+
95110
} else {
96111
// Configure deployment of release versions to Bintray
97112
project.bintray {
@@ -113,5 +128,7 @@ project.configure(project) {
113128
}
114129
}
115130
}
131+
132+
bintrayUpload.doFirst verifyJarNotEmpty
116133
}
117134
}

android-junit5/src/test/groovy/de/mannodermaus/gradle/plugins/android_junit5/BaseFunctionalSpec.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ import java.nio.file.Paths
1515

1616
import static de.mannodermaus.gradle.plugins.android_junit5.util.StringUtils.splitClasspath
1717

18+
/*
19+
* Base class for functional tests of the plugin
20+
* across different versions of the Android Gradle Plugin.
21+
* It is extended inside the respective sub-configurations for
22+
* Android Gradle Plugin 2 & 3, which then drive the execution
23+
* of unit tests embedded in "virtual projects", as if the plugin
24+
* was applied to an actual client project. To do this, there are
25+
* several factory-like methods that write pieces of the build script
26+
* into a temporary file and allow for a clean "given-when-then" approach
27+
* to setting up those temporary projects.
28+
*
29+
* This class tests the runtime behaviour of
30+
* the test tasks generated by the plugin,
31+
* rather than the structural integrity, which is enforced by BasePluginSpec.
32+
*/
33+
1834
abstract class BaseFunctionalSpec extends Specification {
1935

2036
@Rule

0 commit comments

Comments
 (0)