diff --git a/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java b/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java index 8bbcc8d75d3..8aed405adc1 100644 --- a/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java +++ b/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java @@ -42,14 +42,22 @@ public class WrapperDownloader { public static void main(String[] args) { if (args.length != 1) { System.err.println("Usage: java WrapperDownloader.java "); - System.exit(1); + System.exit(2); } try { + checkVersion(); new WrapperDownloader().run(Paths.get(args[0])); } catch (Exception e) { System.err.println("ERROR: " + e.getMessage()); - System.exit(1); + System.exit(3); + } + } + + public static void checkVersion() { + int major = Runtime.getRuntime().version().feature(); + if (major != 17) { + throw new IllegalStateException("java version be exactly 17, your version: " + major); } } diff --git a/gradlew b/gradlew index 5f47106d205..03e24cab3e5 100755 --- a/gradlew +++ b/gradlew @@ -121,9 +121,13 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then fi GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar" -if ! "$JAVACMD" $JAVA_OPTS --source 11 "$APP_HOME/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "$GRADLE_WRAPPER_JAR" ; then - echo "\nSomething went wrong. Make sure you're using Java 11 or later." - exit $? +"$JAVACMD" $JAVA_OPTS --source 11 "$APP_HOME/buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "$GRADLE_WRAPPER_JAR" +WRAPPER_STATUS=$? +if [ "$WRAPPER_STATUS" -eq 1 ]; then + echo "ERROR: Something went wrong. Make sure you're using Java 17." + exit $WRAPPER_STATUS +elif [ "$WRAPPER_STATUS" -ne 0 ]; then + exit $WRAPPER_STATUS fi CLASSPATH=$GRADLE_WRAPPER_JAR diff --git a/gradlew.bat b/gradlew.bat index 9247f240ff7..7635f36589a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -94,6 +94,9 @@ IF NOT EXIST "%DIRNAME%\gradle.properties" SET GRADLE_DAEMON_CTRL=--no-daemon if "%ERRORLEVEL%"=="0" goto mainEnd :fail +@rem https://github.com/apache/lucene/pull/819 +echo Error: Something went wrong. Make sure you're using Java 17. + rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1