Skip to content

Commit a972c58

Browse files
committed
Merge remote-tracking branch 'asf/branch_10x' into backport_14333
2 parents 504b142 + af62580 commit a972c58

File tree

76 files changed

+1593
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1593
-393
lines changed

.github/workflows/run-checks-gradle-upgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
matrix:
3232
os: [ ubuntu-latest ]
33-
java-version: [ '23-ea' ]
33+
java-version: [ '24' ]
3434
uses-alt-java: [ true, false ]
3535

3636
runs-on: ${{ matrix.os }}

build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
import java.security.MessageDigest;
3636
import java.security.NoSuchAlgorithmException;
3737
import java.util.Locale;
38+
import java.util.Objects;
3839
import java.util.concurrent.TimeUnit;
40+
import java.util.logging.Logger;
3941

4042
/**
4143
* Standalone class that can be used to download a gradle-wrapper.jar
@@ -60,18 +62,54 @@ public static void main(String[] args) {
6062

6163
public static void checkVersion() {
6264
int major = Runtime.version().feature();
63-
if (major != 21 && major != 22 && major != 23) {
64-
throw new IllegalStateException("java version must be 21, 22 or 23, your version: " + major);
65+
if (major < 21 || major > 24) {
66+
throw new IllegalStateException(
67+
"java version must be >= 21 and <= 24, your version: " + major);
6568
}
6669
}
6770

6871
public void run(Path destination) throws IOException, NoSuchAlgorithmException {
69-
Path checksumPath =
70-
destination.resolveSibling(destination.getFileName().toString() + ".sha256");
72+
var expectedFileName = destination.getFileName().toString();
73+
Path checksumPath = destination.resolveSibling(expectedFileName + ".sha256");
7174
if (!Files.exists(checksumPath)) {
7275
throw new IOException("Checksum file not found: " + checksumPath);
7376
}
74-
String expectedChecksum = Files.readString(checksumPath, StandardCharsets.UTF_8).trim();
77+
78+
String expectedChecksum;
79+
try (var lines = Files.lines(checksumPath, StandardCharsets.UTF_8)) {
80+
expectedChecksum =
81+
lines
82+
.map(
83+
line -> {
84+
// "The default mode is to print a line with: checksum, a space,
85+
// a character indicating input mode ('*' for binary, ' ' for text
86+
// or where binary is insignificant), and name for each FILE."
87+
var spaceIndex = line.indexOf(" ");
88+
if (spaceIndex != -1 && spaceIndex + 2 < line.length()) {
89+
var mode = line.charAt(spaceIndex + 1);
90+
String fileName = line.substring(spaceIndex + 2);
91+
if (mode == '*' && fileName.equals(expectedFileName)) {
92+
return line.substring(0, spaceIndex);
93+
}
94+
}
95+
96+
Logger.getLogger(WrapperDownloader.class.getName())
97+
.warning(
98+
"Something is wrong with the checksum file. Regenerate with "
99+
+ "'sha256sum -b gradle-wrapper.jar > gradle-wrapper.jar.sha256'");
100+
return null;
101+
})
102+
.filter(Objects::nonNull)
103+
.findFirst()
104+
.orElse(null);
105+
106+
if (expectedChecksum == null) {
107+
throw new IOException(
108+
"The checksum file did not contain the expected checksum for '"
109+
+ expectedFileName
110+
+ "'?");
111+
}
112+
}
75113

76114
Path versionPath =
77115
destination.resolveSibling(destination.getFileName().toString() + ".version");

dev-tools/doap/lucene.rdf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@
6767
</maintainer>
6868

6969
<!-- NOTE: please insert releases in numeric order, NOT chronologically. -->
70+
<release>
71+
<Version>
72+
<name>lucene-10.2.1</name>
73+
<created>2025-05-01</created>
74+
<revision>10.2.1</revision>
75+
</Version>
76+
</release>
7077
<release>
7178
<Version>
7279
<name>lucene-10.2.0</name>

gradle/java/core-mrjar.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ configure(project(":lucene:core")) {
5252
mrjarJavaVersions.each { jdkVersion ->
5353
// the sourceSet which corresponds to the minimum/base Java version
5454
// will copy its output to root of JAR, all other sourceSets will go into MR-JAR folders:
55-
boolean isBaseVersion = (jdkVersion.toString() == rootProject.minJavaVersion.toString())
55+
boolean isBaseVersion = (jdkVersion.toString() as int <= rootProject.minJavaVersion.toString() as int)
5656
into(isBaseVersion ? '' : "META-INF/versions/${jdkVersion}") {
5757
from sourceSets["main${jdkVersion}"].output
5858
}

gradle/validation/check-environment.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ configure(rootProject) {
3737
throw new GradleException("At least Java ${minJavaVersion} is required, you are running Java ${currentJavaVersion} "
3838
+ "[${System.getProperty('java.vm.name')} ${System.getProperty('java.vm.version')}]")
3939
}
40+
if (Runtime.version().pre().isPresent()) {
41+
throw new GradleException("You are running Gradle with an EA version of Java, this is not supported! "
42+
+ "To test Lucene compatibility with EA or prerelease versions, use the RUNTIME_JAVA_HOME environment variable. Detected Java version: "
43+
+ "[${System.getProperty('java.vm.name')} ${System.getProperty('java.vm.version')}]")
44+
}
4045

4146
// If we're regenerating the wrapper, skip the check.
4247
if (!gradle.startParameter.taskNames.contains("wrapper")) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2db75c40782f5e8ba1fc278a5574bab070adccb2d21ca5a6e5ed840888448046
1+
7d3a4ac4de1c32b59bc6a4eb8ecb8e612ccd0cf1ae1e99f66902da64df296172 *gradle-wrapper.jar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.10.0
1+
8.14.0

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
116118

117119

118120
# Determine the Java command to use to start the JVM.
@@ -140,47 +142,6 @@ location of your Java installation."
140142
fi
141143
fi
142144

143-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
144-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
145-
146-
# LUCENE-9471: workaround for gradle leaving junk temp. files behind.
147-
GRADLE_TEMPDIR="$APP_HOME/.gradle/tmp"
148-
mkdir -p "$GRADLE_TEMPDIR"
149-
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
150-
GRADLE_TEMPDIR=`cygpath --path --mixed "$GRADLE_TEMPDIR"`
151-
fi
152-
DEFAULT_JVM_OPTS="$DEFAULT_JVM_OPTS \"-Djava.io.tmpdir=$GRADLE_TEMPDIR\""
153-
154-
# LUCENE-9266: verify and download the gradle wrapper jar if we don't have one.
155-
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
156-
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
157-
fi
158-
159-
GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
160-
if [ ! -e "$GRADLE_WRAPPER_JAR" ]; then
161-
"$JAVACMD" $JAVA_OPTS "$APP_HOME/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "$GRADLE_WRAPPER_JAR"
162-
WRAPPER_STATUS=$?
163-
if [ "$WRAPPER_STATUS" -eq 1 ]; then
164-
echo "ERROR: Something went wrong. Make sure you're using Java version of exactly 21."
165-
exit $WRAPPER_STATUS
166-
elif [ "$WRAPPER_STATUS" -ne 0 ]; then
167-
exit $WRAPPER_STATUS
168-
fi
169-
fi
170-
171-
CLASSPATH=$GRADLE_WRAPPER_JAR
172-
173-
# START OF LUCENE CUSTOMIZATION
174-
# Generate gradle.properties if they don't exist
175-
if [ ! -e "$APP_HOME/gradle.properties" ]; then
176-
"$JAVACMD" $JAVA_OPTS "$APP_HOME/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.java" "$APP_HOME/gradle/template.gradle.properties" "$APP_HOME/gradle.properties"
177-
GENERATOR_STATUS=$?
178-
if [ "$GENERATOR_STATUS" -ne 0 ]; then
179-
exit $GENERATOR_STATUS
180-
fi
181-
fi
182-
# END OF LUCENE CUSTOMIZATION
183-
184145
# Increase the maximum file descriptors if we can.
185146
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
186147
case $MAX_FD in #(
@@ -239,19 +200,59 @@ if "$cygwin" || "$msys" ; then
239200
done
240201
fi
241202

203+
# START OF LUCENE CUSTOMIZATION
204+
205+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207+
242208
# Prevent jgit from forking/searching git.exe
243209
export GIT_CONFIG_NOSYSTEM=1
244210

211+
# LUCENE-9471: workaround for gradle leaving junk temp. files behind.
212+
GRADLE_TEMPDIR="$APP_HOME/.gradle/tmp"
213+
mkdir -p "$GRADLE_TEMPDIR"
214+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
215+
GRADLE_TEMPDIR=`cygpath --path --mixed "$GRADLE_TEMPDIR"`
216+
fi
217+
DEFAULT_JVM_OPTS="$DEFAULT_JVM_OPTS \"-Djava.io.tmpdir=$GRADLE_TEMPDIR\""
218+
219+
# LUCENE-9266: verify and download the gradle wrapper jar if we don't have one.
220+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
221+
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
222+
fi
223+
224+
GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
225+
if ! ( cd $APP_HOME/gradle/wrapper && sha256sum --status -c ${GRADLE_WRAPPER_JAR}.sha256 ); then
226+
"$JAVACMD" $JAVA_OPTS "$APP_HOME/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "$GRADLE_WRAPPER_JAR"
227+
WRAPPER_STATUS=$?
228+
if [ "$WRAPPER_STATUS" -eq 1 ]; then
229+
echo "ERROR: Something went wrong. Make sure you're using Java version of exactly 21."
230+
exit $WRAPPER_STATUS
231+
elif [ "$WRAPPER_STATUS" -ne 0 ]; then
232+
exit $WRAPPER_STATUS
233+
fi
234+
fi
235+
236+
# Generate gradle.properties if they don't exist
237+
if [ ! -e "$APP_HOME/gradle.properties" ]; then
238+
"$JAVACMD" $JAVA_OPTS "$APP_HOME/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/GradlePropertiesGenerator.java" "$APP_HOME/gradle/template.gradle.properties" "$APP_HOME/gradle.properties"
239+
GENERATOR_STATUS=$?
240+
if [ "$GENERATOR_STATUS" -ne 0 ]; then
241+
exit $GENERATOR_STATUS
242+
fi
243+
fi
244+
# END OF LUCENE CUSTOMIZATION
245+
245246
# Collect all arguments for the java command:
246-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
247+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
247248
# and any embedded shellness will be escaped.
248249
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
249250
# treated as '${Hostname}' itself on the command line.
250251

251252
set -- \
252253
"-Dorg.gradle.appname=$APP_BASE_NAME" \
253254
-classpath "$CLASSPATH" \
254-
org.gradle.wrapper.GradleWrapperMain \
255+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
255256
"$@"
256257

257258
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -36,23 +38,18 @@ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
3638
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
3739
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
3840

39-
@rem LUCENE-9471: workaround for gradle leaving junk temp. files behind.
40-
SET GRADLE_TEMPDIR=%DIRNAME%\.gradle\tmp
41-
IF NOT EXIST "%GRADLE_TEMPDIR%" MKDIR "%GRADLE_TEMPDIR%"
42-
SET DEFAULT_JVM_OPTS=%DEFAULT_JVM_OPTS% "-Djava.io.tmpdir=%GRADLE_TEMPDIR%"
43-
4441
@rem Find java.exe
4542
if defined JAVA_HOME goto findJavaFromJavaHome
4643

4744
set JAVA_EXE=java.exe
4845
%JAVA_EXE% -version >NUL 2>&1
4946
if %ERRORLEVEL% equ 0 goto execute
5047

51-
echo.
52-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
53-
echo.
54-
echo Please set the JAVA_HOME variable in your environment to match the
55-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5653

5754
goto fail
5855

@@ -62,29 +59,45 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
6259

6360
if exist "%JAVA_EXE%" goto execute
6461

65-
echo.
66-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
67-
echo.
68-
echo Please set the JAVA_HOME variable in your environment to match the
69-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
7067

7168
goto fail
7269

7370
:execute
7471
@rem Setup the command line
7572

73+
set CLASSPATH=
74+
75+
@rem START OF LUCENE CUSTOMIZATION
76+
77+
@rem LUCENE-9471: workaround for gradle leaving junk temp. files behind.
78+
SET GRADLE_TEMPDIR=%DIRNAME%\.gradle\tmp
79+
IF NOT EXIST "%GRADLE_TEMPDIR%" MKDIR "%GRADLE_TEMPDIR%"
80+
SET DEFAULT_JVM_OPTS=%DEFAULT_JVM_OPTS% "-Djava.io.tmpdir=%GRADLE_TEMPDIR%"
81+
7682
@rem LUCENE-9266: verify and download the gradle wrapper jar if we don't have one.
7783
set GRADLE_WRAPPER_JAR=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
78-
IF NOT EXIST "%GRADLE_WRAPPER_JAR%" (
79-
"%JAVA_EXE%" %JAVA_OPTS% "%APP_HOME%/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "%GRADLE_WRAPPER_JAR%"
80-
IF %ERRORLEVEL% EQU 1 goto failWithJvmMessage
81-
IF %ERRORLEVEL% NEQ 0 goto fail
84+
set GRADLE_WRAPPER_CHECKSUM=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar.sha256
85+
86+
@rem Read the expected hash from .sha256 file
87+
for /f "tokens=1" %%A in ("%GRADLE_WRAPPER_CHECKSUM%") do (
88+
set "EXPECTED=%%A"
89+
)
90+
@rem Get actual SHA-256 hash using certutil
91+
for /f "tokens=* delims=" %%H in ('certutil -hashfile "%GRADLE_WRAPPER_JAR%" SHA256 ^| findstr /R /B /I /X "[0-9a-f]*"') do (
92+
set "ACTUAL=%%H"
8293
)
8394

84-
@rem Setup the command line
85-
set CLASSPATH=%GRADLE_WRAPPER_JAR%
95+
if /i "%ACTUAL%" NEQ "%EXPECTED%" (
96+
"%JAVA_EXE%" -XX:TieredStopAtLevel=1 %JAVA_OPTS% "%APP_HOME%/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java" "%GRADLE_WRAPPER_JAR%"
97+
IF %ERRORLEVEL% EQU 1 goto failWithJvmMessage
98+
IF %ERRORLEVEL% NEQ 0 goto fail
99+
)
86100

87-
@rem START OF LUCENE CUSTOMIZATION
88101
@rem Generate gradle.properties if they don't exist
89102
IF NOT EXIST "%APP_HOME%\gradle.properties" (
90103
@rem local expansion is needed to check ERRORLEVEL inside control blocks.
@@ -93,13 +106,14 @@ IF NOT EXIST "%APP_HOME%\gradle.properties" (
93106
IF %ERRORLEVEL% NEQ 0 goto fail
94107
endlocal
95108
)
96-
@rem END OF LUCENE CUSTOMIZATION
97109

98110
@rem Prevent jgit from forking/searching git.exe
99111
SET GIT_CONFIG_NOSYSTEM=1
100112

113+
@rem END OF LUCENE CUSTOMIZATION
114+
101115
@rem Execute Gradle
102-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
116+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
103117

104118
:end
105119
@rem End local scope for the variables with windows NT shell
@@ -108,7 +122,7 @@ goto fail
108122

109123
:failWithJvmMessage
110124
@rem https://github.com/apache/lucene/pull/819
111-
echo Error: Something went wrong. Make sure you're using Java version of exactly 21.
125+
echo Error: Something went wrong. Make sure you're using Java version of exactly 24.
112126

113127
:fail
114128
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

0 commit comments

Comments
 (0)