From 07d7e0179f428fe8ae3a44f63538fa8cc839f0ed Mon Sep 17 00:00:00 2001 From: Marcel Schnelle Date: Sat, 9 Sep 2017 21:12:27 +0900 Subject: [PATCH] Utilize a new Fat JAR module to embed the runtime using a new artifact --- LICENSE.md | 8 ++- .../LICENSE.md | 3 +- android-junit5-embedded-runtime/build.gradle | 56 ++++++++----------- LICENSE-epl2.md => android-junit5/LICENSE.md | 0 android-junit5/build.gradle | 10 ++-- gradle.properties | 16 ++++-- sample/build.gradle | 8 +-- 7 files changed, 48 insertions(+), 53 deletions(-) rename LICENSE-apache.md => android-junit5-embedded-runtime/LICENSE.md (99%) rename LICENSE-epl2.md => android-junit5/LICENSE.md (100%) diff --git a/LICENSE.md b/LICENSE.md index c89ee694..60bc3a05 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,9 @@ Open Source Licenses ==================== -This repository includes multiple licenses: +The individual modules use different open source licenses: -- The bundled `junit5-rt.jar` is taken from intellij-community & released under [Apache License v2.0](LICENSE-apache.md) -- The remaining code mirrors JUnit 5's license & is released under [Eclipse Public License v2.0](LICENSE-epl2.md) +- `android-junit5-embedded-runtime` uses [Apache License v2.0](android-junit5-embedded-runtime/LICENSE.md) +- All other modules use [Eclipse Public License v2.0](android-junit5/LICENSE.md) + +Please see the `LICENSE.md` files in the subfolders for details. diff --git a/LICENSE-apache.md b/android-junit5-embedded-runtime/LICENSE.md similarity index 99% rename from LICENSE-apache.md rename to android-junit5-embedded-runtime/LICENSE.md index d4c76698..edc580cd 100644 --- a/LICENSE-apache.md +++ b/android-junit5-embedded-runtime/LICENSE.md @@ -199,4 +199,5 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. + No newline at end of file diff --git a/android-junit5-embedded-runtime/build.gradle b/android-junit5-embedded-runtime/build.gradle index 8179949a..0206dcf2 100644 --- a/android-junit5-embedded-runtime/build.gradle +++ b/android-junit5-embedded-runtime/build.gradle @@ -1,6 +1,16 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath "com.github.jengelman.gradle.plugins:shadow:$SHADOW_PLUGIN_VERSION" + } +} + apply plugin: "java-library" apply plugin: "maven" apply plugin: "maven-publish" +apply plugin: "com.github.johnrengelman.shadow" apply plugin: "com.jfrog.bintray" sourceCompatibility = JavaVersion.VERSION_1_6 @@ -8,12 +18,21 @@ targetCompatibility = JavaVersion.VERSION_1_6 // ------------------------------------------------------------------------------------------------ // Dependency Definitions +// This module exports a "fat JAR" with the embedded junit5-rt from IntelliJ IDEA, +// using a shadowed JAR that overrides the default build artifact. // ------------------------------------------------------------------------------------------------ dependencies { implementation files("libs/junit5-rt.jar") } +shadowJar { + // Remove '-all' suffix from the generated JAR + classifier = null +} + +build.doLast { shadowJar.execute() } + // ------------------------------------------------------------------------------------------------ // Deployment Setup // @@ -21,41 +40,12 @@ dependencies { // This section defines the necessary tasks to push new releases and snapshots using Gradle tasks. // ------------------------------------------------------------------------------------------------ -// Include sources.jar archive in each release -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} - -// Include javadoc.jar archive in each release -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = "javadoc" - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -project.ext.artifactId = "android-junit5-embedded-runtime" version = VERSION_NAME publishing { publications { library(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - groupId GROUP_ID - artifactId project.ext.artifactId - version VERSION_NAME - pom.withXml { - def root = asNode() - root.appendNode("description", DESCRIPTION) - root.appendNode("name", project.ext.artifactId) - root.appendNode("url", VCS_URL) - } + project.shadow.component(it) } } } @@ -94,15 +84,15 @@ project.configure(project) { dryRun = false pkg { repo = "maven" - name = project.ext.artifactId + name = RUNTIME_ARTIFACT_ID userOrg = project.ext.bintrayUser - licenses = [LICENCE_NAME] + licenses = [RUNTIME_LICENSE_NAME] publish = true publicDownloadNumbers = true vcsUrl = VCS_URL version { name = VERSION_NAME - desc = DESCRIPTION + desc = RUNTIME_DESCRIPTION } } } diff --git a/LICENSE-epl2.md b/android-junit5/LICENSE.md similarity index 100% rename from LICENSE-epl2.md rename to android-junit5/LICENSE.md diff --git a/android-junit5/build.gradle b/android-junit5/build.gradle index b50f73dd..e5e93c32 100644 --- a/android-junit5/build.gradle +++ b/android-junit5/build.gradle @@ -117,12 +117,12 @@ publishing { artifact sourcesJar artifact javadocJar groupId GROUP_ID - artifactId ARTIFACT_ID + artifactId PLUGIN_ARTIFACT_ID version VERSION_NAME pom.withXml { def root = asNode() - root.appendNode("description", DESCRIPTION) - root.appendNode("name", ARTIFACT_ID) + root.appendNode("description", PLUGIN_DESCRIPTION) + root.appendNode("name", PLUGIN_ARTIFACT_ID) root.appendNode("url", VCS_URL) } } @@ -163,9 +163,9 @@ project.configure(project) { dryRun = false pkg { repo = "maven" - name = ARTIFACT_ID + name = PLUGIN_ARTIFACT_ID userOrg = project.ext.bintrayUser - licenses = [LICENCE_NAME] + licenses = [PLUGIN_LICENSE_NAME] publish = true publicDownloadNumbers = true vcsUrl = VCS_URL diff --git a/gradle.properties b/gradle.properties index 441f3775..9d2afb6f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,18 +3,26 @@ # "AGP 3.x requires Studio 3.0 minimum" - workaround to use it inside IJ android.injected.build.model.only.versioned = 3 -# Artifact configuration +# Artifact configuration (common) GROUP_ID = de.mannodermaus.gradle.plugins -ARTIFACT_ID = android-junit5 VERSION_NAME = 1.0.0-RC3-rev1-SNAPSHOT -LICENCE_NAME = EPL-1.0 -DESCRIPTION = Unit Testing with JUnit 5 for Android. VCS_URL = https://github.com/aurae/android-junit5 +# Artifact configuration (plugin) +PLUGIN_ARTIFACT_ID = android-junit5 +PLUGIN_LICENSE_NAME = EPL-2.0 +PLUGIN_DESCRIPTION = Unit Testing with JUnit 5 for Android. + +# Artifact configuration (embedded-runtime) +RUNTIME_ARTIFACT_ID = android-junit5-embedded-runtime +RUNTIME_LICENSE_NAME = Apache-2.0 +RUNTIME_DESCRIPTION = Mirror of IntelliJ IDEA's embedded JUnit 5 Runtime. + # Dependency versions (plugins) ANDROID_PLUGIN_2X_VERSION = 2.3.2 ANDROID_PLUGIN_3X_VERSION = 3.0.0-beta5 BINTRAY_PLUGIN_VERSION = 1.7.3 +SHADOW_PLUGIN_VERSION = 2.0.1 # Dependency versions JUNIT_PLATFORM_VERSION = 1.0.0-RC3 diff --git a/sample/build.gradle b/sample/build.gradle index 1cd0ae26..dae691da 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,16 +9,10 @@ buildscript { dependencies { //noinspection GradleDynamicVersion - classpath ("de.mannodermaus.gradle.plugins:android-junit5:1.0.0-RC3") { -// changing = true - } + classpath "de.mannodermaus.gradle.plugins:android-junit5:+" classpath "com.android.tools.build:gradle:$ANDROID_PLUGIN_3X_VERSION" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } - - configurations.classpath { -// resolutionStrategy.cacheChangingModulesFor 0, "minutes" - } } apply plugin: "com.android.application"