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 86bb31c3..5d0617de 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ 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 " " }