Skip to content

Commit 88ca41b

Browse files
authored
JUnit 5.6.2 (#214)
* Cleanup pt. 1 Move into singular dependencies file & update all references in plugin project * Cleanup, pt. 2 * Cleanup, pt. 3 * Update snapshot version of plugin * Update publish name of plugin module * Update CCI cache key
1 parent 835efce commit 88ca41b

14 files changed

Lines changed: 259 additions & 391 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defaults: &defaults
77
GRADLE_OPTS: -Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false
88

99
cache_key: &cache_key
10-
key: jars-{{ checksum "build.gradle.kts" }}-{{ checksum "plugin/android-junit5/build.gradle.kts" }}-{{ checksum "instrumentation/runner/build.gradle.kts" }}-{{ checksum "instrumentation/sample/build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "buildSrc/src/main/kotlin/Artifacts.kt" }}-{{ checksum "buildSrc/src/main/kotlin/Libs.kt" }}-{{ checksum "buildSrc/src/main/kotlin/Versions.kt" }}
10+
key: jars-{{ checksum "build.gradle.kts" }}-{{ checksum "plugin/android-junit5/build.gradle.kts" }}-{{ checksum "instrumentation/runner/build.gradle.kts" }}-{{ checksum "instrumentation/sample/build.gradle.kts" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "buildSrc/src/main/kotlin/Artifacts.kt" }}-{{ checksum "buildSrc/src/main/kotlin/Dependencies.kt" }}
1111

1212
version: 2
1313
jobs:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Furthermore, this repository provides a small showcase of the functionality prov
2424
```groovy
2525
buildscript {
2626
dependencies {
27-
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.6.0.0"
27+
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.6.1.0"
2828
}
2929
}
3030
```
@@ -36,7 +36,7 @@ Furthermore, this repository provides a small showcase of the functionality prov
3636
```kotlin
3737
buildscript {
3838
dependencies {
39-
classpath("de.mannodermaus.gradle.plugins:android-junit5:1.6.0.0")
39+
classpath("de.mannodermaus.gradle.plugins:android-junit5:1.6.1.0")
4040
}
4141
}
4242
```

README.md.template

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ Snapshots of the development version are available through [Sonatype's `snapshot
5151

5252
dependencies {
5353
// (Required) Writing and executing Unit Tests on the JUnit Platform
54-
testImplementation "org.junit.jupiter:junit-jupiter-api:${Versions.org_junit_jupiter}"
55-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${Versions.org_junit_jupiter}"
54+
testImplementation "${Libs.junitJupiterApi}"
55+
testRuntimeOnly "${Libs.junitJupiterEngine}"
5656

5757
// (Optional) If you need "Parameterized Tests"
58-
testImplementation "org.junit.jupiter:junit-jupiter-params:${Versions.org_junit_jupiter}"
58+
testImplementation "${Libs.junitJupiterParams}"
5959

6060
// (Optional) If you also have JUnit 4-based tests
61-
testImplementation "junit:junit:${Versions.junit}"
62-
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${Versions.junit_vintage_engine}"
61+
testImplementation "${Libs.junit4}"
62+
testRuntimeOnly "${Libs.junitVintageEngine}"
6363
}
6464
```
6565
</details>
@@ -74,15 +74,15 @@ Snapshots of the development version are available through [Sonatype's `snapshot
7474

7575
dependencies {
7676
// (Required) Writing and executing Unit Tests on the JUnit Platform
77-
testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.org_junit_jupiter}")
78-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.org_junit_jupiter}")
77+
testImplementation("${Libs.junitJupiterApi}")
78+
testRuntimeOnly("${Libs.junitJupiterEngine}")
7979

8080
// (Optional) If you need "Parameterized Tests"
81-
testImplementation("org.junit.jupiter:junit-jupiter-params:${Versions.org_junit_jupiter}")
81+
testImplementation("${Libs.junitJupiterParams}")
8282

8383
// (Optional) If you also have JUnit 4-based tests
84-
testImplementation("junit:junit:${Versions.junit}")
85-
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${Versions.junit_vintage_engine}")
84+
testImplementation("${Libs.junit4}")
85+
testRuntimeOnly("${Libs.junitVintageEngine}")
8686
}
8787
```
8888
</details>
@@ -129,8 +129,8 @@ To start writing instrumentation tests with JUnit Jupiter, make the following ch
129129

130130
dependencies {
131131
// 5) Jupiter API & Test Runner, if you don't have it already
132-
androidTestImplementation "androidx.test:runner:${Versions.androidx_test_runner}"
133-
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:${Versions.org_junit_jupiter}"
132+
androidTestImplementation "${Libs.androidxTestRunner}"
133+
androidTestImplementation "${Libs.junitJupiterApi}"
134134

135135
// 6) The instrumentation test companion libraries
136136
androidTestImplementation "de.mannodermaus.junit5:android-test-core:${instrumentationVersion}"
@@ -164,8 +164,8 @@ To start writing instrumentation tests with JUnit Jupiter, make the following ch
164164
}
165165
dependencies {
166166
// 5) Jupiter API & Test Runner, if you don't have it already
167-
androidTestImplementation("androidx.test:runner:${Versions.androidx_test_runner}")
168-
androidTestImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.org_junit_jupiter}")
167+
androidTestImplementation("${Libs.androidxTestRunner}")
168+
androidTestImplementation("${Libs.junitJupiterApi}")
169169

170170
// 6) The instrumentation test companion libraries
171171
androidTestImplementation("de.mannodermaus.junit5:android-test-core:${instrumentationVersion}")

build.gradle.kts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
import java.util.Properties
2-
31
buildscript {
42
repositories {
53
google()
64
jcenter()
7-
maven("https://jitpack.io")
8-
maven("https://dl.bintray.com/kotlin/kotlin-eap") // Workaround for bug in AGP 4.0.0-alpha01
5+
jitpack()
96
}
107
dependencies {
11-
classpath(Libs.kotlin_gradle_plugin)
12-
classpath(Libs.com_android_tools_build_gradle)
13-
classpath(Libs.android_maven_publish)
14-
classpath(Libs.gradle_bintray_plugin)
15-
classpath(Libs.android_maven_gradle_plugin)
16-
classpath(Libs.gradle_versions_plugin)
17-
classpath(Libs.dokka_core_plugin)
18-
classpath(Libs.dokka_android_plugin)
8+
classpath(Plugins.kotlin)
9+
classpath(Plugins.android)
10+
classpath(Plugins.androidMavenPublish)
11+
classpath(Plugins.bintray)
12+
classpath(Plugins.androidMavenGradle)
13+
classpath(Plugins.versions)
14+
classpath(Plugins.dokkaCore)
15+
classpath(Plugins.dokkaAndroid)
1916
}
2017
}
2118

22-
plugins {
23-
id("de.fayard.buildSrcVersions") version "0.3.2"
24-
}
25-
26-
allprojects {
19+
subprojects {
2720
repositories {
2821
google()
2922
jcenter()
30-
maven("https://oss.sonatype.org/content/repositories/snapshots")
31-
maven("https://dl.bintray.com/kotlin/kotlin-eap") // Workaround for bug in AGP 4.0.0-alpha01
23+
sonatypeSnapshots()
3224
}
3325

34-
// Store deployment credentials (used in deployment.gradle)
35-
extra["deployCredentials"] = DeployCredentials(project)
26+
// Configure publishing (if the project is eligible for publication)
27+
configurePublishing()
3628
}
3729

3830
tasks.create<GenerateReadme>("generateReadme") {
@@ -52,3 +44,18 @@ tasks.create<GenerateReadme>("generateReadme") {
5244
rootFolder = rootFolder.parentFile
5345
}
5446
}
47+
48+
fun Project.configurePublishing() {
49+
// ------------------------------------------------------------------------------------------------
50+
// Deployment Setup
51+
//
52+
// Releases are pushed to JCenter via Bintray, while snapshots are pushed to Sonatype OSS.
53+
// This section defines the necessary tasks to push new releases and snapshots using Gradle tasks.
54+
// ------------------------------------------------------------------------------------------------
55+
val configuration = Artifacts.from(this) ?: return
56+
ext["deployConfig"] = configuration
57+
ext["deployCredentials"] = DeployedCredentials(this)
58+
afterEvaluate {
59+
apply(from = "$rootDir/gradle/deployment.gradle")
60+
}
61+
}

buildSrc/src/main/kotlin/Artifacts.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@ object Artifacts {
2828
val githubRepo = "mannodermaus/android-junit5"
2929
val license = "Apache-2.0"
3030

31+
/**
32+
* Retrieve the artifact configuration based on a Gradle project reference.
33+
* Return null if none can be found
34+
*/
35+
fun from(project: Project) =
36+
when (project.name) {
37+
"core" -> Instrumentation.Core
38+
"runner" -> Instrumentation.Runner
39+
"android-junit5" -> Plugin
40+
else -> null
41+
}
42+
3143
/**
3244
* Gradle Plugin artifact
3345
*/
3446
val Plugin = Deployed(
3547
platform = Java,
3648
groupId = "de.mannodermaus.gradle.plugins",
3749
artifactId = "android-junit5",
38-
currentVersion = "1.6.1.0",
39-
latestStableVersion = "1.6.0.0",
50+
currentVersion = "1.6.2.0-SNAPSHOT",
51+
latestStableVersion = "1.6.1.0",
4052
license = license,
4153
description = "Unit Testing with JUnit 5 for Android."
4254
)
@@ -71,7 +83,7 @@ object Artifacts {
7183
}
7284
}
7385

74-
class DeployCredentials(private val project: Project) {
86+
class DeployedCredentials(private val project: Project) {
7587

7688
val bintrayUser: String?
7789
val bintrayKey: String?
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import kotlin.String
2+
3+
// Shared versions
4+
5+
private const val kotlinVersion = "1.3.72"
6+
7+
/**
8+
* Gradle plugins used throughout the repository.
9+
* Also, the list of supported AGP versions is maintained here.
10+
*/
11+
object Plugins {
12+
// Maintenance & Build Environment
13+
const val versions: Lib = "com.github.ben-manes:gradle-versions-plugin:0.20.0"
14+
const val kotlin: Lib = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
15+
16+
// Android Gradle Plugin
17+
const val android35x: Agp = "com.android.tools.build:gradle:3.5.3"
18+
const val android36x: Agp = "com.android.tools.build:gradle:3.6.3"
19+
const val android40x: Agp = "com.android.tools.build:gradle:4.0.0-beta05"
20+
const val android41x: Agp = "com.android.tools.build:gradle:4.1.0-alpha08"
21+
const val android: Agp = android35x
22+
23+
val supportedAndroidPlugins = listOf(
24+
android35x,
25+
android36x,
26+
android40x,
27+
android41x
28+
)
29+
30+
// Documentation
31+
const val dokkaCore: Lib = "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18"
32+
const val dokkaAndroid: Lib = "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"
33+
34+
// Publishing
35+
const val androidMavenGradle: Lib = "com.github.dcendents:android-maven-gradle-plugin:2.1"
36+
const val androidMavenPublish: Lib = "digital.wup:android-maven-publish:3.6.2"
37+
const val bintray: Lib = "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
38+
}
39+
40+
/**
41+
* Third-party dependencies used by the modules in this repository.
42+
*/
43+
object Libs {
44+
// Environment & Helpers
45+
const val kotlinStdLib: Lib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
46+
const val kotlinReflect: Lib = "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
47+
const val javaSemver: Lib = "com.github.zafarkhaja:java-semver:0.9.0"
48+
const val annimonStream: Lib = "com.annimon:stream:1.2.1"
49+
const val commonsIO: Lib = "commons-io:commons-io:2.6"
50+
const val commonsLang: Lib = "commons-lang:commons-lang:2.6"
51+
52+
// JUnit 5
53+
private const val junitJupiterVersion = "5.6.2"
54+
private const val junitPlatformVersion = "1.6.2"
55+
private const val junitVintageVersion = "5.6.2"
56+
const val junitJupiterApi: Lib = "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
57+
const val junitJupiterEngine: Lib = "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
58+
const val junitJupiterParams: Lib = "org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion"
59+
const val junitPlatformCommons: Lib = "org.junit.platform:junit-platform-commons:$junitPlatformVersion"
60+
const val junitPlatformEngine: Lib = "org.junit.platform:junit-platform-engine:$junitPlatformVersion"
61+
const val junitPlatformLauncher: Lib = "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
62+
const val junitPlatformRunner: Lib = "org.junit.platform:junit-platform-runner:$junitPlatformVersion"
63+
const val junitVintageEngine: Lib = "org.junit.vintage:junit-vintage-engine:$junitVintageVersion"
64+
65+
// Assertions & Testing
66+
private const val truthVersion = "0.43"
67+
const val truth: Lib = "com.google.truth:truth:$truthVersion"
68+
const val truthJava8Extensions: Lib = "com.google.truth.extensions:truth-java8-extension:$truthVersion"
69+
const val truthAndroidExtensions: Lib = "androidx.test.ext:truth:1.1.0"
70+
71+
const val mockitoCore: Lib = "org.mockito:mockito-core:2.19.0"
72+
const val mockitoKotlin: Lib = "com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0"
73+
74+
const val espressoCore: Lib = "androidx.test.espresso:espresso-core:3.2.0"
75+
const val androidxTestCore: Lib = "androidx.test:core:1.2.0"
76+
const val androidxTestMonitor: Lib = "androidx.test:monitor:1.2.0"
77+
const val androidxTestRunner: Lib = "androidx.test:runner:1.2.0"
78+
79+
private const val spekVersion = "1.2.1"
80+
const val spekApi: Lib = "org.jetbrains.spek:spek-api:$spekVersion"
81+
const val spekEngine: Lib = "org.jetbrains.spek:spek-junit-platform-engine:$spekVersion"
82+
83+
const val junit4: Lib = "junit:junit:4.13"
84+
}
85+
86+
/* Helpers & Extensions */
87+
88+
typealias Lib = String
89+
val Lib.version get() = substringAfterLast(":")
90+
91+
typealias Agp = Lib
92+
val Agp.shortVersion: String get() {
93+
// Extract first two components of the Maven dependency's version string.
94+
val components = substringAfterLast(":").split('.')
95+
if (components.size < 2) {
96+
throw IllegalArgumentException("Cannot derive AGP configuration name from: $this")
97+
}
98+
99+
return "${components[0]}${components[1]}"
100+
}
101+
val Agp.configurationName: String get() {
102+
// Derive the Gradle configuration name from that
103+
// (Example: version = "3.2.0" --> configurationName = "testAgp32x")
104+
return "testAgp${shortVersion}x"
105+
}

0 commit comments

Comments
 (0)