diff --git a/gradle/release-tasks.gradle b/gradle/release-tasks.gradle index 67960d9a6..51fff1836 100644 --- a/gradle/release-tasks.gradle +++ b/gradle/release-tasks.gradle @@ -190,7 +190,7 @@ Release procedure: 8. ./gradlew bumpReadmeVersion 9. update README.md (latest version, release notes) 10. (in new cmd prompt session) - cd picocli-legacy-tests & set JAVA_HOME=C:\apps\jdk1.5.0_22\&& echo ++%JAVA_HOME%++ && gradlew clean build --no-daemon + cd picocli-tests-java567 & set JAVA_HOME=C:\apps\jdk1.5.0_22\&& echo ++%JAVA_HOME%++ && gradlew clean build --no-daemon 11. commit -m "Release picocli version ..." 12. tag v$version 13 ./gradlew publishReleasePublicationToSonatypeRepository - creates a Sonatype staging repository, and uploads artifacts diff --git a/picocli-tests-java567/src/test/java/picocli/HelpAnsiHeuristicsTest.java b/picocli-tests-java567/src/test/java/picocli/HelpAnsiHeuristicsTest.java index 583f804e2..19978d5a8 100644 --- a/picocli-tests-java567/src/test/java/picocli/HelpAnsiHeuristicsTest.java +++ b/picocli-tests-java567/src/test/java/picocli/HelpAnsiHeuristicsTest.java @@ -360,11 +360,11 @@ public void testAnsiAutoJansiConsoleInstalledOverridesHintDisabled() { environmentVariables.clear(ANSI_ENVIRONMENT_VARIABLES); environmentVariables.set("CLICOLOR", "0"); // hint disabled System.setProperty("os.name", "Windows"); - // Clear the globally cached jansiConsole value that might + // Clear the globally cached jansiInstalled value that might // have been set in a previous test to force the // Ansi#isJansiConsoleInstalled method to recalculate // the cached value. - Ansi.jansiConsole = null; + Ansi.jansiInstalled = null; assertTrue(Ansi.isWindows()); assertFalse(Ansi.isPseudoTTY()); assertFalse(Ansi.forceDisabled()); @@ -372,13 +372,26 @@ public void testAnsiAutoJansiConsoleInstalledOverridesHintDisabled() { assertTrue(Ansi.hintDisabled()); assertFalse(Ansi.hintEnabled()); + + // Clear the globally cached jansiInstalled value that might + // have been set in a previous test to force the + // Ansi#isJansiConsoleInstalled method to recalculate + // the cached value. + Ansi.jansiInstalled = null; assertFalse(Ansi.isJansiConsoleInstalled()); AnsiConsole.systemInstall(); try { + + // Clear the cached jansiInstalled value to force the + // Ansi#isJansiConsoleInstalled method to recalculate + Ansi.jansiInstalled = null; assertTrue(Ansi.isJansiConsoleInstalled()); assertTrue(Ansi.AUTO.enabled()); } finally { AnsiConsole.systemUninstall(); + + // Clear the cached jansiInstalled value + Ansi.jansiInstalled = null; } } @@ -396,6 +409,12 @@ public void testAnsiAutoHintDisabledOverridesHintEnabled() { assertFalse(Ansi.isJansiConsoleInstalled()); + // Clear the globally cached jansiInstalled value that might + // have been set in a previous test to force the + // Ansi#isJansiConsoleInstalled method to recalculate + // the cached value. + Ansi.jansiInstalled = null; + assertFalse(Ansi.forceDisabled()); assertFalse(Ansi.forceEnabled()); assertTrue(Ansi.hintDisabled()); @@ -413,6 +432,12 @@ public void testAnsiAutoDisabledIfNoTty() { assertFalse(Ansi.isPseudoTTY()); assertFalse(Ansi.isJansiConsoleInstalled()); + // Clear the globally cached jansiInstalled value that might + // have been set in a previous test to force the + // Ansi#isJansiConsoleInstalled method to recalculate + // the cached value. + Ansi.jansiInstalled = null; + assertFalse(Ansi.forceDisabled()); assertFalse(Ansi.forceEnabled()); assertFalse(Ansi.hintDisabled()); @@ -430,6 +455,12 @@ public void testAnsiAutoEnabledIfNotWindows() { assertFalse(Ansi.isPseudoTTY()); // TODO Mock this? assertFalse(Ansi.isJansiConsoleInstalled()); + // Clear the globally cached jansiInstalled value that might + // have been set in a previous test to force the + // Ansi#isJansiConsoleInstalled method to recalculate + // the cached value. + Ansi.jansiInstalled = null; + assertFalse(Ansi.forceDisabled()); assertFalse(Ansi.forceEnabled()); assertFalse(Ansi.hintDisabled()); @@ -445,6 +476,12 @@ public void testAnsiAutoEnabledIfWindowsPseudoTTY() { assertTrue(Ansi.isWindows()); assertFalse(Ansi.isJansiConsoleInstalled()); + // Clear the globally cached jansiInstalled value that might + // have been set in a previous test to force the + // Ansi#isJansiConsoleInstalled method to recalculate + // the cached value. + Ansi.jansiInstalled = null; + assertFalse(Ansi.forceDisabled()); assertFalse(Ansi.forceEnabled()); assertFalse(Ansi.hintDisabled()); diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index bb3ec3a4e..4b7c0fa2a 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -17805,12 +17805,12 @@ static boolean ansiPossible() { if (!isTTY() && !isPseudoTTY()) { return false; } return hintEnabled() || !isWindows() || isXterm() || isCygwin() || hasOsType(); } - /** Cache the result for isJansiConsoleInstalled so it doesn't repeatedly + /** Caches the result of method isJansiConsoleInstalled so it doesn't repeatedly * call Class#forName, which can cause performance issues. */ - static Boolean jansiConsole; + static Boolean jansiInstalled; static boolean isJansiConsoleInstalled() { - if (jansiConsole == null) { jansiConsole = calcIsJansiConsoleInstalled(); } - return jansiConsole; + if (jansiInstalled == null) { jansiInstalled = calcIsJansiConsoleInstalled(); } + return jansiInstalled; } static boolean calcIsJansiConsoleInstalled() { try { diff --git a/src/test/java/picocli/HelpAnsiTest.java b/src/test/java/picocli/HelpAnsiTest.java index 1bbc47b8b..7d0554411 100644 --- a/src/test/java/picocli/HelpAnsiTest.java +++ b/src/test/java/picocli/HelpAnsiTest.java @@ -131,7 +131,7 @@ public void testAnsiEnabled() { // The previous Ansi.enabled() call caches the result for whether or not jansi is enabled. Reset the cache value // and force the Ansi.enabled() call to rescan the classpath for the jansi classes. - Ansi.jansiConsole = null; + Ansi.jansiInstalled = null; try { assertTrue(Ansi.AUTO.enabled()); } finally { diff --git a/src/test/java/picocli/Issue1125_1538_OptionNameOrSubcommandAsOptionValue.java b/src/test/java/picocli/Issue1125_1538_OptionNameOrSubcommandAsOptionValue.java index bf23bc79d..33e36ff4d 100644 --- a/src/test/java/picocli/Issue1125_1538_OptionNameOrSubcommandAsOptionValue.java +++ b/src/test/java/picocli/Issue1125_1538_OptionNameOrSubcommandAsOptionValue.java @@ -112,11 +112,11 @@ public void testAmbiguousOptionsDefault() { //-x -y=123 MyCommand obj = new MyCommand(); CommandLine cmdLine = new CommandLine(obj); - // Clear the globally cached jansiConsole value that might + // Clear the globally cached jansiInstalled value that might // have been set in a previous test to force the // Ansi#isJansiConsoleInstalled method to recalculate // the cached value. - Ansi.jansiConsole = null; + Ansi.jansiInstalled = null; int exitCode = cmdLine.execute("-x", "-y=123"); assertEquals(2, exitCode); String expected = String.format("" +