Skip to content

Commit

Permalink
Upgrade to Kotlin 1.2.30
Browse files Browse the repository at this point in the history
See https://blog.jetbrains.com/kotlin/2018/03/kotlin-1-2-30-is-out for
details. As https://youtrack.jetbrains.com/issue/KT-21303 is fixed, this
commit enables Kotlin support on Java 10.

As https://youtrack.jetbrains.com/issue/KT-18497 was also fixed, the
special configuration needed to work correctly with the "java-library"
plugin is removed from the `junit-jupiter-api.gradle` script.

Closes junit-team#1169
Supersedes junit-team#1278
  • Loading branch information
sormuras committed Mar 1, 2018
1 parent c718af4 commit 00aa2c4
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:
# Display Gradle, Groovy, JVM and other versions
- ./gradlew -version
# Build JUnit 5
- ./gradlew build $EXTRA_GRADLE_ARGS --scan --stacktrace -Dkotlin.compiler.execution.strategy="in-process"
- ./gradlew build $EXTRA_GRADLE_ARGS --scan --stacktrace -Dkotlin.compiler.execution.strategy="in-process" --warning-mode=all

# Do not store unnecessary files from Gradle dependency cache
before_cache:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ allprojects { subproj ->

apply plugin: 'java-library'
apply plugin: 'groovy' // apply for all projects so rootProject sees groovy output dir
if (gradle.ext.kotlinIsSupported) apply plugin: 'kotlin'
apply plugin: 'kotlin'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.diffplug.gradle.spotless'
Expand Down Expand Up @@ -198,7 +198,7 @@ allprojects { subproj ->
options.compilerArgs += '-parameters'
}

if (gradle.ext.kotlinIsSupported) tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.1'
Expand Down Expand Up @@ -340,7 +340,7 @@ subprojects { subproj ->
options.encoding = 'UTF-8'
// Remove Kotlin classes from classpath due to "bad" class file: AssertionsKt$sam$Supplier$44378ebd.class
// see https://bugs.openjdk.java.net/browse/JDK-8187422
if (gradle.ext.kotlinIsSupported) classpath = classpath - files(compileKotlin.destinationDir)
classpath = classpath - files(compileKotlin.destinationDir)
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
6 changes: 2 additions & 4 deletions documentation/documentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
testImplementation(project(':junit-jupiter-params'))
testImplementation(project(':junit-platform-runner'))
testImplementation(project(':junit-platform-launcher'))
if (gradle.ext.kotlinIsSupported) testImplementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")

// Include junit-platform-console so that the JUnit Gradle plugin
// uses the local version of the ConsoleLauncher.
Expand Down Expand Up @@ -121,6 +121,7 @@ asciidoctor {
'revnumber' : project.version,
'mainDir': project.sourceSets.main.java.srcDirs[0],
'testDir': project.sourceSets.test.java.srcDirs[0],
'kotlinTestDir': project.sourceSets.test.kotlin.srcDirs[0],
'consoleLauncherOptionsFile': consoleLauncherOptionsFile.toString(),
'experimentalApisTableFile': experimentalApisTableFile.toString(),
'testResourcesDir': project.sourceSets.test.resources.srcDirs[0],
Expand All @@ -132,7 +133,4 @@ asciidoctor {
'sectanchors': true,
'idprefix': '',
'idseparator': '-'
if (gradle.ext.kotlinIsSupported) {
attributes.put('kotlinTestDir', project.sourceSets.test.kotlin.srcDirs[0])
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ assertJVersion = 3.9.1
degraphVersion = 0.1.4
jmhVersion = 1.20
junit4Version = 4.12
kotlinVersion = 1.2.21
kotlinVersion = 1.2.30
log4jVersion = 2.10.0
mockitoVersion = 2.15.0
ota4jVersion = 1.0.0
Expand Down
21 changes: 1 addition & 20 deletions junit-jupiter-api/junit-jupiter-api.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies {
api("org.opentest4j:opentest4j:${ota4jVersion}")
api(project(":junit-platform-commons"))
if (gradle.ext.kotlinIsSupported) compileOnly("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
}

jar {
Expand All @@ -11,22 +11,3 @@ jar {
)
}
}

configurations {
if (gradle.ext.kotlinIsSupported) apiElements {
/*
* Needed to configure kotlin to work correctly with the "java-library" plugin.
* See:
* https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_known_issues
* https://youtrack.jetbrains.com/issue/KT-18497
*/
outgoing
.variants
.getByName("classes")
.artifact(
"file" : compileKotlin.destinationDir,
"type" : "java-classes-directory",
"builtBy" : compileKotlin
)
}
}
16 changes: 1 addition & 15 deletions junit-jupiter-engine/junit-jupiter-engine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ test {
}
*/

// Disable these tests on Java 10 as they depend on working
// Kotlin compilation.
if (!gradle.ext.kotlinIsSupported) {
sourceSets {
test {
java {
srcDir 'src'
exclude '**/AtypicalJvmMethodNameTests**'
exclude '**/TestInstanceLifecycleKotlinTests**'
}
}
}
}

jar {
manifest {
attributes(
Expand Down Expand Up @@ -61,7 +47,7 @@ dependencies {
testImplementation(project(path: ':junit-platform-engine', configuration: 'testArtifacts'))
testImplementation("org.assertj:assertj-core:${assertJVersion}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
if (gradle.ext.kotlinIsSupported) testImplementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")

// Include junit-platform-console so that the JUnit Gradle plugin
// uses the local version of the ConsoleLauncher.
Expand Down
5 changes: 0 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ if (javaVersion < 9) {
"Currently executing with Java " + javaVersion + ".")
}

// Disable Kotlin support on Java 10 or higher
// Details at https://github.com/junit-team/junit5/issues/1169
// Blocked by https://youtrack.jetbrains.com/issue/KT-21303
gradle.ext.kotlinIsSupported = javaVersion < 10

rootProject.name = 'junit5'

include 'documentation'
Expand Down

0 comments on commit 00aa2c4

Please sign in to comment.