Skip to content

Commit 72d38e2

Browse files
committed
Fix default Java 21 to run OpenRewrite
1 parent 86ee514 commit 72d38e2

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

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/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;

0 commit comments

Comments
 (0)