diff --git a/README.md b/README.md
index 9d687c1..edd9b27 100644
--- a/README.md
+++ b/README.md
@@ -35,26 +35,12 @@ An example application using this plugin is available [here](https://github.com/
Compatability
===
-The plugin is compatible with the following Gradle versions:
-
-| Gradle version | Min plugin version |
-|----------------|----------------------------------------------------------------------------------------|
-| 5.* -> 7.5.+ | 1.+ |
-| 7.6+ | 1.8.14 |
-| 8.+ | See [issue #260](https://github.com/java9-modularity/gradle-modules-plugin/issues/260) |
-
-The plugin is compatible with the following Java versions:
-
-| Java version | Min plugin version |
-|--------------|--------------------|
-| 11+ | 1.+ |
-
-The plugin is compatible with the following Kotlin versions:
-
-| Kotlin version | Min plugin version |
-|----------------|--------------------|
-| 1.0.* -> 1.6.* | 1.+ |
-| 1.7+ | 1.8.12 |
+| Plugin Version | Gradle Versions | Java Version | Kotlin Version | Notes |
+|--------------------|-----------------|--------------|----------------|--------------------------------------------------------------------------------------------|
+| - -> 1.18.12 | 5.+ -> 7.5.+ | 11+ | 1.0.+ -> 1.6.+ | |
+| 1.18.12 -> 1.18.13 | 5.+ -> 7.5.+ | 11+ | 1.0.+ -> 1.9.+ | Adds support for Kotlin 1.7 and above. |
+| 1.18.14 | 5.+ -> 7.6.+ | 11+ | 1.0.+ -> 1.9.+ | Fixes compatibility issue with Gradle 7.6 |
+| 1.18.15 -> + | 5.+ -> 8.6.+ | 11+ | 1.6.+ -> 1.9.+ | Fixes compatibility issues with Gradle 8.0.
Use JUnit v5.8.0 or above if using Gradle 8 |
Setup
===
diff --git a/build.gradle b/build.gradle
index 648e73f..3218113 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,6 +27,8 @@ configurations {
compile.extendsFrom plugin
}
+def jUnitVersion = '5.10.2'
+
dependencies {
implementation gradleApi()
implementation 'org.jooq:joor:0.9.15'
@@ -35,11 +37,11 @@ dependencies {
testImplementation gradleTestKit()
testImplementation 'com.google.guava:guava-base:r03'
testImplementation 'com.google.guava:guava-io:r03'
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
- testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
+ testImplementation "org.junit.jupiter:junit-jupiter-api:$jUnitVersion"
+ testImplementation "org.junit.jupiter:junit-jupiter-params:$jUnitVersion"
testImplementation 'org.junit-pioneer:junit-pioneer:2.2.0'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
- testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2' // required when testing in Eclipse
+ testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$jUnitVersion"
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher' // required when testing in Eclipse
}
shadowJar {
@@ -57,7 +59,7 @@ shadowJar {
jar.enabled = false
jar.dependsOn shadowJar
-processResources.duplicatesStrategy = 'exclude'
+processResources.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations {
[apiElements, runtimeElements].each {
diff --git a/src/test/java/org/javamodularity/moduleplugin/ModulePluginSmokeTest.java b/src/test/java/org/javamodularity/moduleplugin/ModulePluginSmokeTest.java
index 48efadb..42ccefe 100644
--- a/src/test/java/org/javamodularity/moduleplugin/ModulePluginSmokeTest.java
+++ b/src/test/java/org/javamodularity/moduleplugin/ModulePluginSmokeTest.java
@@ -16,6 +16,8 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -25,6 +27,7 @@
@SuppressWarnings("ConstantConditions")
class ModulePluginSmokeTest {
private static final Logger LOGGER = Logging.getLogger(ModulePluginSmokeTest.class);
+ private static final Pattern SEMANTIC_VERSION = Pattern.compile("(?\\d+)\\.(?\\d+).(?\\d+)");
private List pluginClasspath;
@@ -32,7 +35,8 @@ class ModulePluginSmokeTest {
private enum GradleVersion {
v5_1, v5_6,
v6_3, v6_4_1, v6_5_1, v6_8_3,
- v7_0, v7_6_4
+ v7_0, v7_6_4,
+ v8_0, v8_6
;
@Override
@@ -52,11 +56,16 @@ void before() throws IOException {
@CartesianTest(name = "smokeTest({arguments})")
void smokeTest(
- @CartesianTest.Values(strings = {"test-project", "test-project-kotlin-pre-1-7", "test-project-kotlin", "test-project-groovy"}) String projectName,
+ @CartesianTest.Values(strings = {
+ "test-project",
+ "test-project-kotlin-pre-1-7",
+ "test-project-kotlin",
+ "test-project-groovy"
+ }) String projectName,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTest of {} with Gradle {}", projectName, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
- assumeTrue(checkCombination(projectName, gradleVersion));
+ assumeTrue(checkKotlinCombination(projectName, gradleVersion));
var result = GradleRunner.create()
.withProjectDir(new File(projectName + "/"))
.withPluginClasspath(pluginClasspath)
@@ -77,11 +86,16 @@ void smokeTest(
@CartesianTest(name = "smokeTestRun({arguments})")
void smokeTestRun(
- @CartesianTest.Values(strings = {"test-project", "test-project-kotlin-pre-1-7", "test-project-kotlin", "test-project-groovy"}) String projectName,
+ @CartesianTest.Values(strings = {
+ "test-project",
+ "test-project-kotlin-pre-1-7",
+ "test-project-kotlin",
+ "test-project-groovy"
+ }) String projectName,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTestRun of {} with Gradle {}", projectName, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
- assumeTrue(checkCombination(projectName, gradleVersion));
+ assumeTrue(checkKotlinCombination(projectName, gradleVersion));
var writer = new StringWriter(256);
var result = GradleRunner.create()
.withProjectDir(new File(projectName + "/"))
@@ -102,12 +116,20 @@ void smokeTestRun(
@CartesianTest(name = "smokeTestJunit5({arguments})")
void smokeTestJunit5(
- @CartesianTest.Values(strings = {"5.4.2/1.4.2", "5.5.2/1.5.2", "5.7.1/1.7.1", "5.10.2/1.10.2"}) String junitVersionPair,
+ @CartesianTest.Values(strings = {
+ "5.4.2/1.4.2",
+ "5.5.2/1.5.2",
+ "5.7.1/1.7.1",
+ "5.8.0/1.8.0",
+ "5.10.2/1.10.2"
+ }) String junitVersionPair,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTestJunit5 with junitVersionPair {} and Gradle {}", junitVersionPair, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
var junitVersionParts = junitVersionPair.split("/");
- var junitVersionProperty = String.format("-PjUnitVersion=%s", junitVersionParts[0]);
+ final String junitVersion = junitVersionParts[0];
+ assumeTrue(checkJUnitCombination(junitVersion, gradleVersion));
+ var junitVersionProperty = String.format("-PjUnitVersion=%s", junitVersion);
var junitPlatformVersionProperty = String.format("-PjUnitPlatformVersion=%s", junitVersionParts[1]);
var result = GradleRunner.create()
.withProjectDir(new File("test-project/"))
@@ -176,11 +198,16 @@ private static void assertExpectedClassFileFormats(
@CartesianTest(name = "smokeTestDist({arguments})")
void smokeTestDist(
- @CartesianTest.Values(strings = {"test-project", "test-project-kotlin-pre-1-7", "test-project-kotlin", "test-project-groovy"}) String projectName,
+ @CartesianTest.Values(strings = {
+ "test-project",
+ "test-project-kotlin-pre-1-7",
+ "test-project-kotlin",
+ "test-project-groovy"
+ }) String projectName,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTestDist of {} with Gradle {}", projectName, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
- assumeTrue(checkCombination(projectName, gradleVersion));
+ assumeTrue(checkKotlinCombination(projectName, gradleVersion));
var result = GradleRunner.create()
.withProjectDir(new File(projectName + "/"))
.withPluginClasspath(pluginClasspath)
@@ -218,11 +245,16 @@ void smokeTestDist(
@CartesianTest(name = "smokeTestRunDemo({arguments})")
void smokeTestRunDemo(
- @CartesianTest.Values(strings = {"test-project", "test-project-kotlin-pre-1-7", "test-project-kotlin", "test-project-groovy"}) String projectName,
+ @CartesianTest.Values(strings = {
+ "test-project",
+ "test-project-kotlin-pre-1-7",
+ "test-project-kotlin",
+ "test-project-groovy"
+ }) String projectName,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTestRunDemo of {} with Gradle {}", projectName, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
- assumeTrue(checkCombination(projectName, gradleVersion));
+ assumeTrue(checkKotlinCombination(projectName, gradleVersion));
var result = GradleRunner.create()
.withProjectDir(new File(projectName + "/"))
.withPluginClasspath(pluginClasspath)
@@ -238,11 +270,16 @@ void smokeTestRunDemo(
@CartesianTest(name = "smokeTestRunStartScripts({arguments})")
void smokeTestRunStartScripts(
- @CartesianTest.Values(strings = {"test-project", "test-project-kotlin-pre-1-7", "test-project-kotlin", "test-project-groovy"}) String projectName,
+ @CartesianTest.Values(strings = {
+ "test-project",
+ "test-project-kotlin-pre-1-7",
+ "test-project-kotlin",
+ "test-project-groovy"
+ }) String projectName,
@CartesianTest.Enum GradleVersion gradleVersion) {
LOGGER.lifecycle("Executing smokeTestRunScripts of {} with Gradle {}", projectName, gradleVersion);
assumeTrue(jdkSupported(gradleVersion));
- assumeTrue(checkCombination(projectName, gradleVersion));
+ assumeTrue(checkKotlinCombination(projectName, gradleVersion));
var result = GradleRunner.create()
.withProjectDir(new File(projectName + "/"))
.withPluginClasspath(pluginClasspath)
@@ -263,7 +300,7 @@ void smokeTestRunStartScripts(
@Test
void shouldNotCheckInWithCommentedOutVersions() {
- assertEquals(8, GradleVersion.values().length);
+ assertEquals(10, GradleVersion.values().length);
}
private static void assertTasksSuccessful(BuildResult result, String subprojectName, String... taskNames) {
@@ -277,16 +314,31 @@ private static void assertOutputDoesNotContain(BuildResult result, String text)
assertFalse(output.contains(text), "Output should not contain '" + text + "', but was: " + output);
}
- private static boolean checkCombination(String projectName, GradleVersion gradleVersion) {
+ private static boolean checkKotlinCombination(String projectName, GradleVersion gradleVersion) {
final boolean kotlin_NotSupported = projectName.startsWith("test-project-kotlin") && gradleVersion.toString().compareTo("6.4") < 0;
- final boolean kotlin1_7_NotSupported = projectName.equals("test-project-kotlin") && gradleVersion.toString().compareTo("6.6") < 0;
- if (kotlin_NotSupported || kotlin1_7_NotSupported) {
+ final boolean kotlinPost1_7_NotSupported = projectName.equals("test-project-kotlin") && gradleVersion.toString().compareTo("6.6") < 0;
+ final boolean kotlinPre1_7_NotSupported = projectName.equals("test-project-kotlin-pre-1-7") && gradleVersion.toString().compareTo("8.0") >= 0;
+ if (kotlin_NotSupported || kotlinPost1_7_NotSupported || kotlinPre1_7_NotSupported) {
LOGGER.lifecycle("Unsupported combination: {} / Gradle {}. Test skipped", projectName, gradleVersion);
return false;
}
return true;
}
+ private boolean checkJUnitCombination(final String junitVersion, final GradleVersion gradleVersion) {
+ final boolean gradleEighthPlus = gradleVersion.ordinal() >= GradleVersion.v8_0.ordinal();
+ final Matcher m = SEMANTIC_VERSION.matcher(junitVersion);
+ assumeTrue(m.matches(), "JUnit version not semantic: " + junitVersion);
+ final boolean junitOlderThan5_8_0 = Integer.parseInt(m.group("major")) < 5 ||
+ (Integer.parseInt(m.group("major")) == 5 && Integer.parseInt(m.group("minor")) < 8);
+
+ if (gradleEighthPlus && junitOlderThan5_8_0) {
+ LOGGER.lifecycle("Unsupported JUnit and Gradle combination. Gradle: {}, JUnit: {}: Test skipped", gradleVersion, junitVersion);
+ return false;
+ }
+ return true;
+ }
+
private static int javaMajorVersion() {
final String version = System.getProperty("java.version");
return Integer.parseInt(version.substring(0, version.indexOf(".")));
@@ -301,7 +353,7 @@ private boolean jdkSupported(final GradleVersion gradleVersion) {
case v5_1:
case v5_6:
final int major = javaMajorVersion();
- if (major >= 14) {
+ if (major > 13) {
LOGGER.lifecycle("Unsupported JDK version '{}' for Gradle 5: Test skipped", major);
return false;
}
diff --git a/test-project-groovy/gradle.properties b/test-project-groovy/gradle.properties
index 5ef2ebc..ab1f457 100644
--- a/test-project-groovy/gradle.properties
+++ b/test-project-groovy/gradle.properties
@@ -1,2 +1,2 @@
-jUnitVersion = 5.6.2
-jUnitPlatformVersion = 1.6.2
+jUnitVersion = 5.10.2
+jUnitPlatformVersion = 1.10.2
diff --git a/test-project-kotlin-pre-1-7/build.gradle.kts b/test-project-kotlin-pre-1-7/build.gradle.kts
index e0b2ef2..1ed5ecc 100644
--- a/test-project-kotlin-pre-1-7/build.gradle.kts
+++ b/test-project-kotlin-pre-1-7/build.gradle.kts
@@ -5,6 +5,11 @@ plugins {
id("org.javamodularity.moduleplugin") version "1.8.14" apply false
}
+if (gradle.gradleVersion >= "8.0") {
+ throw GradleException("The Kotlin version used in this build isn't compatible with Gradle 8. " +
+ "This project should be excluded when testing with Gradle version 8 and above.")
+}
+
subprojects {
apply(plugin = "kotlin")
apply(plugin = "org.javamodularity.moduleplugin")
diff --git a/test-project-kotlin-pre-1-7/gradle.properties b/test-project-kotlin-pre-1-7/gradle.properties
index 5ef2ebc..ab1f457 100644
--- a/test-project-kotlin-pre-1-7/gradle.properties
+++ b/test-project-kotlin-pre-1-7/gradle.properties
@@ -1,2 +1,2 @@
-jUnitVersion = 5.6.2
-jUnitPlatformVersion = 1.6.2
+jUnitVersion = 5.10.2
+jUnitPlatformVersion = 1.10.2
diff --git a/test-project-kotlin/build.gradle.kts b/test-project-kotlin/build.gradle.kts
index 9c31aff..b20fef4 100644
--- a/test-project-kotlin/build.gradle.kts
+++ b/test-project-kotlin/build.gradle.kts
@@ -11,8 +11,6 @@ subprojects {
//region https://docs.gradle.org/current/userguide/kotlin_dsl.html#using_kotlin_delegated_properties
val test by tasks.existing(Test::class)
- val build by tasks
- val javadoc by tasks
val implementation by configurations
val testImplementation by configurations
@@ -23,9 +21,18 @@ subprojects {
//endregion
//region KOTLIN
- tasks.withType {
- kotlinOptions.jvmTarget = "1.8"
+ if (gradle.gradleVersion >= "8.0") {
+ configure {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+ }
+ } else {
+ tasks.withType {
+ kotlinOptions.jvmTarget = "1.8"
+ }
}
+
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
@@ -54,6 +61,4 @@ subprojects {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jUnitVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:$jUnitPlatformVersion")
}
-
-// build.dependsOn(javadoc) // TODO: No public or protected classes found to document
}
diff --git a/test-project-kotlin/gradle.properties b/test-project-kotlin/gradle.properties
index 5ef2ebc..ab1f457 100644
--- a/test-project-kotlin/gradle.properties
+++ b/test-project-kotlin/gradle.properties
@@ -1,2 +1,2 @@
-jUnitVersion = 5.6.2
-jUnitPlatformVersion = 1.6.2
+jUnitVersion = 5.10.2
+jUnitPlatformVersion = 1.10.2
diff --git a/test-project-kotlin/greeter.startscripts/build.gradle.kts b/test-project-kotlin/greeter.startscripts/build.gradle.kts
index 14187b2..8b72c44 100644
--- a/test-project-kotlin/greeter.startscripts/build.gradle.kts
+++ b/test-project-kotlin/greeter.startscripts/build.gradle.kts
@@ -35,7 +35,12 @@ File("${project.projectDir}/src/main/kotlin/startscripts")
val runDemo = tasks.create("run$demoClassName") {
group = "Demo"
description = "Run the $demoClassName program"
- main = "$moduleName/startscripts.${demoClassName}Kt"
+ if (gradle.gradleVersion >= "8.0") {
+ mainClass.set("startscripts.${demoClassName}Kt")
+ mainModule.set(moduleName)
+ } else {
+ main = "$moduleName/startscripts.${demoClassName}Kt"
+ }
jvmArgs = listOf("-Xmx128m")
}
diff --git a/test-project-mixed/gradle.properties b/test-project-mixed/gradle.properties
index 5ef2ebc..ab1f457 100644
--- a/test-project-mixed/gradle.properties
+++ b/test-project-mixed/gradle.properties
@@ -1,2 +1,2 @@
-jUnitVersion = 5.6.2
-jUnitPlatformVersion = 1.6.2
+jUnitVersion = 5.10.2
+jUnitPlatformVersion = 1.10.2
diff --git a/test-project/gradle.properties b/test-project/gradle.properties
index 5ef2ebc..ab1f457 100644
--- a/test-project/gradle.properties
+++ b/test-project/gradle.properties
@@ -1,2 +1,2 @@
-jUnitVersion = 5.6.2
-jUnitPlatformVersion = 1.6.2
+jUnitVersion = 5.10.2
+jUnitPlatformVersion = 1.10.2