From 07015f581ae300cf17e2010edfdf5c8f58788f91 Mon Sep 17 00:00:00 2001 From: Marcel Schnelle Date: Fri, 19 May 2017 21:58:15 +0200 Subject: [PATCH] Released 1.0.0-M4-rev1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Some advancements towards AGP 3.0.0 * Expanded Unit Test suite to run tests for 2.x & 3.x variants of the AGP * Mark test source folders as such in IDEA * Use default JUnit Platform version * Performed some sweeping inside the plugin’s compile & runtime dependencies, and tasks * JUnit 4 is included by default, which allows AS builds w/o “class not found” * Deprecated junitVintage() dependency handler & issue a warning * Both TestEngines are included on the runtime classpath by default * Disable the default unit test task if JUnit 5 is used * Some clean-up * Moved around unit test cases for 2.x & 3.x * Bump to 1.0.0-M4-rev1 --- .idea/runConfigurations/Run_Unit_Tests.xml | 2 + README.md | 9 +- android-junit5/build.gradle | 51 ++++++- .../gradle/anj5/AndroidJUnit5Compat.groovy | 22 +++ .../AndroidJUnit5PlatformExtension.groovy | 3 + .../anj5/AndroidJUnitPlatformPlugin.groovy | 79 ++++++----- .../anj5/AndroidJUnitPlatformSpec.groovy | 126 +++++------------- .../anj5/AndroidJUnitPlatformAgp2xSpec.groovy | 109 +++++++++++++++ .../anj5/AndroidJUnitPlatformAgp3xSpec.groovy | 84 ++++++++++++ build.gradle | 3 +- gradle.properties | 22 +-- gradle/wrapper/gradle-wrapper.jar | Bin 54783 -> 54793 bytes gradle/wrapper/gradle-wrapper.properties | 4 +- gradlew | 6 +- 14 files changed, 365 insertions(+), 155 deletions(-) create mode 100644 android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5Compat.groovy create mode 100644 android-junit5/src/testAgp2x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp2xSpec.groovy create mode 100644 android-junit5/src/testAgp3x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp3xSpec.groovy diff --git a/.idea/runConfigurations/Run_Unit_Tests.xml b/.idea/runConfigurations/Run_Unit_Tests.xml index ba63410a..84ff2779 100644 --- a/.idea/runConfigurations/Run_Unit_Tests.xml +++ b/.idea/runConfigurations/Run_Unit_Tests.xml @@ -10,6 +10,8 @@ diff --git a/README.md b/README.md index 61aca01b..5ac69455 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ buildscript { } dependencies { // 2. Add the plugin as a classpath dependency - classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0-M4" + classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0-M4-rev1" } } @@ -22,15 +22,14 @@ apply plugin: "de.mannodermaus.android-junit5" dependencies { // 4. Add the testCompile dependencies on JUnit Jupiter testCompile junitJupiter() - - // 5. (Optional) Add the testCompile dependency on the JUnit Vintage Engine - testCompile junitVintage() } ``` ## Usage -This plugin configures the `junitPlatform` task for each registered build variant of a project. Further instructions on how to write JUnit 5 tests can be found [in their User Guide][junit5ug]. +This plugin configures the `junitPlatform` task for each registered build variant of a project. Starting with version `1.0.0-M4-rev1`, the plugin automatically attaches both the Jupiter & Vintage Engines. + +Further instructions on how to write JUnit 5 tests can be found [in their User Guide][junit5ug]. ## Extras diff --git a/android-junit5/build.gradle b/android-junit5/build.gradle index 438a9ba1..6ccddd5a 100644 --- a/android-junit5/build.gradle +++ b/android-junit5/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'groovy' +apply plugin: 'idea' apply plugin: 'maven' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' @@ -6,18 +7,64 @@ apply plugin: 'com.jfrog.bintray' sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 +configurations { + testAgp2xCompile { + extendsFrom configurations.testCompile + } + testAgp3xCompile { + extendsFrom configurations.testCompile + } +} + +sourceSets { + testAgp2x { + java.srcDir "src/testAgp2x/groovy" + compileClasspath += sourceSets.test.output + runtimeClasspath += sourceSets.test.output + } + testAgp3x { + java.srcDir "src/testAgp3x/groovy" + compileClasspath += sourceSets.test.output + runtimeClasspath += sourceSets.test.output + } +} + +idea { + module { + testSourceDirs += file("src/testAgp2x/groovy") + testSourceDirs += file("src/testAgp3x/groovy") + } +} + dependencies { compile gradleApi() compile localGroovy() compile "org.junit.platform:junit-platform-gradle-plugin:$JUNIT_PLATFORM_VERSION" - testCompile "com.android.tools.build:gradle:$ANDROID_PLUGIN_VERSION" + testCompile "junit:junit:$JUNIT4_VERSION" testCompile("org.spockframework:spock-core:$SPOCK_VERSION") { transitive = false } - testCompile "junit:junit:$JUNIT4_VERSION" + + testAgp2xCompile "com.android.tools.build:gradle:2.3.2" + testAgp3xCompile "com.android.tools.build:gradle:3.0.0-alpha1" } +// Run Unit Tests against Android Gradle Plugin version 2.x +task testAgp2x(type: Test) { + testClassesDirs = sourceSets.testAgp2x.output.classesDirs + classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp2x.runtimeClasspath +} + +// Run Unit Tests against Android Gradle Plugin version 3.x +task testAgp3x(type: Test) { + testClassesDirs = sourceSets.testAgp3x.output.classesDirs + classpath = sourceSets.main.runtimeClasspath + sourceSets.testAgp3x.runtimeClasspath +} + +// Combine all tests when executing the main JUnit task +tasks.getByName("test").dependsOn(testAgp2x, testAgp3x) + version = VERSION_NAME bintray { diff --git a/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5Compat.groovy b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5Compat.groovy new file mode 100644 index 00000000..a03b3eb7 --- /dev/null +++ b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5Compat.groovy @@ -0,0 +1,22 @@ +package de.mannodermaus.gradle.anj5 + +class AndroidJUnit5Compat { + + /** + * Fetches the Java output directories for the given Variant scopes + * across different versions of the Android Gradle plugin. + * @param variantScope VariantScope to look up the Java outputs from + * @return An Iterable container depicting the output directories + */ + static Iterable getJavaOutputDirs(variantScope) { + if (variantScope.hasProperty("javaOutputs")) { + return variantScope.javaOutputs + + } else if (variantScope.hasProperty("javaOuptuts")) { + return variantScope.javaOuptuts + + } else { + return Collections.singletonList(variantScope.javaOutputDir) + } + } +} diff --git a/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5PlatformExtension.groovy b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5PlatformExtension.groovy index e292db7a..0ab3279b 100644 --- a/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5PlatformExtension.groovy +++ b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnit5PlatformExtension.groovy @@ -9,8 +9,11 @@ import org.junit.platform.gradle.plugin.JUnitPlatformExtension */ class AndroidJUnit5PlatformExtension extends JUnitPlatformExtension { + private static final String PLATFORM_VERSION = "1.0.0-M4" + AndroidJUnit5PlatformExtension(Project project) { super(project) + platformVersion = PLATFORM_VERSION } /** diff --git a/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformPlugin.groovy b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformPlugin.groovy index 241e8cad..b10c1fb4 100644 --- a/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformPlugin.groovy +++ b/android-junit5/src/main/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformPlugin.groovy @@ -18,6 +18,10 @@ import org.junit.platform.gradle.plugin.* */ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { + private static final String LOG_TAG = "[android-junit5]" + + private static final String VINTAGE_WARNING = "AGPBI: {\"kind\":\"warning\",\"text\":\"$LOG_TAG You don't need to depend on junitVintage() directly anymore!\",\"sources\":[{},{}]}" + private static final String EXTENSION_NAME = 'junitPlatform' private static final String TASK_NAME = 'junitPlatformTest' @@ -51,22 +55,34 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { // by this plugin. def configuration = project.configurations.maybeCreate('junitPlatform') configuration.defaultDependencies { deps -> - def version = junitExtension.platformVersion - deps.add(project.dependencies.create("org.junit.platform:junit-platform-launcher:${version}")) - deps.add(project.dependencies.create("org.junit.platform:junit-platform-console:${version}")) + // By default, include both TestEngines + // and the Launcher-related dependencies + // on the runtime classpath + def platformVersion = junitExtension.platformVersion + deps.add(project.dependencies.create("org.junit.platform:junit-platform-launcher:${platformVersion}")) + deps.add(project.dependencies.create("org.junit.platform:junit-platform-console:${platformVersion}")) + + def jupiterVersion = junitExtension.jupiterVersion + deps.add(project.dependencies.create("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")) + + def vintageVersion = junitExtension.vintageVersion + deps.add(project.dependencies.create("org.junit.vintage:junit-vintage-engine:${vintageVersion}")) } // Add a junitJupiter() dependency handler project.dependencies.ext.junitJupiter = { def jupiterVersion = junitExtension.jupiterVersion - project.dependencies.create("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}") - project.dependencies.create("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}") + + return [ + project.dependencies.create("junit:junit:4.12"), + project.dependencies.create("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}"), + ] } // Add a junitVintage() dependency handler project.dependencies.ext.junitVintage = { - def vintageVersion = junitExtension.vintageVersion - project.dependencies.create("org.junit.vintage:junit-vintage-engine:${vintageVersion}") + project.logger.warn(VINTAGE_WARNING) + return [] } project.afterEvaluate { @@ -86,12 +102,12 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { // Obtain variant properties def variantData = variant.variantData def variantScope = variantData.scope - def scopeJavaOutputs = variantScope.hasProperty("javaOutputs") ? variantScope.javaOutputs : variantScope.javaOuptuts + def scopeJavaOutputs = AndroidJUnit5Compat.getJavaOutputDirs(variantScope) // Obtain tested variant properties def testedVariantData = variant.testedVariant.variantData def testedVariantScope = testedVariantData.scope - def testedScopeJavaOutputs = testedVariantScope.hasProperty("javaOutputs") ? testedVariantScope.javaOutputs : testedVariantScope.javaOuptuts + def testedScopeJavaOutputs = AndroidJUnit5Compat.getJavaOutputDirs(testedVariantScope) // Collect the root directories for unit tests from the variant's scopes def testRootDirs = [] @@ -111,11 +127,14 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { classpath.add(scopeJavaOutputs) } - // 2) Add the testApk configuration - def testApk = project.configurations.findByName("testApk") - if (testApk != null) { - classpath.add(testApk) - } + // 2) Add the runtime configurations +// def testRuntime = project.configurations.findByName("testRuntimeOnly") +// if (testRuntime == null) { +// testRuntime = project.configurations.findByName("testApk") +// } +// if (testRuntime != null) { +// classpath.add(testRuntime) +// } // 3) Add test resources classpath.add(variantData.javaResourcesForUnitTesting) @@ -123,7 +142,9 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { // 4) Add filtered boot classpath def globalScope = variantScope.globalScope - classpath.add(globalScope.androidBuilder.getBootClasspath(false).findAll { it.name != "android.jar" }) + classpath.add(globalScope.androidBuilder.getBootClasspath(false).findAll { + it.name != "android.jar" + }) // 5) Add mocked version of android.jar classpath.add(globalScope.mockableAndroidJarFile) @@ -152,6 +173,11 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { group: 'verification', description: 'Runs tests on the JUnit Platform.') { junitTask -> + // Disable the default Unit Test task, since we're running JUnit 5 anyway + def defaultTestTask = project.tasks.findByName("test${nameSuffix}UnitTest") + defaultTestTask.setEnabled(false) + defaultTestTask.dependsOn += junitTask + junitTask.inputs.property('enableStandardTestTask', junitExtension.enableStandardTestTask) junitTask.inputs.property('selectors.uris', junitExtension.selectors.uris) junitTask.inputs.property('selectors.files', junitExtension.selectors.files) @@ -188,25 +214,6 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { junitTask.main = ConsoleLauncher.class.getName() junitTask.args buildArgs(project, junitExtension, reportsDir, testRootDirs) - - doFirst { - project.logger.info("CLASS PATH ==") - classpath.each { - project.logger.info("$it") - } - project.logger.info("=============") - project.logger.info("TASK ARGS ===") - project.logger.info("${junitTask.args.join(" ")}") - project.logger.info("=============") - -// def rootDirs = [] -// project.sourceSets.each { sourceSet -> -// rootDirs.add(sourceSet.output.classesDir) -// rootDirs.add(sourceSet.output.resourcesDir) -// rootDirs.addAll(sourceSet.output.dirs.files) -// } -// args.addAll(['--scan-class-path', rootDirs.join(File.pathSeparator)]) - } } } @@ -245,10 +252,10 @@ class AndroidJUnitPlatformPlugin extends JUnitPlatformPlugin { args.addAll(['-n', pattern]) } filters.packages.include.each { includedPackage -> - args.addAll(['--include-package',includedPackage]) + args.addAll(['--include-package', includedPackage]) } filters.packages.exclude.each { excludedPackage -> - args.addAll(['--exclude-package',excludedPackage]) + args.addAll(['--exclude-package', excludedPackage]) } filters.tags.include.each { tag -> args.addAll(['-t', tag]) diff --git a/android-junit5/src/test/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformSpec.groovy b/android-junit5/src/test/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformSpec.groovy index 200d3e06..c3b1ae92 100644 --- a/android-junit5/src/test/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformSpec.groovy +++ b/android-junit5/src/test/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformSpec.groovy @@ -2,19 +2,29 @@ package de.mannodermaus.gradle.anj5 import org.gradle.api.Project import org.gradle.api.internal.plugins.PluginApplicationException -import org.gradle.internal.resolve.ModuleVersionNotFoundException import org.gradle.testfixtures.ProjectBuilder import spock.lang.Specification -class AndroidJUnitPlatformSpec extends Specification { - - private static final COMPILE_SDK = 25 - private static final BUILD_TOOLS = "25.0.2" - private static final MIN_SDK = 25 - private static final TARGET_SDK = 25 - private static final VERSION_CODE = 1 - private static final VERSION_NAME = "1.0" - private static final APPLICATION_ID = "org.junit.android.sample" +/** + * Base class for Unit Tests of the android-junit5 plugin. + * The structure of this project allows common unit tests + * to be executed with different versions of the Android Gradle plugin backing it up. + */ +abstract class AndroidJUnitPlatformSpec extends Specification { + + protected static final COMPILE_SDK = 25 + protected static final BUILD_TOOLS = "25.0.2" + protected static final MIN_SDK = 25 + protected static final TARGET_SDK = 25 + protected static final VERSION_CODE = 1 + protected static final VERSION_NAME = "1.0" + protected static final APPLICATION_ID = "org.junit.android.sample" + protected static final ANDROID_MANIFEST = """ + + + """ /* SDK Directory, taken from the project itself and setup */ static String sdkDir @@ -65,6 +75,8 @@ class AndroidJUnitPlatformSpec extends Specification { when: Project p = ProjectBuilder.builder().withParent(testRoot).build() p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } p.apply plugin: 'com.android.application' p.apply plugin: 'de.mannodermaus.android-junit5' @@ -91,15 +103,8 @@ class AndroidJUnitPlatformSpec extends Specification { when: Project p = ProjectBuilder.builder().withParent(testRoot).build() p.file(".").mkdir() - - // Library projects require an AndroidManifest - def mainDir = p.file("src/main") - mainDir.mkdirs() - p.file("${mainDir.absolutePath}/AndroidManifest.xml").withWriter { - it.write( - "" - ) - } + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } p.apply plugin: 'com.android.library' p.apply plugin: 'de.mannodermaus.android-junit5' @@ -118,6 +123,8 @@ class AndroidJUnitPlatformSpec extends Specification { when: Project p = ProjectBuilder.builder().withParent(testRoot).build() p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } p.apply plugin: 'com.android.application' p.apply plugin: 'de.mannodermaus.android-junit5' @@ -133,11 +140,15 @@ class AndroidJUnitPlatformSpec extends Specification { versionName VERSION_NAME } + flavorDimensions "plan" + productFlavors { free { + dimension "plan" } paid { + dimension "plan" } } } @@ -149,81 +160,4 @@ class AndroidJUnitPlatformSpec extends Specification { p.tasks.getByName("junitPlatformTestPaidDebug") p.tasks.getByName("junitPlatformTestPaidRelease") } - - def "custom junit jupiter version"() { - when: - def nonExistentVersion = "0.0.0" - - Project p = ProjectBuilder.builder().withParent(testRoot).build() - p.file(".").mkdir() - - p.apply plugin: 'com.android.application' - p.apply plugin: 'de.mannodermaus.android-junit5' - p.android { - compileSdkVersion COMPILE_SDK - buildToolsVersion BUILD_TOOLS - - defaultConfig { - applicationId APPLICATION_ID - minSdkVersion MIN_SDK - targetSdkVersion TARGET_SDK - versionCode VERSION_CODE - versionName VERSION_NAME - } - } - p.junitPlatform { - // Some arbitrary non-existent version - jupiterVersion nonExistentVersion - } - p.dependencies { - testCompile junitJupiter() - } - - then: - try { - p.evaluate() - throw new AssertionError("Expected ${ModuleVersionNotFoundException.class.name}, but wasn't thrown") - - } catch (Throwable expected) { - while (expected != null) { - if (expected instanceof ModuleVersionNotFoundException) { - assert expected.message.contains("Could not find org.junit.jupiter:junit-jupiter-engine:$nonExistentVersion.") - break - } - expected = expected.cause - } - - if (expected == null) { - throw new AssertionError("Expected ${ModuleVersionNotFoundException.class.name}, but wasn't thrown") - } - } - } - - def "junit jupiter dependency extension works"() { - when: - Project p = ProjectBuilder.builder().withParent(testRoot).build() - p.file(".").mkdir() - - p.apply plugin: 'com.android.application' - p.apply plugin: 'de.mannodermaus.android-junit5' - p.android { - compileSdkVersion COMPILE_SDK - buildToolsVersion BUILD_TOOLS - - defaultConfig { - applicationId APPLICATION_ID - minSdkVersion MIN_SDK - targetSdkVersion TARGET_SDK - versionCode VERSION_CODE - versionName VERSION_NAME - } - } - p.dependencies { - testCompile junitJupiter() - } - - then: - def testCompileDeps = p.configurations.getByName("testCompile").dependencies - testCompileDeps.find { it.group == "org.junit.jupiter" && it.name == "junit-jupiter-engine" } != null - } } diff --git a/android-junit5/src/testAgp2x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp2xSpec.groovy b/android-junit5/src/testAgp2x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp2xSpec.groovy new file mode 100644 index 00000000..8039e451 --- /dev/null +++ b/android-junit5/src/testAgp2x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp2xSpec.groovy @@ -0,0 +1,109 @@ +package de.mannodermaus.gradle.anj5 + +import org.gradle.api.Project +import org.gradle.api.logging.LogLevel +import org.gradle.api.logging.StandardOutputListener +import org.gradle.internal.logging.services.DefaultLoggingManager +import org.gradle.internal.logging.services.DefaultLoggingManagerFactory +import org.gradle.internal.resolve.ModuleVersionNotFoundException +import org.gradle.testfixtures.ProjectBuilder + +/** + * Unit Tests of the android-junit5 plugin for the Android Gradle Plugin 2.x. + * This is applied on top of the default test cases that this class inherits. + */ +class AndroidJUnitPlatformAgp2xSpec extends AndroidJUnitPlatformSpec { + + def "custom junit jupiter version"() { + when: + def nonExistentVersion = "0.0.0" + + Project p = ProjectBuilder.builder().withParent(testRoot).build() + p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } + + p.apply plugin: 'com.android.application' + p.apply plugin: 'de.mannodermaus.android-junit5' + p.android { + compileSdkVersion COMPILE_SDK + buildToolsVersion BUILD_TOOLS + + defaultConfig { + applicationId APPLICATION_ID + minSdkVersion MIN_SDK + targetSdkVersion TARGET_SDK + versionCode VERSION_CODE + versionName VERSION_NAME + } + } + p.junitPlatform { + // Some arbitrary non-existent version + jupiterVersion nonExistentVersion + } + p.repositories { + jcenter() + } + p.dependencies { + testCompile junitJupiter() + } + + then: + // AGP 2.x throws a ModuleVersionNotFoundException here + try { + p.evaluate() + throw new AssertionError("Expected ${ModuleVersionNotFoundException.class.name}, but wasn't thrown") + + } catch (Throwable expected) { + while (expected != null) { + if (expected instanceof ModuleVersionNotFoundException) { + assert expected.message.contains("Could not find org.junit.jupiter") + assert expected.message.contains("$nonExistentVersion") + break + } + expected = expected.cause + } + + if (expected == null) { + throw new AssertionError("Expected ${ModuleVersionNotFoundException.class.name}, but wasn't thrown") + } + } + } + + def "show warning if depending on junitVintage() directly"() { + when: + Project p = ProjectBuilder.builder().withParent(testRoot).build() + + p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } + + p.apply plugin: 'com.android.application' + p.apply plugin: 'de.mannodermaus.android-junit5' + p.android { + compileSdkVersion COMPILE_SDK + buildToolsVersion BUILD_TOOLS + + defaultConfig { + applicationId APPLICATION_ID + minSdkVersion MIN_SDK + targetSdkVersion TARGET_SDK + versionCode VERSION_CODE + versionName VERSION_NAME + } + } + p.repositories { + jcenter() + } + p.dependencies { + testCompile junitJupiter() + testApk junitVintage() + } + + then: + p.evaluate() + // Unsure how to capture the output directly + // (Project.logging listeners don't seem to work) + assert true == true + } +} diff --git a/android-junit5/src/testAgp3x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp3xSpec.groovy b/android-junit5/src/testAgp3x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp3xSpec.groovy new file mode 100644 index 00000000..f903b664 --- /dev/null +++ b/android-junit5/src/testAgp3x/groovy/de/mannodermaus/gradle/anj5/AndroidJUnitPlatformAgp3xSpec.groovy @@ -0,0 +1,84 @@ +package de.mannodermaus.gradle.anj5 + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder + +class AndroidJUnitPlatformAgp3xSpec extends AndroidJUnitPlatformSpec { + + def "custom junit jupiter version"() { + when: + def nonExistentVersion = "0.0.0" + + Project p = ProjectBuilder.builder().withParent(testRoot).build() + p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } + + p.apply plugin: 'com.android.application' + p.apply plugin: 'de.mannodermaus.android-junit5' + p.android { + compileSdkVersion COMPILE_SDK + buildToolsVersion BUILD_TOOLS + + defaultConfig { + applicationId APPLICATION_ID + minSdkVersion MIN_SDK + targetSdkVersion TARGET_SDK + versionCode VERSION_CODE + versionName VERSION_NAME + } + } + p.junitPlatform { + // Some arbitrary non-existent version + jupiterVersion nonExistentVersion + } + p.dependencies { + testApi junitJupiter() + } + + then: + p.evaluate() + + def testApiDeps = p.configurations.getByName("testApi").dependencies + assert testApiDeps.find { + it.group == "org.junit.jupiter" && it.name == "junit-jupiter-api" && it.version == nonExistentVersion + } != null + + assert testApiDeps.find { + it.group == "junit" && it.name == "junit" && it.version == "4.12" + } != null + } + + def "show warning if depending on junitVintage() directly"() { + when: + Project p = ProjectBuilder.builder().withParent(testRoot).build() + p.file(".").mkdir() + p.file("src/main").mkdirs() + p.file("src/main/AndroidManifest.xml").withWriter { it.write(ANDROID_MANIFEST) } + + p.apply plugin: 'com.android.application' + p.apply plugin: 'de.mannodermaus.android-junit5' + p.android { + compileSdkVersion COMPILE_SDK + buildToolsVersion BUILD_TOOLS + + defaultConfig { + applicationId APPLICATION_ID + minSdkVersion MIN_SDK + targetSdkVersion TARGET_SDK + versionCode VERSION_CODE + versionName VERSION_NAME + } + } + p.dependencies { + testApi junitJupiter() + testRuntimeOnly junitVintage() + } + + then: + p.evaluate() + // Unsure how to capture the output directly + // (Project.logging listeners don't seem to work) + assert true == true + } +} diff --git a/build.gradle b/build.gradle index 4fc2f703..69d5a41b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ buildscript { repositories { + google() jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath "com.android.tools.build:gradle:$ANDROID_PLUGIN_VERSION" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$BINTRAY_PLUGIN_VERSION" } } @@ -13,6 +13,7 @@ Properties properties = new Properties() properties.load(new FileInputStream(new File(rootProject.projectDir, "local.properties"))) allprojects { repositories { + google() jcenter() } ext { diff --git a/gradle.properties b/gradle.properties index 10b36a0f..a5321375 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,17 @@ +# suppress inspection "UnusedProperty" for whole file + # Artifact configuration -GROUP_ID=de.mannodermaus.gradle.plugins -ARTIFACT_ID=android-junit5 -VERSION_NAME=1.0.0-M4 -DESCRIPTION=Unit Testing with JUnit 5 for Android. -VCS_URL=https://github.com/aurae/android-junit5 +GROUP_ID = de.mannodermaus.gradle.plugins +ARTIFACT_ID = android-junit5 +VERSION_NAME = 1.0.0-M4-rev1 +DESCRIPTION = Unit Testing with JUnit 5 for Android. +VCS_URL = https://github.com/aurae/android-junit5 # Dependency versions (plugins) -ANDROID_PLUGIN_VERSION=2.3.0 -BINTRAY_PLUGIN_VERSION=1.3.1 +ANDROID_PLUGIN_VERSION = 3.0.0-alpha1 +BINTRAY_PLUGIN_VERSION = 1.3.1 # Dependency versions -JUNIT_PLATFORM_VERSION=1.0.0-M4 -SPOCK_VERSION=1.0-groovy-2.4 -JUNIT4_VERSION=4.12 +JUNIT_PLATFORM_VERSION = 1.0.0-M4 +SPOCK_VERSION = 1.0-groovy-2.4 +JUNIT4_VERSION = 4.12 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 86bb31c338b34c8101fdef325dd59b342e4dcd55..5d0617def3d225d6a778e1bc8429a439a18677e8 100644 GIT binary patch delta 4395 zcmYk9c{Ei2|HpHckc6>L_T30&9a~Z+J6VRt8WLhKg~)PKvPWF949dRCPWEK^2xDK9 zHL{dFOD4X4^X>OJ-+RtI_wjtZ-sjx&dcR-)yiW?r!-~jX%bg3Y4Su2=ql7-6{H${O z5!sp7@UqHZlxGvE%sQcBs%s$o80I*wvR(@QiuV1L3Fl6NLNyHIkb?B$?Tiw@RNHHp z7gc>L;SgeTQXiZwz9M)r7D)1(o*)vw7Te<<~YVdS7_X?Kz46w6_l*_!1p|ATr z(w#GI>#^14jl9gC<4DevQfqYVNAYEcdnQvlXK1plc@7kTVa%2;SFei8uJUF?=o+p+ zFynO{Xg_r$?ZtJWtG0M?*P(VVk$WM6UJvKJbfp`UwL7Ab z4II@w>JsUGViEXzpbS#)q_8auIf{N2okBsbZ5Y=~cCxc>_Ch5W`1q zcd3)2kJcC@FHWJ(PDx_J8_HgiU)R}>bQUo5+JElc+xNwF|Fzka#50>oO}*8i<^^d&Jt5NBclyrY&d*B5X^iH9jRQ~WqoOuPHu=Su z>-ss+v1(w`s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}4j4|23Q8_t9 z)oj$Om>9fFB31a9(!IS!!5rYnL`nsfImW3>ZkKs^uOYno!N+o0ZSxWO^M4W#Ls|DW^*{5g~xXZ zzADl@{~pR9T-+FY^4E$7@{@+~9#-jT_Mbtel$Kdto&DE5e2kBHKD#&G!bO#+h8Sst z&PizdhsNCyY9F5S^$OV6;>Z%>@}m;{9Iqf^Wt>3N2ESwRGoGbxU6`Xyo_cSa8wcA` zYW*T(QPpPN;cNDA?3U#q;rZ^QnIgR&ql}{VP)m5pw$}K9));GZ(vyD5s3U*Vr&0T# zM0PEXt_Fa53ff}k{HWLAQ@E7WfY6X*?9sUZnZ;q_Vo~~W6ymp9&fN~j*Z#N&(oKoZ znb2=*o7PJ4bEE7*lxv%hlzP0g7ew4K79QO?X)8fRMA1mObW*sjuv(9l{U^j_>J5z6 zv<_;zci;$=yE7}Yi#

eXJbW?8yHWpmObskfHuV86(9^qNJ4KSbJ$Ms)x z2Ou8`hibNel#|vUmA+EUnVqIu*@F&$m1&lu{@lt-=0l^rD-Xo$0B57yxNloB%V||W z8Jm~|z?+qrN93p|ZW)}X8SxwNV5Oj-UEi#}wz@vpS4IHF5EG!&1p!muJw+Y>*QEqz!T?Z=FfiQ(1$h9p-EeRQ2B^fy z0d~VoKtwkLBnISkKLF3W0oU+6fH+wL?CX9eKe;oWW%9@n@TkX`b@9;!V4VyFfATs- zK>*$(15WWilV80dKtT@_e9iw1ANsQZ482gWP~aKf?L~kegq+FNUSlu^{#2?1F@sEi zQy&DR1cdZCgJCgeb;f>euw?wdk{Sr^hk=a~&Tyt*17ryB57>dFQ~p_OX;#A2r a0|w0yj#~y))c^Rhr>`wD1w};jKlFcQphEEg diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7bdd7a95..43929b43 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed May 03 18:52:32 CEST 2017 +#Thu May 18 21:53:32 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-2-bin.zip diff --git a/gradlew b/gradlew index 4453ccea..cccdd3d5 100755 --- a/gradlew +++ b/gradlew @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " }