Skip to content

Commit 0265cef

Browse files
authored
Only support Java 21 build (#1186)
1 parent 1cdc6b5 commit 0265cef

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

.gitpod/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# specifically tailored for building Jenkins plugins. It includes the installation of Maven,
33
# cloning of two specific Jenkins plugin repositories, and building these plugins using Maven.
44

5-
# Start from a base image that includes JDK 17 and Git. This serves as the foundation for the development environment.
6-
FROM gitpod/workspace-java-17
5+
# Start from a base image that includes JDK 21 and Git. This serves as the foundation for the development environment.
6+
FROM gitpod/workspace-java-21
77

88
# Define the versions of the JDKs to install. This is used by the `sdk install java` command to install the specified JDK.
99
ENV JDK8_PACKAGE=8.0.462-tem

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ buildPlugin(
55
useContainerAgent: false,
66
configurations: [
77
[platform: 'linux', jdk: 21],
8-
[platform: 'windows', jdk: 17],
8+
[platform: 'windows', jdk: 21],
99
])

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Learn more at [this project page](https://www.jenkins.io/projects/gsoc/2024/proj
5656

5757
### Requirements
5858
- Maven version 3.9.7 or later, or mvnd
59-
- Java 17 or Java 21 ([Eclipse Temurin](https://adoptium.net/temurin/releases) recommended)
59+
- Java 21 ([Eclipse Temurin](https://adoptium.net/temurin/releases) recommended)
6060

6161
### Build
6262

plugin-modernizer-cli/src/test/java/io/jenkins/tools/pluginmodernizer/cli/CommandLineITCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ private InvocationRequest buildRequest(String args, Path logFile) {
680680
properties.put("set.changelist", "true");
681681
}
682682
properties.put("exec.executable", javaHome.resolve("bin/java").toString());
683+
LOG.debug("Using java executable: {}", properties.get("exec.executable"));
683684
properties.put("test.cliArgs", args);
684685
request.setProperties(properties);
685686

plugin-modernizer-core/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@
147147
<dependency>
148148
<groupId>org.openrewrite.recipe</groupId>
149149
<artifactId>rewrite-migrate-java</artifactId>
150-
<exclusions>
151-
<exclusion>
152-
<groupId>org.openrewrite</groupId>
153-
<artifactId>rewrite-java-21</artifactId>
154-
</exclusion>
155-
</exclusions>
156150
</dependency>
157151
<dependency>
158152
<groupId>org.openrewrite.recipe</groupId>

plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/impl/PluginModernizer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void start() {
159159
LOG.debug("Plugin Health Score Url: {}", config.getPluginHealthScore());
160160
LOG.debug("Installation Stats Url: {}", config.getPluginStatsInstallations());
161161
LOG.debug("Cache Path: {}", config.getCachePath());
162+
LOG.debug("Java Version: {}", getJavaVersion());
162163
LOG.debug("Maven Home: {}", config.getMavenHome());
163164
LOG.debug("Maven Local Repository: {}", config.getMavenLocalRepo());
164165
LOG.debug("Dry Run: {}", config.isDryRun());
@@ -237,7 +238,7 @@ private void process(Plugin plugin) {
237238
plugin.checkoutBranch(ghService);
238239

239240
// Minimum JDK to run openrewrite
240-
plugin.withJDK(JDK.JAVA_17);
241+
plugin.withJDK(JDK.JAVA_21);
241242

242243
// Collect metadata and move metadata from the target directory of the plugin to the common cache
243244
if (!plugin.hasMetadata() || config.isFetchMetadataOnly()) {
@@ -348,7 +349,7 @@ private void process(Plugin plugin) {
348349

349350
// Recollect metadata after modernization
350351
if (!config.isFetchMetadataOnly()) {
351-
plugin.withJDK(JDK.JAVA_17);
352+
plugin.withJDK(JDK.JAVA_21);
352353
plugin.clean(mavenInvoker);
353354
collectMetadata(plugin, false);
354355
LOG.debug(
@@ -416,7 +417,7 @@ private void process(Plugin plugin) {
416417
*/
417418
private void collectMetadata(Plugin plugin, boolean retryAfterFirstCompile) {
418419
LOG.trace("Collecting metadata for plugin {}... Please be patient", plugin.getName());
419-
plugin.withJDK(JDK.JAVA_17);
420+
plugin.withJDK(JDK.JAVA_21);
420421
try {
421422
plugin.collectMetadata(mavenInvoker);
422423
if (plugin.hasErrors()) {
@@ -435,7 +436,7 @@ private void collectMetadata(Plugin plugin, boolean retryAfterFirstCompile) {
435436
plugin.getName());
436437
plugin.raiseLastError();
437438
}
438-
plugin.withJDK(JDK.JAVA_17);
439+
plugin.withJDK(JDK.JAVA_21);
439440
plugin.collectMetadata(mavenInvoker);
440441
} else {
441442
LOG.info("Failed to collect metadata for plugin {}. Not retrying.", plugin.getName());
@@ -539,7 +540,7 @@ private JDK verifyPlugin(Plugin plugin) {
539540
// Determine the JDK
540541
JDK jdk;
541542
if (metadata.getJdks() == null || metadata.getJdks().isEmpty()) {
542-
jdk = JDK.JAVA_17;
543+
jdk = JDK.JAVA_21;
543544
LOG.info(
544545
"No JDKs found in metadata for plugin {}. Using same JDK as rewrite for verification",
545546
plugin.getName());

plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/model/Plugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ public void collectMetadata(MavenInvoker maven) {
788788
* @param maven The maven invoker instance
789789
*/
790790
public void runOpenRewrite(MavenInvoker maven) {
791-
withJDK(JDK.JAVA_17);
791+
withJDK(JDK.JAVA_21);
792792
if (config.isFetchMetadataOnly()) {
793793
LOG.info("Skipping OpenRewrite recipe application for plugin {} as only metadata is required", name);
794794
return;

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<!-- Reproducible builds -->
3737
<project.build.outputTimestamp>2024-01-01T00:00:00Z</project.build.outputTimestamp>
3838

39+
<maven.compiler.release>21</maven.compiler.release>
3940
<maven.compiler.source>21</maven.compiler.source>
4041
<maven.compiler.target>21</maven.compiler.target>
4142
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -391,8 +392,8 @@
391392
<configuration>
392393
<rules>
393394
<requireJavaVersion>
394-
<version>17,21</version>
395-
<message>Project requires Java 17 or Java 21</message>
395+
<version>21</version>
396+
<message>Project Java 21</message>
396397
</requireJavaVersion>
397398
</rules>
398399
</configuration>

0 commit comments

Comments
 (0)