Skip to content

Apache Lucene open-source search software

Move more gradle scripts to java (#14933)

Dawid Weissed8648c359f5
diff --git a/.gitignore b/.gitignore
index 15a1ae5d624..3741e083a97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,9 +10,9 @@ gradle/wrapper/gradle-wrapper.jar
# IntelliJ IDEA
/.idea/
-# IntelliJ creates this folder, ignore.
-/dev-tools/missing-doclet/out/
+# IntelliJ creates this folder, ignore.
/build-tools/build-infra/out/
+/dev-tools/missing-doclet/out/
# Eclipse
/.project
diff --git a/build-tools/build-infra-shadow/build.gradle b/build-tools/build-infra-shadow/build.gradle
index 034a060b7cc..ccd22a87a4e 100644
--- a/build-tools/build-infra-shadow/build.gradle
+++ b/build-tools/build-infra-shadow/build.gradle
@@ -51,6 +51,7 @@ dependencies {
implementation plugin(deps.plugins.carrotsearch.buildopts)
implementation plugin(deps.plugins.carrotsearch.dependencychecks)
implementation plugin(deps.plugins.forbiddenapis)
+ implementation plugin(deps.plugins.undercouch.download)
}
tasks.matching {
@@ -70,7 +71,7 @@ tasks.matching {
}
// make certain tasks think their sources are from build-infra.
-if (!isIdea) {
+if (!buildGlobals.intellijIdea.get().isIdea) {
plugins.withType(JavaPlugin).configureEach {
SourceSet main = sourceSets.main
main.java.srcDirs = rootProject.files("build-tools/build-infra/src/main/java")
diff --git a/build-tools/build-infra/build.gradle b/build-tools/build-infra/build.gradle
index a462c17de1d..6d2a390976a 100644
--- a/build-tools/build-infra/build.gradle
+++ b/build-tools/build-infra/build.gradle
@@ -38,7 +38,17 @@ gradlePlugin {
automatedPublishing = false
plugins {
- luceneJavaProjectConventions {
+ CheckEnvironmentPlugin {
+ id = 'lucene.root-project.check-environment'
+ implementationClass = 'org.apache.lucene.gradle.plugins.misc.CheckEnvironmentPlugin'
+ }
+
+ RootProjectSetupPlugin {
+ id = 'lucene.root-project.setup'
+ implementationClass = 'org.apache.lucene.gradle.plugins.misc.RootProjectSetupPlugin'
+ }
+
+ JavaProjectConventionsPlugin {
id = 'lucene.java-projects.conventions'
implementationClass = 'org.apache.lucene.gradle.plugins.java.JavaProjectConventionsPlugin'
}
@@ -88,7 +98,7 @@ dependencies {
implementation plugin(deps.plugins.versionCatalogUpdate)
}
-def hasJavaFlightRecorder = ModuleLayer.boot().findModule('jdk.jfr').map{ otherModule ->
+def hasJavaFlightRecorder = ModuleLayer.boot().findModule('jdk.jfr').map {otherModule ->
this.getClass().module.canRead(otherModule)
}.orElse(false)
if (!hasJavaFlightRecorder) {
diff --git a/build-tools/build-infra/src/main/groovy/lucene.all-projects.conventions.gradle b/build-tools/build-infra/src/main/groovy/lucene.all-projects.conventions.gradle
deleted file mode 100644
index eb360661650..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.all-projects.conventions.gradle
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Common setup for all projects.
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-allprojects {project ->
- // All projects have the base plugin (convention tasks like 'check', etc.)
- apply plugin: 'base'
-
- // Configure build option groups.
- project.plugins.apply(org.apache.lucene.gradle.plugins.help.BuildOptionGroupsPlugin)
-
- // Project group and version.
- group = "org.apache.lucene"
- version = rootProject.version
-
- // Source repositories for dependencies.
- repositories {
- mavenCentral()
- }
-
- // Common archive artifact naming.
- var baseExt = project.getExtensions().getByType(BasePluginExtension)
- baseExt.archivesName.convention(project.path.replaceAll("^:", "").replace(':', '-'))
-
- // Common support for reproducible builds.
- tasks.withType(AbstractArchiveTask).configureEach {
- duplicatesStrategy = DuplicatesStrategy.FAIL
- preserveFileTimestamps = false
- reproducibleFileOrder = true
- dirPermissions {
- it.unix(0755)
- }
- filePermissions {
- it.unix(0644)
- }
- }
-
- // Common tasks or meta-tasks.
- tasks.register("tidy", {
- description = "Applies all code formatters and other enforced cleanups to the project."
- group = "verification"
- })
-}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.documentation.changes-to-html.gradle b/build-tools/build-infra/src/main/groovy/lucene.documentation.changes-to-html.gradle
index 60a318dcfe2..98462b5436a 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.documentation.changes-to-html.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.documentation.changes-to-html.gradle
@@ -88,7 +88,7 @@ class ChangesToHtmlTask extends DefaultTask {
def toHtml(File versionsFile) {
def output = new ByteArrayOutputStream()
def result = execOperations.exec {
- executable project.externalTool("perl")
+ executable = project.buildGlobals.externalTool("perl")
standardInput = changesFile.newInputStream()
standardOutput = project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()
errorOutput = output
diff --git a/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle b/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
index 254a3c7cbb4..dd5243a352c 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
@@ -1,5 +1,6 @@
import org.gradle.internal.jvm.Jvm
import org.apache.lucene.gradle.plugins.java.RenderJavadocTaskBase
+import org.apache.lucene.gradle.plugins.globals.LuceneBuildGlobalsExtension
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -37,6 +38,8 @@ allprojects {
relativeDocPath = project.path.replaceFirst(/:\w+:/, "").replace(':', '/')
}
+ JavaVersion minJavaVersion = buildGlobals.minJavaVersion.get()
+
def renderJavadoc = tasks.register("renderJavadoc", RenderJavadocTask, {
description = "Generates Javadoc API documentation for each module. This directly invokes javadoc tool."
group = "documentation"
@@ -45,7 +48,7 @@ allprojects {
dependsOn sourceSets.main.compileClasspath
classpath = sourceSets.main.compileClasspath
srcDirSet = sourceSets.main.java
- releaseVersion = rootProject.ext.minJavaVersion
+ releaseVersion = minJavaVersion
outputDir = project.tasks.named("javadoc").get().destinationDir
})
@@ -71,7 +74,7 @@ allprojects {
dependsOn sourceSets.main.compileClasspath
classpath = sourceSets.main.compileClasspath
srcDirSet = sourceSets.main.java
- releaseVersion = rootProject.ext.minJavaVersion
+ releaseVersion = minJavaVersion
relativeProjectLinks = true
@@ -388,9 +391,11 @@ abstract class RenderJavadocTask extends RenderJavadocTaskBase {
classpath.asPath
]
}
+
+ LuceneBuildGlobalsExtension buildGlobals = project.rootProject.extensions.getByType(LuceneBuildGlobalsExtension)
opts << [
'-bottom',
- "<i>Copyright &copy; 2000-${project.buildYear} Apache Software Foundation. All Rights Reserved.</i>"
+ "<i>Copyright &copy; 2000-${buildGlobals.buildYear} Apache Software Foundation. All Rights Reserved.</i>"
]
opts << [
@@ -529,12 +534,12 @@ abstract class RenderJavadocTask extends RenderJavadocTaskBase {
def javadocCmd = project.file(executable.get())
logger.info("Javadoc executable used: ${javadocCmd}")
- project.quietExec {
+ buildGlobals.quietExec(this, {
executable javadocCmd
args += ["@${optionsFile}"]
args += jOpts
- }
+ })
// append some special table css, prettify css
ant.concat(destfile: "${outputDir}/stylesheet.css", append: "true", fixlastline: "true", encoding: "UTF-8") {
diff --git a/build-tools/build-infra/src/main/groovy/lucene.hacks.wipe-gradle-temp.gradle b/build-tools/build-infra/src/main/groovy/lucene.hacks.wipe-gradle-temp.gradle
deleted file mode 100644
index c9db9b07e3e..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.hacks.wipe-gradle-temp.gradle
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.nio.file.Files
-import java.time.temporal.ChronoUnit
-import java.time.Instant
-import java.util.stream.Stream
-
-// See LUCENE-9471. We redirect temporary location for gradle
-// so that it doesn't pollute user's tmp. Wipe it during a clean though.
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-gradle.buildFinished {
- // we clean up the java.io.tmpdir we've redirected gradle to use (LUCENE-9471).
- // these are still used and populated with junk.
- rootProject.delete fileTree(".gradle/tmp").matching {
- include "gradle-worker-classpath*"
- }
-
- // clean up any files older than 3 hours from the user's gradle temp. the time
- // limit is added so that we don't interfere with any concurrent builds... just in case.
- Instant deadline = Instant.now().minus(3, ChronoUnit.HOURS);
- List<Stream<java.nio.file.Path>> toDelete = new ArrayList<>()
-
- def gradleTmp = gradle.gradleUserHomeDir.toPath().resolve(".tmp")
- if (Files.exists(gradleTmp)) {
- toDelete.add(Files.list(gradleTmp))
- }
- def daemonDir = gradle.gradleUserHomeDir.toPath().resolve("daemon").resolve("${gradle.gradleVersion}")
- if (Files.exists(daemonDir)) {
- toDelete.add(Files.list(daemonDir).filter {path -> path.toString().endsWith(".out.log") })
- }
-
- toDelete.each {
- it.withCloseable {stream ->
- stream.filter { p -> Files.isRegularFile(p) }
- .filter { p -> Files.getLastModifiedTime(p).toInstant().isBefore(deadline) }
- .forEach { p ->
- Files.deleteIfExists(p)
- }
- }
- }
-}
-
-// Make sure we clean up after running tests.
-allprojects {
- plugins.withType(JavaPlugin).configureEach {
- def wipeTaskTempTask = tasks.register("wipeTaskTemp", Delete, {
- delete tasks.withType(Test).collect {
- fileTree(it.temporaryDir, {
- include "jar_extract*"
- })
- }
- })
-
- tasks.withType(Test).configureEach {
- finalizedBy wipeTaskTempTask
- }
- }
-}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.help.gradle b/build-tools/build-infra/src/main/groovy/lucene.help.gradle
deleted file mode 100644
index ff35c4b5b55..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.help.gradle
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Add "help" tasks which display plain text files under 'help' folder.
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-def helpFiles = [
- [
- "Workflow",
- "help/workflow.txt",
- "Typical workflow commands."
- ],
- [
- "Tests",
- "help/tests.txt",
- "Tests, filtering, beasting, etc."
- ],
- [
- "Formatting",
- "help/formatting.txt",
- "Code formatting conventions."
- ],
- [
- "Jvms",
- "help/jvms.txt",
- "Using alternative or EA JVM toolchains."
- ],
- [
- "Deps",
- "help/dependencies.txt",
- "Declaring, inspecting and excluding dependencies."
- ],
- [
- "ForbiddenApis",
- "help/forbiddenApis.txt",
- "How to add/apply rules for forbidden APIs."
- ],
- [
- "LocalSettings",
- "help/localSettings.txt",
- "Local settings, overrides and build performance tweaks."
- ],
- [
- "Regeneration",
- "help/regeneration.txt",
- "How to refresh generated and derived resources."
- ],
- [
- "Jmh",
- "help/jmh.txt",
- "JMH micro-benchmarks."
- ],
- [
- "Git",
- "help/git.txt",
- "Git assistance and guides."
- ],
- [
- "IDEs",
- "help/IDEs.txt",
- "IDE support."
- ],
- [
- "Publishing",
- "help/publishing.txt",
- "Maven and other artifact publishing, signing, etc."
- ],
-]
-
-// Declare helpXyz task to display the given help section.
-helpFiles.each { section, path, sectionInfo ->
- tasks.register("help${section}", {
- group = 'Help (developer guides and hints)'
- description = sectionInfo
- doFirst {
- println "\n" + rootProject.file(path).getText("UTF-8")
- }
- })
-}
-
-// Add custom section to the default 'help' task.
-tasks.named("help").configure {
- doFirst {
- println ""
- println "This is Lucene ${rootProject.version} build file (gradle ${gradle.gradleVersion}). See some guidelines in files"
- println "found under the help/* folder or type any of these:"
- println ""
-
- helpFiles.each { section, path, sectionInfo ->
- println String.format(Locale.ROOT,
- " gradlew :help%-16s # %s", section, sectionInfo)
- }
-
- println ""
- println "For the impatient, build the project with 'gradlew assemble', run all tests with 'gradlew check', check " +
- "your current build options with 'gradlew allOptions'."
- throw new StopExecutionException()
- }
-}
-
-// Make sure all help files exist.
-def allHelpFilesExist = tasks.register("allHelpFilesExist", {
- doFirst {
- helpFiles.each { section, path, sectionInfo ->
- if (!rootProject.file(path).exists()) {
- throw new GradleException("Help file missing: ${path} (correct help.gradle)")
- }
- }
- }
-})
-
-tasks.named("check").configure {
- dependsOn allHelpFilesExist
-}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.ide.intellij-idea.gradle b/build-tools/build-infra/src/main/groovy/lucene.ide.intellij-idea.gradle
index 3ca81b61560..34ad5f3c164 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.ide.intellij-idea.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.ide.intellij-idea.gradle
@@ -21,7 +21,7 @@ if (project != project.rootProject) {
throw new GradleException("Applicable to rootProject only: " + project.path)
}
-if (rootProject.ext.isIdea) {
+if (buildGlobals.intellijIdea.get().isIdea) {
logger.warn("IntelliJ Idea IDE detected.")
allprojects {
@@ -37,7 +37,7 @@ if (rootProject.ext.isIdea) {
}
}
-if (rootProject.ext.isIdeaSync) {
+if (buildGlobals.intellijIdea.get().isIdeaSync) {
allprojects {
// disable all MR-JAR folders by hiding them from IDE after evaluation:
plugins.withType(JavaPlugin).configureEach {
@@ -52,7 +52,7 @@ if (rootProject.ext.isIdeaSync) {
}
}
-if (rootProject.ext.isIdeaBuild) {
+if (buildGlobals.intellijIdea.get().isIdeaBuild) {
// Skip certain long tasks that are dependencies
// of 'assemble' if we're building from within IntelliJ.
def skipTasks = [
diff --git a/build-tools/build-infra/src/main/groovy/lucene.java.core.mrjar.gradle b/build-tools/build-infra/src/main/groovy/lucene.java.core.mrjar.gradle
index 7ea96a5d05e..28be2f079e1 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.java.core.mrjar.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.java.core.mrjar.gradle
@@ -63,7 +63,7 @@ configure(project(":lucene:core")) {
tasks.named('jar').configure {
boolean needMRJAR = false
- int minJavaVersion = Integer.parseInt(JavaVersion.toVersion(deps.versions.minJava.get()).majorVersion)
+ int minJavaVersion = Integer.parseInt(buildGlobals.getMinJavaVersion().get().majorVersion)
mrjarJavaVersions.each { jdkVersion ->
// the sourceSet which corresponds to the minimum/base Java version
diff --git a/build-tools/build-infra/src/main/groovy/lucene.java.modules.gradle b/build-tools/build-infra/src/main/groovy/lucene.java.modules.gradle
index 839c9cb4c82..18c477725cd 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.java.modules.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.java.modules.gradle
@@ -80,7 +80,7 @@ allprojects {
// LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as compile-time
// dependencies, don't know why.
- if (!rootProject.ext.isIdeaSync) {
+ if (!buildGlobals.intellijIdea.get().isIdeaSync) {
task.classpath = modularPaths.compilationClasspath
}
@@ -123,7 +123,7 @@ allprojects {
// LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as compile-time
// dependencies, don't know why.
- if (!rootProject.ext.isIdeaSync) {
+ if (!buildGlobals.intellijIdea.get().isIdeaSync) {
def jarTask = project.tasks.getByName(mainSourceSet.getJarTaskName())
def testJarTask = project.tasks.getByName(testSourceSet.getJarTaskName())
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.extract-jdk-apis.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.extract-jdk-apis.gradle
index 5bb519ffb8a..33884dd4440 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.extract-jdk-apis.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.extract-jdk-apis.gradle
@@ -46,7 +46,7 @@ configure(project(":lucene:core")) {
'file.encoding': 'UTF-8',
]
args = [
- rootProject.minJavaVersion.toString(),
+ buildGlobals.getMinJavaVersion().get().toString(),
jdkVersion,
apijars.file("jdk${jdkVersion}-api.jar"),
]
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.forUtil.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.forUtil.gradle
index f4358284a4a..1e3145af492 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.forUtil.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.forUtil.gradle
@@ -15,253 +15,60 @@
* limitations under the License.
*/
-// Regenerates "ForUtil.java" code used by codecs.
+import org.apache.lucene.gradle.plugins.misc.QuietExec
-configure(project(":lucene:core")) {
+// Regenerates "ForUtil.java" code used by codecs.
- task generateForUtilInternal() {
- description = "Regenerate gen_ForUtil.py"
+void addGenerateFromPythonTask(Project project, File genDir, String taskName, String pyScript, String javaFile) {
+ var generateTaskProvider = project.getTasks().register(
+ "generate" + taskName + "Internal", QuietExec, {
+ description = "Regenerate " + javaFile + " using " + pyScript + " in " + genDir
group = "generation"
- def genDir = file("src/java/org/apache/lucene/codecs/lucene103")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
+ def genScript = project.file("${genDir}/${pyScript}")
+ def genOutput = project.file("${genDir}/${javaFile}")
inputs.file genScript
outputs.file genOutput
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
+ workingDir = genDir
+ executable = buildGlobals.externalTool("python3")
+ args = ['-B', genScript.toString()]
+ })
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtilInternal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
+ var wrapped = project.wrapWithPersistentChecksums2(generateTaskProvider, [
+ andThenTasks: [ "applyGoogleJavaFormat" ],
+ mustRunBefore: [ "compileJava" ]
])
- task generateForDeltaUtilInternal() {
- description = "Regenerate gen_ForDeltaUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/codecs/lucene103")
- def genScript = file("${genDir}/gen_ForDeltaUtil.py")
- def genOutput = file("${genDir}/ForDeltaUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
+ project.getTasks().named("regenerate").configure {
+ dependsOn wrapped
}
+}
- regenerate.dependsOn wrapWithPersistentChecksums(generateForDeltaUtilInternal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
+configure(project(":lucene:core")) {
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/codecs/lucene103"), "ForUtil", "gen_ForUtil.py", "ForUtil.java")
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/codecs/lucene103"), "ForDeltaUtil", "gen_ForDeltaUtil.py", "ForDeltaUtil.java")
}
configure(project(":lucene:backward-codecs")) {
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene84"), "ForUtil84", "gen_ForUtil.py", "ForUtil.java")
- task generateForUtil84Internal() {
- description = "Regenerate gen_ForUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene84")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtil84Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForUtil90Internal() {
- description = "Regenerate gen_ForUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene90")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtil90Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForUtil99Internal() {
- description = "Regenerate gen_ForUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene99")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtil99Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForUtil912Internal() {
- description = "Regenerate gen_ForUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene912")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtil912Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForDeltaUtil912Internal() {
- description = "Regenerate gen_ForDeltaUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene912")
- def genScript = file("${genDir}/gen_ForDeltaUtil.py")
- def genOutput = file("${genDir}/ForDeltaUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForDeltaUtil912Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForUtil101Internal() {
- description = "Regenerate gen_ForUtil.py"
- group = "generation"
-
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene101")
- def genScript = file("${genDir}/gen_ForUtil.py")
- def genOutput = file("${genDir}/ForUtil.java")
-
- inputs.file genScript
- outputs.file genOutput
-
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForUtil101Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
-
- task generateForDeltaUtil101Internal() {
- description = "Regenerate gen_ForDeltaUtil.py"
- group = "generation"
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene90"), "ForUtil90", "gen_ForUtil.py", "ForUtil.java")
- def genDir = file("src/java/org/apache/lucene/backward_codecs/lucene101")
- def genScript = file("${genDir}/gen_ForDeltaUtil.py")
- def genOutput = file("${genDir}/ForDeltaUtil.java")
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene99"), "ForUtil99", "gen_ForUtil.py", "ForUtil.java")
- inputs.file genScript
- outputs.file genOutput
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene912"), "ForUtil912", "gen_ForUtil.py", "ForUtil.java")
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene912"), "ForDeltaUtil912", "gen_ForDeltaUtil.py", "ForDeltaUtil.java")
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("python3")
- args = ['-B', genScript]
- }
- }
- }
-
- regenerate.dependsOn wrapWithPersistentChecksums(generateForDeltaUtil101Internal, [
- andThenTasks: [
- "applyGoogleJavaFormat"
- ],
- mustRunBefore: ["compileJava"]
- ])
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene101"), "ForUtil101", "gen_ForUtil.py", "ForUtil.java")
+ addGenerateFromPythonTask(project,
+ file("src/java/org/apache/lucene/backward_codecs/lucene101"), "ForDeltaUtil101", "gen_ForDeltaUtil.py", "ForDeltaUtil.java")
}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.gradle
index 3f71d330885..302bd47e6e6 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.gradle
@@ -18,7 +18,8 @@
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.apache.commons.codec.digest.DigestUtils
-
+import org.apache.lucene.gradle.plugins.misc.QuietExec
+import org.apache.lucene.gradle.plugins.regenerate.RegenerateTaskExtension
import java.util.function.Function
// Create common 'regenerate' task sub-tasks can hook into.
@@ -27,10 +28,35 @@ if (project != project.rootProject) {
throw new GradleException("Applicable to rootProject only: " + project.path)
}
+String valueToString(String sourceTaskName, String key, Object val) {
+ // Handle closures and other lazy providers.
+ if (val instanceof Provider<?>) {
+ val = val.get()
+ }
+ if (val instanceof Closure<?>) {
+ val = val.call()
+ }
+
+ if (val instanceof Boolean || val instanceof Number) {
+ val = val.toString()
+ }
+
+ if (val instanceof List) {
+ val = "[" + ((List<?>) val).collect {valueToString(sourceTaskName, key, it)}.join(", ") + "]"
+ }
+
+ if (!(val instanceof String)) {
+ throw new GradleException("Input properties of wrapped tasks must all be " +
+ "strings: ${key} in ${sourceTaskName} is not: ${val.class.getName()}")
+ }
+
+ return (String) val
+}
+
/**
* Compute all "checksummed" key-value pairs.
*/
-def computeChecksummedEntries = { Task sourceTask ->
+def computeChecksummedEntries = {Task sourceTask ->
// An flat ordered map of key-value pairs.
Map<String, String> allEntries = new TreeMap<>()
@@ -38,21 +64,19 @@ def computeChecksummedEntries = { Task sourceTask ->
// or closures returning simple strings.
//
// Don't overcomplicate things with other serializable types.
- Map<String, Object> props = sourceTask.inputs.properties
- props.forEach { key, val ->
- // Handle closures and other lazy providers.
- if (val instanceof Provider<?>) {
- val = val.get()
- }
- if (val instanceof Closure<?>) {
- val = val.call()
- }
+ Map<String, Object> props = new LinkedHashMap<>(sourceTask.inputs.properties)
- if (!(val instanceof String)) {
- throw new GradleException("Input properties of wrapped tasks must all be " +
- "strings: ${key} in ${sourceTask.name} is not.")
- }
- allEntries.put("property:" + key, (String) val)
+ // we don't want to inspect all properties of QuietExec since it
+ // contains local paths, etc. omit those. It could probably be modeled
+ // as a specific extension on the sourceTask (?).
+
+ def regenerateExt = sourceTask.getExtensions().findByType(RegenerateTaskExtension)
+ if (regenerateExt != null) {
+ props.keySet().removeAll(regenerateExt.getIgnoredInputs().get())
+ }
+
+ props.forEach {key, val ->
+ allEntries.put("property:" + key, valueToString(sourceTask.path, key, val))
}
// Collect all of task inputs/ output files and compute their checksums.
@@ -60,12 +84,18 @@ def computeChecksummedEntries = { Task sourceTask ->
// Compute checksums for root-project relative paths
def digestUtils = new DigestUtils(DigestUtils.getSha1Digest())
- allFiles.files.forEach { file ->
+ allFiles.files.forEach {file ->
allEntries.put(
sourceTask.project.rootDir.relativePath(file),
file.exists() ? digestUtils.digestAsHex(file).trim() : "--")
}
+ if (sourceTask.getLogger().isEnabled(LogLevel.INFO)) {
+ sourceTask.getLogger().info("Checksum properties:\n" + allEntries.entrySet().collect {
+ e -> " " + e.getKey() + ": " + e.getValue()
+ }.join("\n"));
+ }
+
return allEntries
}
@@ -73,8 +103,8 @@ ext {
/**
* Utility function to read a file, apply changes to its content and write it back.
*/
- modifyFile = { File path, Function<String, String> modify ->
- Function<String, String> normalizeEols = { text -> text.replace("\r\n", "\n") }
+ modifyFile = {File path, Function<String, String> modify ->
+ Function<String, String> normalizeEols = {text -> text.replace("\r\n", "\n")}
String original = path.getText("UTF-8")
String modified = normalizeEols.apply(original)
@@ -87,21 +117,51 @@ ext {
}
configure([
- project(":lucene:analysis:common"),
- project(":lucene:analysis:icu"),
- project(":lucene:analysis:kuromoji"),
- project(":lucene:analysis:nori"),
- project(":lucene:backward-codecs"),
- project(":lucene:core"),
- project(":lucene:queryparser"),
- project(":lucene:expressions"),
- project(":lucene:test-framework"),
+ project(":lucene:analysis:common"),
+ project(":lucene:analysis:icu"),
+ project(":lucene:analysis:kuromoji"),
+ project(":lucene:analysis:nori"),
+ project(":lucene:backward-codecs"),
+ project(":lucene:core"),
+ project(":lucene:queryparser"),
+ project(":lucene:expressions"),
+ project(":lucene:test-framework"),
]) {
tasks.register("regenerate", {
description = "Rerun any code or static data generation tasks."
group = "generation"
})
+ // Convert a list of strings, tasks and task providers into resolved tasks or task providers.
+ def resolveTaskRefs = {List<Object> refs ->
+ def resolved = refs.collect {
+ if (it instanceof Task) return it
+ if (it instanceof TaskProvider) return it
+ if (it instanceof String) return project.tasks.named((String) it)
+ throw new GradleException("Can't resolve task: ${it}")
+ }
+ return resolved
+ }
+
+ // Forces sequential ordering of a list of tasks (via mustRunAfter).
+ // This method should not be required in 99% of cases, consider regular dependsOn links.
+ // This method does NOT imply any ordering between dependencies of task on the input
+ // list - the execution of these may still be unordered.
+ def mustRunInOrder = {List<Object> taskList ->
+ project.afterEvaluate {
+ def resolved = resolveTaskRefs(taskList)
+
+ // Enforce sequential ordering between tasks (this does NOT apply to their dependencies!)
+ for (int i = 1; i < resolved.size(); i++) {
+ resolved[i].configure {
+ logger.info("Scheduling " + resolved[i].name + " to run after " + resolved[i - 1].name)
+ mustRunAfter resolved[i - 1]
+ }
+ }
+ }
+ return taskList
+ }
+
project.ext {
// This utility method implements the logic required for "persistent" incremental
// source-generating tasks. The idea is simple, the implementation quite complex.
@@ -135,14 +195,17 @@ configure([
// ignoreWithSource: any other tasks that should be ignored if the internal task is ignored
// (checksums are identical)
// mustRunBefore: any tasks which should be scheduled to run after the internal task.
- wrapWithPersistentChecksums = { Task sourceTask, Map<String, Object> extraConfig = [:] ->
+ wrapWithPersistentChecksums2 = {TaskProvider sourceTaskProvider, Map<String, Object> extraConfig = [:] ->
+ wrapWithPersistentChecksums(sourceTaskProvider.get(), extraConfig)
+ }
+ wrapWithPersistentChecksums = {Task sourceTask, Map<String, Object> extraConfig = [:] ->
if (!sourceTask.name.endsWith("Internal")) {
throw new GradleException("Wrapped task must follow the convention name of *Internal: ${sourceTask.name}")
}
String sourceTaskName = sourceTask.name.replaceAll('Internal$', '')
- def toList = { value ->
+ def toList = {value ->
if (value instanceof List) {
return value
} else if (value == null) {
@@ -153,12 +216,12 @@ configure([
}
List<Object> andThenTasks = toList(extraConfig.get("andThenTasks"))
- List<Object> ignoreWithSource = toList(extraConfig.get("ignoreWithSource"))
+ List<Object> ignoreWithSource = toList(extraConfig.get("ignoreWithSource"))
// Schedule must-run-afters
List<Object> mustRunBefore = toList(extraConfig.get("mustRunBefore"))
// TODO: maybe ensure all task refs here are strings?
- tasks.matching { it.name in mustRunBefore }.configureEach {
+ tasks.matching {it.name in mustRunBefore}.configureEach {
mustRunAfter sourceTask
}
@@ -198,11 +261,11 @@ configure([
expected = expected - same
throw new GradleException("Checksums mismatch for derived resources; you might have" +
- " modified a generated resource (regenerate task: ${sourceTaskName}):\n" +
- "Current:\n ${current.entrySet().join('\n ')}\n\n" +
- "Expected:\n ${expected.entrySet().join('\n ')}\n\n" +
- "Input files for this task are:\n " + sourceTask.inputs.files.join('\n ') + "\n\n" +
- "Files generated by this task are:\n " + sourceTask.outputs.files.join('\n ')
+ " modified a generated resource (regenerate task: ${sourceTaskName}):\n" +
+ "Current:\n ${current.entrySet().join('\n ')}\n\n" +
+ "Expected:\n ${expected.entrySet().join('\n ')}\n\n" +
+ "Input files for this task are:\n " + sourceTask.inputs.files.join('\n ') + "\n\n" +
+ "Files generated by this task are:\n " + sourceTask.outputs.files.join('\n ')
)
}
}
@@ -220,7 +283,7 @@ configure([
def updatedChecksums = computeChecksummedEntries(sourceTask)
checksumsFile.setText(
JsonOutput.prettyPrint(JsonOutput.toJson(new TreeMap<String,
- String>(updatedChecksums))) + '\n', "UTF-8")
+ String>(updatedChecksums))) + '\n', "UTF-8")
logger.warn("Updated generated file checksums for task ${sourceTask.path}.")
}
@@ -228,10 +291,10 @@ configure([
Task conditionalTask = tasks.create("${sourceTaskName}", {
def deps = [
- checksumLoadTask,
- sourceTask,
- *andThenTasks,
- checksumSaveTask
+ checksumLoadTask,
+ sourceTask,
+ *andThenTasks,
+ checksumSaveTask
].flatten()
dependsOn deps
@@ -246,7 +309,7 @@ configure([
// Load checksums before the source task executes, otherwise it's always ignored.
project.afterEvaluate {
- resolveTaskRefs([sourceTask, *ignoreWithSource]).each { t ->
+ resolveTaskRefs([sourceTask, *ignoreWithSource]).each {t ->
t.configure {
dependsOn checksumLoadTask
}
@@ -267,13 +330,13 @@ configure([
if (!gradle.startParameter.isRerunTasks()) {
project.afterEvaluate {
resolveTaskRefs([
- sourceTask,
- *ignoreWithSource,
- checksumSaveTask
- ]).each { t ->
+ sourceTask,
+ *ignoreWithSource,
+ checksumSaveTask
+ ]).each {t ->
t.configure {
logger.info("Making " + t.name + " run only if " + checksumLoadTask.name + " indicates changes")
- onlyIf { !checksumLoadTask.checksumMatch }
+ onlyIf {!checksumLoadTask.checksumMatch}
}
}
}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.icu.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.icu.gradle
index 65bb2cafe84..39446cd7567 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.icu.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.icu.gradle
@@ -105,7 +105,7 @@ configure(project(":lucene:analysis:icu")) {
]
}
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable gennorm
args = [
"-v",
@@ -115,16 +115,16 @@ configure(project(":lucene:analysis:icu")) {
"${buildDir}/utr30.tmp",
*(inputFiles.collect { it.name })
]
- }
+ })
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable icupkg
args = [
"-tb",
"${buildDir}/utr30.tmp",
outputFile
]
- }
+ })
}
}
@@ -208,17 +208,17 @@ configure(project(":lucene:analysis:icu")) {
project.delete icuSrcDir
// Extract the tgz
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable "tar"
workingDir icuBuildDir
args = [
"-zxf",
icuSrcTgz
]
- }
+ })
// Compile: (cd icu/source && ./configure --prefix=$(pwd) --enable-rpath && make -j4)
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable "sh"
workingDir icuSrcDir
@@ -229,23 +229,23 @@ configure(project(":lucene:analysis:icu")) {
"--prefix=${icuSrcDir}",
"--enable-rpath"
]
- }
+ })
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable "make"
workingDir icuSrcDir
args = [
"-j${buildOptions['tests.jvms'].get()}"
]
- }
+ })
// Test that the binaries work: derb -V
logger.lifecycle("Compiled ICU, checking...")
- project.quietExec {
+ buildGlobals.quietExec(it, {
executable "./derb"
workingDir icuBinDir
args = ["-V"]
- }
+ })
}
}
}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.jflex.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.jflex.gradle
index 934e08e5bea..0783c460b40 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.jflex.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.jflex.gradle
@@ -1,5 +1,3 @@
-import java.nio.file.Files
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +15,9 @@ import java.nio.file.Files
* limitations under the License.
*/
+import java.nio.file.Files
+import org.apache.lucene.gradle.plugins.misc.QuietExec
+
// Add a top-level pseudo-task to which we will attach individual regenerate tasks.
configure(rootProject) {
@@ -171,32 +172,30 @@ configure(project(":lucene:analysis:common")) {
mustRunAfter "generateTldsInternal"
}
- task generateHTMLCharacterEntitiesInternal() {
+ def generateHTMLCharacterEntitiesInternal = tasks.register("generateHTMLCharacterEntitiesInternal", QuietExec, {
def target = file('src/java/org/apache/lucene/analysis/charfilter/HTMLCharacterEntities.jflex')
def script = file("${resources}/htmlentity.py")
outputs.files target
inputs.file script
- doFirst {
- quietExec {
- executable = project.externalTool("python3")
- workingDir = target.parentFile
- args += [
- "-B",
- // don't write any bytecode cache
- script,
- target
- ]
- }
+ executable = buildGlobals.externalTool("python3")
+ workingDir = target.parentFile
+ args += [
+ "-B",
+ // don't write any bytecode cache
+ script,
+ target
+ ]
+ doLast {
project.ant.fixcrlf(
file: target,
encoding: "UTF-8",
eol: "lf"
- )
+ )
}
- }
+ })
task generateHTMLStripCharFilterInternal(type: JFlexTask) {
description = "Regenerate HTMLStripCharFilter.java"
@@ -228,7 +227,7 @@ configure(project(":lucene:analysis:common")) {
regenerate.dependsOn wrapWithPersistentChecksums(generateWikipediaTokenizerInternal, extraConfig),
wrapWithPersistentChecksums(generateClassicTokenizerInternal, extraConfig),
generateUAX29URLEmailTokenizer,
- wrapWithPersistentChecksums(generateHTMLCharacterEntitiesInternal, extraConfig),
+ wrapWithPersistentChecksums2(generateHTMLCharacterEntitiesInternal, extraConfig),
generateHTMLStripCharFilter,
wrapWithPersistentChecksums(generateTldsInternal, extraConfig)
}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.kuromoji.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.kuromoji.gradle
index 845cff53134..263014c7661 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.kuromoji.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.kuromoji.gradle
@@ -70,14 +70,14 @@ configure(project(":lucene:analysis:kuromoji")) {
}
// Apply patch via local git.
- project.quietExec {
+ buildGlobals.quietExec(it, {
workingDir = unpackedDir
executable "git"
args += [
"apply",
project.file("src/tools/patches/Noun.proper.csv.patch").absolutePath
]
- }
+ })
// Compile the dictionary
recompileDictionary(project, dictionaryName, {
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.moman.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.moman.gradle
index ede74cee631..510d8982a80 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.moman.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.moman.gradle
@@ -56,11 +56,11 @@ configure(project(":lucene:core")) {
doLast {
templateFiles.each { prog ->
logger.lifecycle("Executing: ${prog} in ${targetDir}")
- quietExec {
- workingDir targetDir
- executable project.externalTool("python3")
+ buildGlobals.quietExec(it, {
+ workingDir = targetDir
+ executable = buildGlobals.externalTool("python3")
args = ['-B', "${prog}"]
- }
+ })
}
// Correct line endings for Windows.
project.ant.fixcrlf(
@@ -84,9 +84,9 @@ configure(project(":lucene:core")) {
doLast {
['1', '2'].each { num ->
['True', 'False'].each { transpose ->
- quietExec {
- workingDir targetDir
- executable project.externalTool("python3")
+ buildGlobals.quietExec(it, {
+ workingDir = targetDir
+ executable = buildGlobals.externalTool("python3")
args = [
'-B',
templateFile.toString(),
@@ -94,7 +94,7 @@ configure(project(":lucene:core")) {
transpose,
"${momanDir}/finenight/python"
]
- }
+ })
}
}
project.ant.fixcrlf(
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.snowball.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.snowball.gradle
index c27599bb875..35481a84cc6 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.snowball.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.snowball.gradle
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import org.apache.lucene.gradle.plugins.misc.QuietExec
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
@@ -71,17 +72,17 @@ configure(project(":lucene:analysis:common")) {
}
// runs shell script to regenerate stemmers, base stemming subclasses, test data, and stopwords.
- task snowballInternal() {
+ def snowballInternal = tasks.register("generateSnowballInternal", QuietExec, {
description = "Regenerate snowball stemmers."
group = "generation"
inputs.files fileTree(
dir: "src/java/org/tartarus/snowball",
include: [
- "Among.java",
- "SnowballStemmer.java",
- "SnowballProgram.java",
- "ext/*Stemmer.java"
+ "Among.java",
+ "SnowballStemmer.java",
+ "SnowballProgram.java",
+ "ext/*Stemmer.java"
])
inputs.files fileTree(
@@ -97,22 +98,18 @@ configure(project(":lucene:analysis:common")) {
} else {
dependsOn downloadSnowballStemmers
dependsOn downloadSnowballWebsite
-
- doFirst {
- project.quietExec {
- executable "bash"
- args = [
- snowballScript,
- snowballStemmerDir,
- snowballWebsiteDir,
- projectDir
- ]
- }
- }
}
- }
- regenerate.dependsOn wrapWithPersistentChecksums(snowballInternal, [
+ executable "bash"
+ args = [
+ snowballScript,
+ snowballStemmerDir,
+ snowballWebsiteDir,
+ projectDir
+ ]
+ })
+
+ regenerate.dependsOn wrapWithPersistentChecksums2(snowballInternal, [
andThenTasks: [
"applyGoogleJavaFormat"
],
diff --git a/build-tools/build-infra/src/main/groovy/lucene.regenerate.unicode-test-classes.gradle b/build-tools/build-infra/src/main/groovy/lucene.regenerate.unicode-test-classes.gradle
index d76d6b77121..f34782bb877 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.regenerate.unicode-test-classes.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.regenerate.unicode-test-classes.gradle
@@ -15,43 +15,44 @@
* limitations under the License.
*/
+import org.apache.lucene.gradle.plugins.misc.QuietExec
+
// Regenerates test classes from unicode data.
configure(project(":lucene:test-framework")) {
- task generateEmojiTokenizationTestInternal() {
- def unicodeVersion = "12.1"
+ def generateEmojiTokenizationTestInternal =
+ tasks.register("generateEmojiTokenizationTestInternal", QuietExec, {
+ def unicodeVersion = "12.1"
- def genDir = file("src/java/org/apache/lucene/tests/analysis/standard")
- def genScript = file("${genDir}/generateEmojiTokenizationTest.pl")
- def genOutput = file("${genDir}/EmojiTokenizationTestUnicode_${unicodeVersion.replace('.', '_')}.java")
+ def genDir = file("src/java/org/apache/lucene/tests/analysis/standard")
+ def genScript = file("${genDir}/generateEmojiTokenizationTest.pl")
+ def genOutput = file("${genDir}/EmojiTokenizationTestUnicode_${unicodeVersion.replace('.', '_')}.java")
- description = "Regenerate ${genOutput}"
- group = "generation"
+ description = "Regenerate ${genOutput}"
+ group = "generation"
- inputs.file genScript
- inputs.property "unicodeVersion", unicodeVersion
- outputs.file genOutput
+ inputs.file genScript
+ inputs.property "unicodeVersion", unicodeVersion
+ outputs.file genOutput
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("perl")
+ workingDir = genDir
+ executable = buildGlobals.externalTool("perl")
args = [
- genScript,
- "-v",
- unicodeVersion
+ genScript,
+ "-v",
+ unicodeVersion
]
- }
- }
- }
- regenerate.dependsOn wrapWithPersistentChecksums(generateEmojiTokenizationTestInternal, [
+ })
+
+ regenerate.dependsOn wrapWithPersistentChecksums2(generateEmojiTokenizationTestInternal, [
andThenTasks: [
"applyGoogleJavaFormat"
],
mustRunBefore: ["compileJava"]
])
- task generateJavaUnicodeWordBreakTestInternal() {
+ def generateJavaUnicodeWordBreakTestInternal = tasks.register("generateJavaUnicodeWordBreakTestInternal",
+ QuietExec, {
def unicodeVersion = "12.1"
def genDir = file("src/java/org/apache/lucene/tests/analysis/standard")
@@ -65,20 +66,16 @@ configure(project(":lucene:test-framework")) {
inputs.property "unicodeVersion", unicodeVersion
outputs.file genOutput
- doLast {
- quietExec {
- workingDir genDir
- executable project.externalTool("perl")
- args = [
- genScript,
- "-v",
- unicodeVersion
- ]
- }
- }
- }
+ workingDir = genDir
+ executable = buildGlobals.externalTool("perl")
+ args = [
+ genScript,
+ "-v",
+ unicodeVersion
+ ]
+ })
- regenerate.dependsOn wrapWithPersistentChecksums(generateJavaUnicodeWordBreakTestInternal, [
+ regenerate.dependsOn wrapWithPersistentChecksums2(generateJavaUnicodeWordBreakTestInternal, [
andThenTasks: [
"applyGoogleJavaFormat"
],
diff --git a/build-tools/build-infra/src/main/groovy/lucene.root-project.check-environment.gradle b/build-tools/build-infra/src/main/groovy/lucene.root-project.check-environment.gradle
deleted file mode 100644
index 5e572eac878..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.root-project.check-environment.gradle
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This checks that we're running the desired version of Gradle and
-// that the JVM is supported.
-
-import org.gradle.util.GradleVersion
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-String expectedGradleVersion = deps.versions.minGradle.get()
-
-wrapper {
- distributionType = Wrapper.DistributionType.BIN
- gradleVersion = expectedGradleVersion
-}
-
-JavaVersion currentJavaVersion = JavaVersion.current()
-JavaVersion minJavaVersion = JavaVersion.toVersion(deps.versions.minJava.get())
-
-if (currentJavaVersion < minJavaVersion) {
- throw new GradleException("At least Java ${minJavaVersion} is required, you are running Java ${currentJavaVersion} "
- + "[${System.getProperty('java.vm.name')} ${System.getProperty('java.vm.version')}]")
-}
-
-if (Runtime.version().pre().isPresent()) {
- throw new GradleException("You are running Gradle with an EA version of Java - this is not supported. "
- + "To test Lucene compatibility with EA or pre-release versions, see this help guide: " +
- " './gradlew helpJvms'. Detected Java version: "
- + "[${System.getProperty('java.vm.name')} ${System.getProperty('java.vm.version')}]")
-}
-
-//
-// Skip this check if we're regenerating the wrapper.
-//
-if (!gradle.startParameter.taskNames.contains("wrapper")) {
- GradleVersion currentGradleVersion = GradleVersion.current()
- if (currentGradleVersion != GradleVersion.version(expectedGradleVersion)) {
- if (currentGradleVersion.baseVersion == GradleVersion.version(expectedGradleVersion).baseVersion) {
- logger.warn("Gradle ${expectedGradleVersion} is required but base version of this gradle matches, proceeding (" +
- "this gradle is ${currentGradleVersion}).")
- } else {
- throw new GradleException("Gradle ${expectedGradleVersion} is required (hint: use the ./gradlew script), " +
- "this gradle is ${currentGradleVersion}.")
- }
- }
-}
-
-//
-// Register this utility task on the root project.
-//
-tasks.register("checkJdkInternalsExportedToGradle", {
- doFirst {
- def jdkCompilerModule = ModuleLayer.boot().findModule("jdk.compiler").orElseThrow()
- def gradleModule = getClass().module
- def internalsExported = [
- "com.sun.tools.javac.api",
- "com.sun.tools.javac.file",
- "com.sun.tools.javac.parser",
- "com.sun.tools.javac.tree",
- "com.sun.tools.javac.util"
- ].stream()
- .allMatch({ pkg -> jdkCompilerModule.isExported(pkg, gradleModule) })
-
- if (!internalsExported) {
- throw new GradleException(
- "Certain gradle tasks and plugins require access to jdk.compiler" +
- " internals, your gradle.properties might have just been generated or could be" +
- " out of sync (see gradle/template.gradle.properties)")
- }
- }
-})
diff --git a/build-tools/build-infra/src/main/groovy/lucene.root-project.setup.gradle b/build-tools/build-infra/src/main/groovy/lucene.root-project.setup.gradle
deleted file mode 100644
index 3a15570df37..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.root-project.setup.gradle
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionValueSource
-import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsPlugin
-import org.apache.lucene.gradle.plugins.gitgrep.GitGrepPlugin
-import org.apache.lucene.gradle.plugins.gitinfo.GitInfoPlugin
-import org.apache.lucene.gradle.plugins.astgrep.AstGrepPlugin
-import org.apache.lucene.gradle.plugins.eclint.EditorConfigLintPlugin
-import org.apache.lucene.gradle.plugins.globals.RegisterBuildGlobalsPlugin
-import com.carrotsearch.randomizedtesting.SeedUtils
-
-import java.time.ZonedDateTime
-import java.time.format.DateTimeFormatter
-
-// Prepare the root project and some global infrastructure.
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-//
-// Register these plugins early.
-//
-allprojects {
- plugins.apply(BuildOptionsPlugin)
-}
-
-plugins.apply(BasePlugin)
-
-plugins.apply(RegisterBuildGlobalsPlugin)
-
-plugins.apply(GitInfoPlugin)
-plugins.apply(GitGrepPlugin)
-plugins.apply(AstGrepPlugin)
-plugins.apply(EditorConfigLintPlugin)
-
-//
-// Expose parts of the final project version to the build. We can't use Runtime.Version, sadly.
-//
-def buildGlobals = rootProject.extensions.getByName("buildGlobals")
-ext {
- // TODO: remove ext properties in favor of using the global extension directly in Java plugins code (typed refs).
-
- // Minimum Java version required to compile and run Lucene.
- minJavaVersion = JavaVersion.toVersion(deps.versions.minJava.get())
-
- // Build timestamp.
- buildDate = buildGlobals.buildDate
- buildTime = buildGlobals.buildTime
- buildYear = buildGlobals.buildYear
-}
-
-//
-// Set certain root project properties eagerly so that plugins
-// and scripts have them available.
-//
-ext {
- isIdea = Boolean.parseBoolean(System.getProperty("idea.active", "false"))
- isIdeaSync = Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"))
- isIdeaBuild = (isIdea && !isIdeaSync)
-}
-
-// Wire up included builds to some validation tasks.
-tasks.matching { it.name == "tidy" }.configureEach {
- dependsOn gradle.includedBuilds*.task(":tidy")
-}
-
-tasks.matching { it.name == "check" }.configureEach {
- dependsOn gradle.includedBuilds*.task(":check")
-}
-
-// TODO: this shouldn't be here but it's used in multiple scripts that are racy in lazy-evaluation.
-configure(project(":lucene:core")) {
- ext {
- mrjarJavaVersions = [24]
- apijars = layout.projectDirectory.dir("src/generated/jdk")
- }
-}
-
-//
-// Allow defining external tool locations, use build options so that these options are not hidden.
-//
-buildOptions.addOption("lucene.tool.python3", "External python3 executable (path or name)", "python3")
-buildOptions.addOption("lucene.tool.perl", "External perl executable (path or name)", "perl")
-buildOptions.addOption("lucene.tool.git", "External git executable (path or name)", "git")
-
-ext.externalTool = { String name ->
- if (name in [
- "python3",
- "perl",
- "git"
- ]) {
- return buildOptions.getOption("lucene.tool." + name).asStringProvider().get()
- }
- throw new GradleException("External tool named '${name}' is not defined.")
-}
-
-
-interface InjectedExec {
- @Inject ExecOperations getOps()
-}
-
-// TODO: These utility methods should be moved somewhere else or removed.
-allprojects {
- ext {
- // Utility function similar to project.exec but not emitting
- // any output unless an error code is returned from the executed command.
- quietExec = { closure ->
- // Resolve any properties against the provided closure.
- resolveStrategy = Closure.DELEGATE_ONLY
- delegate = closure.delegate
-
- File outputFile = File.createTempFile("exec-output-", ".txt", getTemporaryDir())
- ExecResult result
- boolean saveIgnoreExitValue
- ExecSpec saveExecSpec
-
- outputFile.withOutputStream { output ->
- // we want to capture both stdout and stderr to the same
- // stream but gradle attempts to close these separately
- // (it has two independent pumping threads) and it can happen
- // that one still tries to write something when the other closed
- // the underlying output stream.
- def wrapped = new java.io.FilterOutputStream(output) {
- public void close() {
- // no-op. we close this stream manually.
- }
- }
-
- def injected = project.objects.newInstance(InjectedExec)
- result = injected.ops.exec { ExecSpec execSpec ->
- project.configure(execSpec, closure)
-
- saveIgnoreExitValue = execSpec.ignoreExitValue
- saveExecSpec = execSpec
-
- standardOutput = wrapped
- errorOutput = wrapped
- ignoreExitValue = true
- }
- }
-
- if (result.getExitValue() != 0) {
- // Pipe the output to console. Intentionally skips any encoding conversion
- // and pumps raw bytes.
- logger.error(new String(outputFile.bytes))
-
- if (!saveIgnoreExitValue) {
- result.rethrowFailure()
- throw new GradleException("The executed process ${saveExecSpec.executable} " +
- "returned an odd status " +
- "code: ${result.exitValue}, " +
- "output at: ${outputFile} (and logged above).")
- }
- } else {
- logger.info(new String(outputFile.bytes))
- }
-
- return result
- }
-
- // Convert a list of strings, tasks and task providers into resolved tasks or task providers.
- resolveTaskRefs = { List<Object> refs ->
- def resolved = refs.collect {
- if (it instanceof Task) return it
- if (it instanceof TaskProvider) return it
- if (it instanceof String) return project.tasks.named((String) it)
- throw new GradleException("Can't resolve task: ${it}")
- }
- return resolved
- }
-
- // Forces sequential ordering of a list of tasks (via mustRunAfter).
- // This method should not be required in 99% of cases, consider regular dependsOn links.
- // This method does NOT imply any ordering between dependencies of task on the input
- // list - the execution of these may still be unordered.
- mustRunInOrder = { List<Object> taskList ->
- project.afterEvaluate {
- def resolved = resolveTaskRefs(taskList)
-
- // Enforce sequential ordering between tasks (this does NOT apply to their dependencies!)
- for (int i = 1; i < resolved.size(); i++) {
- resolved[i].configure {
- logger.info("Scheduling " + resolved[i].name + " to run after " + resolved[i - 1].name)
- mustRunAfter resolved[i - 1]
- }
- }
- }
- return taskList
- }
- }
-}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
index 32129e914aa..fa842d1c465 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
@@ -19,6 +19,7 @@ package org.apache.lucene.gradle.plugins;
import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension;
import java.nio.file.Path;
import java.util.Locale;
+import org.apache.lucene.gradle.plugins.globals.LuceneBuildGlobalsExtension;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@@ -38,7 +39,8 @@ public abstract class LuceneGradlePlugin implements Plugin<Project> {
* Ensure that {@code project} already has plugin {@code clazz} applied, throw an exception
* otherwise.
*/
- protected <T extends Plugin<?>> void requiresAppliedPlugin(Project project, Class<T> clazz) {
+ protected final <T extends Plugin<?>> void requiresAppliedPlugin(
+ Project project, Class<T> clazz) {
var plugin = project.getPlugins().findPlugin(clazz);
if (plugin == null) {
throw new GradleException(
@@ -57,7 +59,7 @@ public abstract class LuceneGradlePlugin implements Plugin<Project> {
}
/** Ensure the plugin is applied to the root project only, not subprojects. */
- protected void applicableToRootProjectOnly(Project project) {
+ protected final void applicableToRootProjectOnly(Project project) {
if (project != project.getRootProject()) {
throw new GradleException(
"This plugin is applicable to the rootProject only: " + getClass().getSimpleName());
@@ -68,7 +70,7 @@ public abstract class LuceneGradlePlugin implements Plugin<Project> {
* Returns a filesystem path to a given resource that the plugin uses. At the moment, these
* resources are located under the top-level {@code gradle/} folder.
*/
- protected Path gradlePluginResource(Project project, String relativePath) {
+ protected final Path gradlePluginResource(Project project, String relativePath) {
return project
.getLayout()
.getSettingsDirectory()
@@ -79,7 +81,15 @@ public abstract class LuceneGradlePlugin implements Plugin<Project> {
}
/** Utility method returning {@link BuildOptionsExtension}. */
- protected BuildOptionsExtension getBuildOptions(Project project) {
+ protected final BuildOptionsExtension getBuildOptions(Project project) {
return project.getExtensions().getByType(BuildOptionsExtension.class);
}
+
+ /**
+ * Return the {@link org.apache.lucene.gradle.plugins.globals.LuceneBuildGlobalsExtension} with
+ * global Lucene constants.
+ */
+ protected final LuceneBuildGlobalsExtension getLuceneBuildGlobals(Project project) {
+ return project.getExtensions().getByType(LuceneBuildGlobalsExtension.class);
+ }
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java
index 3e6a8c1021d..b30092e11ee 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java
@@ -19,6 +19,7 @@ package org.apache.lucene.gradle.plugins.astgrep;
import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension;
import java.util.ArrayList;
import java.util.List;
+import org.apache.lucene.gradle.plugins.misc.QuietExec;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@@ -43,7 +44,7 @@ public class AstGrepPlugin implements Plugin<Project> {
var testAstGrepRules =
tasks.register(
"testAstGrepRules",
- Exec.class,
+ QuietExec.class,
(task) -> {
task.setArgs(
List.of(
@@ -89,7 +90,6 @@ public class AstGrepPlugin implements Plugin<Project> {
task.setEnabled(false);
}
- task.setIgnoreExitValue(false);
if (astToolOption.isPresent()) {
task.setExecutable(astToolOption.get());
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitgrep/GitGrepPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitgrep/GitGrepPlugin.java
index 439320c215f..ee35313ff28 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitgrep/GitGrepPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitgrep/GitGrepPlugin.java
@@ -83,6 +83,7 @@ public class GitGrepPlugin extends LuceneGradlePlugin {
task.doFirst(
_ -> {
try {
+ Files.createDirectories(inputFile.getParent());
Files.write(inputFile, invalidPatterns);
} catch (IOException e) {
throw new UncheckedIOException(e);
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoValueSource.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoValueSource.java
index fddd4f00457..cd1045765b6 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoValueSource.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoValueSource.java
@@ -32,7 +32,6 @@ import org.gradle.api.provider.ValueSource;
import org.gradle.api.provider.ValueSourceParameters;
import org.gradle.api.services.BuildServiceParameters;
import org.gradle.process.ExecOperations;
-import org.jetbrains.annotations.Nullable;
public abstract class GitInfoValueSource
implements ValueSource<Map<String, String>, GitInfoValueSource.Parameters> {
@@ -44,7 +43,7 @@ public abstract class GitInfoValueSource
public abstract ExecOperations getExecOps();
@Override
- public @Nullable Map<String, String> obtain() {
+ public Map<String, String> obtain() {
try (var baos = new ByteArrayOutputStream();
var out = new BufferedOutputStream(baos)) {
var result =
diff --git a/build-tools/build-infra/src/main/groovy/lucene.hacks.downloader-retries.gradle b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/IntellijIdea.java
similarity index 64%
rename from build-tools/build-infra/src/main/groovy/lucene.hacks.downloader-retries.gradle
rename to build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/IntellijIdea.java
index 5dd4ab9cdc3..64875e26140 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.hacks.downloader-retries.gradle
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/IntellijIdea.java
@@ -14,17 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.lucene.gradle.plugins.globals;
-import de.undercouch.gradle.tasks.download.DownloadTaskPlugin
-import de.undercouch.gradle.tasks.download.Download
-
-// Configures the Download task to retry on temporary network glitches.
-
-allprojects {project ->
- // Limit configuration to just those projects that actually have the plugin enabled.
- plugins.withType(DownloadTaskPlugin).configureEach {
- project.tasks.withType(Download).configureEach {
- it.retries 3
- }
- }
-}
+/**
+ * @param isIdea {@code true} if intellij idea is detected.
+ * @param isIdeaSync {@code true} if intellij idea sync is detected.
+ * @param isIdeaBuild {@code true} if intellij idea build is detected.
+ */
+public record IntellijIdea(boolean isIdea, boolean isIdeaSync, boolean isIdeaBuild) {}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/LuceneBuildGlobalsExtension.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/LuceneBuildGlobalsExtension.java
index 103eec9ba51..7d227b315ce 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/LuceneBuildGlobalsExtension.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/LuceneBuildGlobalsExtension.java
@@ -16,7 +16,25 @@
*/
package org.apache.lucene.gradle.plugins.globals;
+import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension;
+import java.io.File;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.inject.Inject;
+import org.apache.lucene.gradle.plugins.misc.QuietExec;
+import org.gradle.api.Action;
+import org.gradle.api.GradleException;
+import org.gradle.api.JavaVersion;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
import org.gradle.api.provider.Property;
+import org.gradle.process.ExecOperations;
+import org.gradle.process.ExecResult;
+import org.gradle.process.ExecSpec;
/** Global build constants. */
public abstract class LuceneBuildGlobalsExtension {
@@ -61,4 +79,69 @@ public abstract class LuceneBuildGlobalsExtension {
/** Return the root randomization seed as a {@code long} value. */
public abstract Property<Long> getRootSeedAsLong();
+
+ /** Minimum Java version required for this version of Lucene. */
+ public abstract Property<JavaVersion> getMinJavaVersion();
+
+ /** If set, returns certain flags helpful for configuring the build for the intellij idea IDE. */
+ public abstract Property<IntellijIdea> getIntellijIdea();
+
+ /**
+ * Returns the path to the provided named external tool. Developers may set up different tool
+ * paths using local build options.
+ */
+ public String externalTool(String name) {
+ var buildOptions =
+ getProject().getRootProject().getExtensions().getByType(BuildOptionsExtension.class);
+ var optionKey = "lucene.tool." + name;
+ if (!buildOptions.hasOption(optionKey)) {
+ throw new GradleException(
+ "External tool of this name has no corresponding build option: " + optionKey);
+ }
+ return buildOptions.getOption(optionKey).asStringProvider().get();
+ }
+
+ /**
+ * An immediate equivalent of the {@link org.apache.lucene.gradle.plugins.misc.QuietExec} task.
+ * This should be avoided but is sometimes handy.
+ */
+ public void quietExec(Task owner, Action<ExecSpec> configureAction) {
+ try {
+ File outputFile = File.createTempFile("exec-output-", ".txt", owner.getTemporaryDir());
+ AtomicReference<String> executable = new AtomicReference<>();
+ ExecResult result;
+ try (OutputStream os =
+ new FilterOutputStream(Files.newOutputStream(outputFile.toPath())) {
+ @Override
+ public void close() {
+ // no-op. we close this stream manually.
+ }
+ }) {
+ result =
+ getExecOps()
+ .exec(
+ spec -> {
+ configureAction.execute(spec);
+
+ spec.setStandardInput(InputStream.nullInputStream());
+ spec.setStandardOutput(os);
+ spec.setErrorOutput(os);
+ spec.setIgnoreExitValue(true);
+
+ executable.set(spec.getExecutable());
+ });
+ }
+ QuietExec.processResult(result, outputFile, executable.get(), owner.getLogger());
+ } catch (IOException e) {
+ throw new GradleException("quietExec failed: " + e.getMessage(), e);
+ }
+ }
+
+ /** For internal use. */
+ @Inject
+ protected abstract ExecOperations getExecOps();
+
+ /** For internal use. */
+ @Inject
+ protected abstract Project getProject();
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/RegisterBuildGlobalsPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/RegisterBuildGlobalsPlugin.java
index a0db8e00cbe..b89745638cd 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/RegisterBuildGlobalsPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/globals/RegisterBuildGlobalsPlugin.java
@@ -27,6 +27,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
import org.gradle.api.GradleException;
+import org.gradle.api.JavaVersion;
import org.gradle.api.Project;
import org.gradle.api.provider.Provider;
@@ -55,6 +56,13 @@ public class RegisterBuildGlobalsPlugin extends LuceneGradlePlugin {
System.getenv().keySet().stream()
.anyMatch(key -> key.matches("(?i)((JENKINS|HUDSON)(_\\w+)?|CI)"));
+ // Set up build options for external tools.
+ var buildOptions = getBuildOptions(project);
+ buildOptions.addOption(
+ "lucene.tool.python3", "External python3 executable (path or name)", "python3");
+ buildOptions.addOption("lucene.tool.perl", "External perl executable (path or name)", "perl");
+ buildOptions.addOption("lucene.tool.git", "External git executable (path or name)", "git");
+
// Pick the "root" seed from which everything else that is randomized is derived.
Provider<String> rootSeedOption =
getBuildOptions(project)
@@ -68,6 +76,14 @@ public class RegisterBuildGlobalsPlugin extends LuceneGradlePlugin {
// We take just the root seed, ignoring any chained sub-seeds.
long rootSeedLong = SeedUtils.parseSeedChain(rootSeed)[0];
+ // Parse the minimum Java version required to run Lucene.
+ JavaVersion minJavaVersion =
+ JavaVersion.toVersion(getVersionCatalog(project).findVersion("minJava").get().toString());
+
+ boolean isIdea = Boolean.parseBoolean(System.getProperty("idea.active", "false"));
+ boolean isIdeaSync = Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"));
+ boolean isIdeaBuild = (isIdea && !isIdeaSync);
+
project.allprojects(
p -> {
var globals =
@@ -86,6 +102,11 @@ public class RegisterBuildGlobalsPlugin extends LuceneGradlePlugin {
.getProjectSeedAsLong()
.convention(rootSeedLong ^ p.getPath().hashCode())
.finalizeValue();
+ globals.getMinJavaVersion().convention(minJavaVersion).finalizeValue();
+ globals
+ .getIntellijIdea()
+ .convention(new IntellijIdea(isIdea, isIdeaSync, isIdeaBuild))
+ .finalizeValue();
});
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/HacksPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/HacksPlugin.java
new file mode 100644
index 00000000000..415f465e69d
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/HacksPlugin.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.hacks;
+
+import de.undercouch.gradle.tasks.download.Download;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.gradle.api.Project;
+
+/** This applies various odd hacks that we probably should not need. */
+public class HacksPlugin extends LuceneGradlePlugin {
+
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ rootProject
+ .getAllprojects()
+ .forEach(
+ project -> {
+ applyRetryDownloads(project);
+ });
+ }
+
+ private void applyRetryDownloads(Project project) {
+ project
+ .getTasks()
+ .withType(Download.class)
+ .configureEach(
+ task -> {
+ task.retries(3);
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/WipeGradleTempPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/WipeGradleTempPlugin.java
new file mode 100644
index 00000000000..7ae7966570f
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/hacks/WipeGradleTempPlugin.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.hacks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+import javax.inject.Inject;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.gradle.api.Project;
+import org.gradle.api.file.FileTree;
+import org.gradle.api.internal.file.FileOperations;
+import org.gradle.api.invocation.Gradle;
+import org.gradle.api.plugins.JavaPlugin;
+import org.gradle.api.tasks.Delete;
+import org.gradle.api.tasks.TaskCollection;
+import org.gradle.api.tasks.TaskContainer;
+import org.gradle.api.tasks.testing.Test;
+
+/**
+ * Try to clean up gradle's temp files and other junk it creates.
+ *
+ * @see "LUCENE-9471"
+ */
+public abstract class WipeGradleTempPlugin extends LuceneGradlePlugin {
+ @Inject
+ public abstract FileOperations getFileOps();
+
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ cleanTempFilesAfterBuildFinished(rootProject);
+
+ rootProject
+ .getAllprojects()
+ .forEach(
+ project -> {
+ project
+ .getPlugins()
+ .withType(JavaPlugin.class)
+ .configureEach(
+ unused -> {
+ wipeAfterTests(project);
+ });
+ });
+ }
+
+ private void wipeAfterTests(Project project) {
+ TaskContainer tasks = project.getTasks();
+ TaskCollection<Test> testTasks = tasks.withType(Test.class);
+ var wipeTaskTempTask =
+ tasks.register(
+ "wipeTaskTemp",
+ Delete.class,
+ task -> {
+ task.delete(
+ testTasks.stream()
+ .map(
+ test -> {
+ return project.fileTree(
+ test.getTemporaryDir(),
+ fileTree -> {
+ fileTree.include("jar_extract*");
+ });
+ })
+ .toList());
+ });
+
+ testTasks.configureEach(
+ task -> {
+ task.finalizedBy(wipeTaskTempTask);
+ });
+ }
+
+ private void cleanTempFilesAfterBuildFinished(Project rootProject) {
+ rootProject
+ .getGradle()
+ .buildFinished(
+ unused -> {
+ cleanUpRedirectedTmpDir(rootProject);
+ cleanUpGradlesTempDir(rootProject);
+ });
+ }
+
+ private static void cleanUpGradlesTempDir(Project rootProject) {
+ try {
+ // clean up any files older than 3 hours from the user's gradle temp. the time
+ // limit is added so that we don't interfere with any concurrent builds... just in
+ // case.
+ Instant deadline = Instant.now().minus(3, ChronoUnit.HOURS);
+ List<Stream<Path>> toDelete = new ArrayList<>();
+
+ Gradle gradle = rootProject.getGradle();
+ Path gradleUserHome = gradle.getGradleUserHomeDir().toPath();
+
+ var gradleTmp = gradleUserHome.resolve(".tmp");
+ if (Files.exists(gradleTmp)) {
+ toDelete.add(Files.list(gradleTmp));
+ }
+
+ var daemonDir = gradleUserHome.resolve("daemon").resolve(gradle.getGradleVersion());
+ if (Files.exists(daemonDir)) {
+ toDelete.add(Files.list(daemonDir).filter(path -> path.toString().endsWith(".out.log")));
+ }
+
+ for (Stream<Path> stream : toDelete) {
+ try {
+ for (var path : stream.toList()) {
+ if (!Files.isRegularFile(path)) {
+ continue;
+ }
+ if (!Files.getLastModifiedTime(path).toInstant().isBefore(deadline)) {
+ continue;
+ }
+ Files.deleteIfExists(path);
+ }
+ } finally {
+ stream.close();
+ }
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ private void cleanUpRedirectedTmpDir(Project rootProject) {
+ // Clean up the java.io.tmpdir we've redirected gradle to use (LUCENE-9471).
+ // these are still used and populated with junk.
+ FileTree tempFiles =
+ rootProject
+ .fileTree(".gradle/tmp")
+ .matching(
+ patternFilterable -> {
+ patternFilterable.include("gradle-worker-classpath*");
+ });
+ getFileOps()
+ .delete(
+ spec -> {
+ spec.delete(tempFiles);
+ spec.setFollowSymlinks(false);
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ApplyForbiddenApisPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ApplyForbiddenApisPlugin.java
index ab0450c1213..13e07f13117 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ApplyForbiddenApisPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ApplyForbiddenApisPlugin.java
@@ -39,7 +39,6 @@ import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.TaskContainer;
-import org.jetbrains.annotations.NotNull;
/**
* This configures the application of forbidden-API signature files.
@@ -287,7 +286,7 @@ public class ApplyForbiddenApisPlugin extends LuceneGradlePlugin {
return signatureLocations;
}
- private static @NotNull HashSet<ResolvedDependencyResult> getAllDependencies(
+ private static HashSet<ResolvedDependencyResult> getAllDependencies(
ResolvedComponentResult graphRoot) {
HashSet<ResolvedDependencyResult> allResolved = new HashSet<>();
ArrayDeque<DependencyResult> queue = new ArrayDeque<>(graphRoot.getDependencies());
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JarManifestConfigurationPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JarManifestConfigurationPlugin.java
index 654e00d2448..90f6e1c3779 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JarManifestConfigurationPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JarManifestConfigurationPlugin.java
@@ -26,7 +26,6 @@ import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.bundling.Jar;
-import org.jetbrains.annotations.NotNull;
/** Sets up the Jar task in gradle: manifest attributes, extra META-INF files, etc. */
public class JarManifestConfigurationPlugin extends LuceneGradlePlugin {
@@ -110,7 +109,7 @@ public class JarManifestConfigurationPlugin extends LuceneGradlePlugin {
});
}
- private static @NotNull String getImplementationVersion(
+ private static String getImplementationVersion(
Project project, String gitRev, LuceneBuildGlobalsExtension globals) {
if (globals.snapshotBuild) {
return project.getVersion() + " " + gitRev + " [snapshot build, details omitted]";
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavacConfigurationPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavacConfigurationPlugin.java
index aecbd0081a8..ac140f3457a 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavacConfigurationPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavacConfigurationPlugin.java
@@ -21,7 +21,6 @@ import java.util.List;
import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
import org.gradle.api.JavaVersion;
import org.gradle.api.Project;
-import org.gradle.api.artifacts.VersionCatalog;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
@@ -34,8 +33,7 @@ public class JavacConfigurationPlugin extends LuceneGradlePlugin {
public void apply(Project project) {
requiresAppliedPlugin(project, JavaPlugin.class);
- VersionCatalog versionCatalog = getVersionCatalog(project);
- JavaVersion minJavaVersion = JavaVersion.toVersion(versionCatalog.findVersion("minJava").get());
+ JavaVersion minJavaVersion = getLuceneBuildGlobals(project).getMinJavaVersion().get();
BuildOptionsExtension buildOptions =
project.getExtensions().getByType(BuildOptionsExtension.class);
@@ -56,68 +54,74 @@ public class JavacConfigurationPlugin extends LuceneGradlePlugin {
CompileOptions options = task.getOptions();
// Use 'release' flag instead of 'source' and 'target'
- options.getCompilerArgs().addAll(List.of("--release", minJavaVersion.toString()));
+ List<String> compilerArgs = options.getCompilerArgs();
+
+ compilerArgs.addAll(List.of("--release", minJavaVersion.toString()));
options.setEncoding("UTF-8");
// Configure warnings. Use 'javac --help-lint' to get the supported list
- options
- .getCompilerArgs()
- .addAll(
- List.of(
- "-Xlint:auxiliaryclass",
- "-Xlint:cast",
- "-Xlint:classfile",
- "-Xlint:dangling-doc-comments",
- "-Xlint:-deprecation",
- "-Xlint:dep-ann",
- "-Xlint:divzero",
- "-Xlint:empty",
- // TODO: uh-oh we have broken APIs.
- "-Xlint:-exports",
- "-Xlint:fallthrough",
- "-Xlint:finally",
- "-Xlint:incubating",
- // TODO: there are problems
- "-Xlint:-lossy-conversions",
- // TODO: there are problems
- "-Xlint:-missing-explicit-ctor",
- "-Xlint:module",
- "-Xlint:opens",
- "-Xlint:options",
- "-Xlint:output-file-clash",
- "-Xlint:overloads",
- "-Xlint:overrides",
- "-Xlint:path",
- "-Xlint:processing",
- "-Xlint:rawtypes",
- "-Xlint:removal",
- "-Xlint:requires-automatic",
- "-Xlint:requires-transitive-automatic",
- "-Xlint:-serial",
- "-Xlint:static",
- "-Xlint:strictfp",
- "-Xlint:synchronization",
- "-Xlint:text-blocks",
- // TODO: there are problems
- "-Xlint:-this-escape",
- "-Xlint:try",
- "-Xlint:unchecked",
- "-Xlint:varargs",
- "-Xlint:preview",
- "-Xlint:restricted",
- "-Xdoclint:all/protected",
- "-Xdoclint:-missing",
- "-Xdoclint:-accessibility"));
+ compilerArgs.addAll(
+ List.of(
+ "-Xlint:auxiliaryclass",
+ "-Xlint:cast",
+ "-Xlint:classfile",
+ "-Xlint:dangling-doc-comments",
+ "-Xlint:-deprecation",
+ "-Xlint:dep-ann",
+ "-Xlint:divzero",
+ "-Xlint:empty",
+ // TODO: uh-oh we have broken APIs.
+ "-Xlint:-exports",
+ "-Xlint:fallthrough",
+ "-Xlint:finally",
+ "-Xlint:incubating",
+ // TODO: there are problems
+ "-Xlint:-lossy-conversions",
+ // TODO: there are problems
+ "-Xlint:-missing-explicit-ctor",
+ "-Xlint:module",
+ "-Xlint:opens",
+ "-Xlint:options",
+ "-Xlint:output-file-clash",
+ "-Xlint:overloads",
+ "-Xlint:overrides",
+ "-Xlint:path",
+ "-Xlint:processing",
+ "-Xlint:rawtypes",
+ "-Xlint:removal",
+ "-Xlint:requires-automatic",
+ "-Xlint:requires-transitive-automatic",
+ "-Xlint:-serial",
+ "-Xlint:static",
+ "-Xlint:strictfp",
+ "-Xlint:synchronization",
+ "-Xlint:text-blocks",
+ // TODO: there are problems
+ "-Xlint:-this-escape",
+ "-Xlint:try",
+ "-Xlint:unchecked",
+ "-Xlint:varargs",
+ "-Xlint:preview",
+ "-Xlint:restricted",
+ "-Xdoclint:all/protected",
+ "-Xdoclint:-missing",
+ "-Xdoclint:-accessibility"));
+
+ // we can't use this linter option
+ // because of https://github.com/apache/lucene/issues/14941
+ if (project.getPath().equals(":lucene:build-tools:build-infra-shadow")) {
+ compilerArgs.remove("-Xlint:path");
+ }
if (project.getPath().equals(":lucene:benchmark-jmh")) {
// Ignore, JMH benchmarks use JMH preprocessor and incubating modules.
} else {
// proc:none was added because of LOG4J2-1925 / JDK-8186647
- options.getCompilerArgs().add("-proc:none");
+ compilerArgs.add("-proc:none");
if (failOnWarningsOption.get()) {
- options.getCompilerArgs().add("-Werror");
+ compilerArgs.add("-Werror");
}
}
});
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsSummaryPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsSummaryPlugin.java
index f4906b7f1c4..be36501db90 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsSummaryPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsSummaryPlugin.java
@@ -43,7 +43,7 @@ public class TestsSummaryPlugin extends LuceneGradlePlugin {
new TestListener() {
@Override
public void afterSuite(TestDescriptor suite, TestResult result) {
- if (suite.getParent() != null) {
+ if (suite.getParent() == null) {
if (result.getTestCount() > 0) {
StringBuilder sb = new StringBuilder();
sb.append(task.getPath())
@@ -57,8 +57,7 @@ public class TestsSummaryPlugin extends LuceneGradlePlugin {
.append(pluralize(result.getFailedTestCount(), " failure"));
}
if (result.getSkippedTestCount() > 0) {
- sb.append(", ")
- .append(pluralize(result.getSkippedTestCount(), " skipped"));
+ sb.append(", ").append(result.getSkippedTestCount()).append(" skipped");
}
task.getLogger().lifecycle(sb.toString());
@@ -67,7 +66,7 @@ public class TestsSummaryPlugin extends LuceneGradlePlugin {
}
private static String pluralize(long count, String verb) {
- return verb + (count == 1 ? "" : "s");
+ return count + " " + verb + (count == 1 ? "" : "s");
}
@Override
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CheckEnvironmentPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CheckEnvironmentPlugin.java
new file mode 100644
index 00000000000..9933d44c997
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CheckEnvironmentPlugin.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.misc;
+
+import java.util.Locale;
+import java.util.Set;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.gradle.api.GradleException;
+import org.gradle.api.JavaVersion;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.VersionCatalog;
+import org.gradle.api.tasks.wrapper.Wrapper;
+import org.gradle.util.GradleVersion;
+
+/**
+ * This checks build environment sanity: that we're running the desired version of Gradle, that the
+ * JVM is supported, etc.
+ */
+public class CheckEnvironmentPlugin extends LuceneGradlePlugin {
+ public static final String CHECK_JDK_INTERNALS_EXPOSED_TO_GRADLE_TASK =
+ "checkJdkInternalsExportedToGradle";
+
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ VersionCatalog versionCatalog = getVersionCatalog(rootProject);
+ String expectedGradleVersion = versionCatalog.findVersion("minGradle").get().toString();
+
+ rootProject
+ .getTasks()
+ .withType(Wrapper.class)
+ .named("wrapper")
+ .configure(
+ task -> {
+ task.setDistributionType(Wrapper.DistributionType.BIN);
+ task.setGradleVersion(expectedGradleVersion);
+ });
+
+ JavaVersion currentJavaVersion = JavaVersion.current();
+ JavaVersion minJavaVersion = JavaVersion.toVersion(versionCatalog.findVersion("minJava").get());
+
+ if (currentJavaVersion.compareTo(minJavaVersion) < 0) {
+ throw new GradleException(
+ String.format(
+ Locale.ROOT,
+ "At least Java %s is required, you are running Java %s " + "[%s %s]",
+ minJavaVersion,
+ currentJavaVersion,
+ System.getProperty("java.vm.name"),
+ System.getProperty("java.vm.version")));
+ }
+
+ if (Runtime.version().pre().isPresent()) {
+ throw new GradleException(
+ String.format(
+ Locale.ROOT,
+ "You are running Gradle with an EA version of Java - this is not supported. "
+ + "To test Lucene compatibility with EA or pre-release versions, see this help guide: "
+ + " './gradlew helpJvms'. Detected Java version: "
+ + "[%s %s]",
+ System.getProperty("java.vm.name"),
+ System.getProperty("java.vm.version")));
+ }
+
+ // Unless we're regenerating the wrapper, ensure we have the exact expected gradle version.
+ if (!rootProject.getGradle().getStartParameter().getTaskNames().contains("wrapper")) {
+ GradleVersion currentGradleVersion = GradleVersion.current();
+ if (!currentGradleVersion.equals(GradleVersion.version(expectedGradleVersion))) {
+ if (currentGradleVersion
+ .getBaseVersion()
+ .equals(GradleVersion.version(expectedGradleVersion).getBaseVersion())) {
+ rootProject
+ .getLogger()
+ .warn(
+ "Gradle {} is required but base version of this gradle matches, proceeding ("
+ + "this gradle is {}).",
+ expectedGradleVersion,
+ currentGradleVersion);
+ } else {
+ throw new GradleException(
+ "Gradle "
+ + expectedGradleVersion
+ + " is required (hint: use the ./gradlew script), "
+ + "this gradle is "
+ + currentGradleVersion
+ + ".");
+ }
+ }
+ }
+
+ rootProject
+ .getTasks()
+ .register(
+ CHECK_JDK_INTERNALS_EXPOSED_TO_GRADLE_TASK,
+ task -> {
+ task.doFirst(
+ t -> {
+ var jdkCompilerModule =
+ ModuleLayer.boot().findModule("jdk.compiler").orElseThrow();
+ var gradleModule = getClass().getModule();
+ var internalsExported =
+ Set.of(
+ "com.sun.tools.javac.api",
+ "com.sun.tools.javac.file",
+ "com.sun.tools.javac.parser",
+ "com.sun.tools.javac.tree",
+ "com.sun.tools.javac.util")
+ .stream()
+ .allMatch(pkg -> jdkCompilerModule.isExported(pkg, gradleModule));
+
+ if (!internalsExported) {
+ throw new GradleException(
+ "Certain gradle tasks and plugins require access to jdk.compiler"
+ + " internals, your gradle.properties might have just been generated or could be"
+ + " out of sync (see gradle/template.gradle.properties)");
+ }
+ });
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java
new file mode 100644
index 00000000000..78b18754e7d
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/HelpPlugin.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.misc;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+import org.apache.lucene.gradle.SuppressForbidden;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.gradle.api.GradleException;
+import org.gradle.api.Project;
+import org.gradle.api.tasks.StopExecutionException;
+
+/** Configures "helpXyz" tasks which display plain text files under 'help' folder. */
+public class HelpPlugin extends LuceneGradlePlugin {
+ record HelpFile(String name, String path, String description) {}
+
+ private static final List<HelpFile> helpFiles =
+ List.of(
+ new HelpFile("Workflow", "help/workflow.txt", "Typical workflow commands."),
+ new HelpFile("Tests", "help/tests.txt", "Tests, filtering, beasting, etc."),
+ new HelpFile("Formatting", "help/formatting.txt", "Code formatting conventions."),
+ new HelpFile("Jvms", "help/jvms.txt", "Using alternative or EA JVM toolchains."),
+ new HelpFile(
+ "Deps", "help/dependencies.txt", "Declaring, inspecting and excluding dependencies."),
+ new HelpFile(
+ "ForbiddenApis",
+ "help/forbiddenApis.txt",
+ "How to add/apply rules for forbidden APIs."),
+ new HelpFile(
+ "LocalSettings",
+ "help/localSettings.txt",
+ "Local settings, overrides and build performance tweaks."),
+ new HelpFile(
+ "Regeneration",
+ "help/regeneration.txt",
+ "How to refresh generated and derived resources."),
+ new HelpFile("Jmh", "help/jmh.txt", "JMH micro-benchmarks."),
+ new HelpFile("Git", "help/git.txt", "Git assistance and guides."),
+ new HelpFile("IDEs", "help/IDEs.txt", "IDE support."),
+ new HelpFile(
+ "Publishing",
+ "help/publishing.txt",
+ "Maven and other artifact publishing, signing, etc."));
+
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ // Register helpXyz task to display the given help section.
+ var tasks = rootProject.getTasks();
+ for (var helpEntry : helpFiles) {
+ tasks.register(
+ "help" + helpEntry.name,
+ task -> {
+ task.setGroup("Help (developer guides and hints)");
+ task.setDescription(helpEntry.description);
+ task.doFirst(
+ t -> {
+ try {
+ println("\n" + Files.readString(rootProject.file(helpEntry.path).toPath()));
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
+ });
+ }
+
+ // Add a custom section to the default 'help' task.
+ tasks
+ .named("help")
+ .configure(
+ task -> {
+ task.doFirst(
+ t -> {
+ printf("");
+ printf(
+ "This is Lucene %s build file (gradle %s). See some guidelines in files",
+ rootProject.getVersion(), rootProject.getGradle().getGradleVersion());
+ printf("found under the help/* folder or type any of these:");
+ printf("");
+
+ helpFiles.forEach(
+ helpFile ->
+ printf(
+ " gradlew :help%-16s # %s", helpFile.name, helpFile.description));
+
+ println("");
+ println(
+ "For the impatient, build the project with 'gradlew assemble', run all tests with 'gradlew check', check "
+ + "your current build options with 'gradlew allOptions'.");
+ throw new StopExecutionException();
+ });
+ });
+
+ // ensure all help files exist.
+ // Make sure all help files exist.
+ var helpDir = getProjectRootPath(rootProject).resolve("help");
+ var allHelpFilesExist =
+ tasks.register(
+ "checkAllHelpFilesExist",
+ task -> {
+ task.doFirst(
+ t -> {
+ helpFiles.forEach(
+ helpFile -> {
+ if (!rootProject.file(helpFile.path).exists()) {
+ throw new GradleException("Help file missing: " + helpFile.path);
+ }
+ });
+
+ try {
+ var existing =
+ Files.list(helpDir)
+ .map(p -> "help/" + p.getFileName().toString())
+ .collect(Collectors.toSet());
+ var expected =
+ helpFiles.stream().map(v -> v.path).collect(Collectors.toSet());
+ if (!existing.equals(expected)) {
+ throw new GradleException(
+ "help/*.txt help files are not consistent with the descriptions"
+ + "in the "
+ + getClass().getName());
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
+ });
+
+ tasks
+ .named("check")
+ .configure(
+ task -> {
+ task.dependsOn(allHelpFilesExist);
+ });
+ }
+
+ @SuppressForbidden(reason = "sysout is ok here.")
+ private static void printf(String fmt, Object... args) {
+ System.out.printf(Locale.ROOT, fmt + "\n", args);
+ }
+
+ @SuppressForbidden(reason = "sysout is ok here.")
+ private static void println(String s) {
+ System.out.println(s);
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/QuietExec.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/QuietExec.java
new file mode 100644
index 00000000000..392572457c2
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/QuietExec.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.misc;
+
+import java.io.File;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.Locale;
+import org.apache.lucene.gradle.SuppressForbidden;
+import org.gradle.api.GradleException;
+import org.gradle.api.logging.LogLevel;
+import org.gradle.api.logging.Logger;
+import org.gradle.api.tasks.Exec;
+import org.gradle.api.tasks.TaskAction;
+import org.gradle.process.ExecResult;
+
+/**
+ * An {@link org.gradle.api.tasks.Exec} task that does not emit any output unless the executed
+ * command fails.
+ */
+public class QuietExec extends Exec {
+ public QuietExec() {
+ super.setIgnoreExitValue(true);
+ }
+
+ @TaskAction
+ protected void exec() {
+ try {
+ // TODO: maybe add an output stream that spills to disk only when necessary here?
+ File outputFile = File.createTempFile("exec-output-", ".txt", getTemporaryDir());
+ try (OutputStream os =
+ new FilterOutputStream(Files.newOutputStream(outputFile.toPath())) {
+ @Override
+ public void close() {
+ // no-op. we close this stream manually.
+ }
+ }) {
+ super.setStandardInput(InputStream.nullInputStream());
+ super.setStandardOutput(os);
+ super.setErrorOutput(os);
+
+ super.exec();
+ os.flush();
+
+ var result = super.getExecutionResult().get();
+ processResult(result, outputFile, getExecutable(), getLogger());
+ }
+ } catch (IOException e) {
+ throw new GradleException("QuietExec failed: " + e.getMessage(), e);
+ }
+ }
+
+ public static void processResult(
+ ExecResult result, File outputFile, String executable, Logger logger) throws IOException {
+ boolean failed = result.getExitValue() != 0;
+ boolean shouldLogOutput = failed || (logger.isInfoEnabled());
+ if (shouldLogOutput) {
+ String output = getOutputAsString(outputFile);
+ logger.log(failed ? LogLevel.ERROR : LogLevel.INFO, output);
+ }
+
+ if (failed) {
+ throw new GradleException(
+ String.format(
+ Locale.ROOT,
+ "The executed process '%s' returned an unexpected status code: %d, full process output logged above.",
+ executable,
+ result.getExitValue()));
+ }
+ }
+
+ @SuppressForbidden(reason = "Intentional default-codepage conversion.")
+ private static String getOutputAsString(File outputFile) throws IOException {
+ return new String(Files.readAllBytes(outputFile.toPath()));
+ }
+
+ @Override
+ public Exec setStandardInput(InputStream inputStream) {
+ throw propertyUnsupported("standardInput");
+ }
+
+ @Override
+ public Exec setStandardOutput(OutputStream outputStream) {
+ throw propertyUnsupported("standardOutput");
+ }
+
+ @Override
+ public Exec setIgnoreExitValue(boolean ignoreExitValue) {
+ throw propertyUnsupported("ignoreExitValue");
+ }
+
+ @Override
+ public Exec setErrorOutput(OutputStream outputStream) {
+ throw propertyUnsupported("errorOutput");
+ }
+
+ private GradleException propertyUnsupported(String propName) {
+ throw new GradleException("Quiet exec does not support setting this property: " + propName);
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java
new file mode 100644
index 00000000000..195a60b70a9
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.misc;
+
+import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsPlugin;
+import java.util.Collection;
+import java.util.List;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.apache.lucene.gradle.plugins.astgrep.AstGrepPlugin;
+import org.apache.lucene.gradle.plugins.eclint.EditorConfigLintPlugin;
+import org.apache.lucene.gradle.plugins.gitgrep.GitGrepPlugin;
+import org.apache.lucene.gradle.plugins.gitinfo.GitInfoPlugin;
+import org.apache.lucene.gradle.plugins.globals.RegisterBuildGlobalsPlugin;
+import org.apache.lucene.gradle.plugins.hacks.HacksPlugin;
+import org.apache.lucene.gradle.plugins.hacks.WipeGradleTempPlugin;
+import org.apache.lucene.gradle.plugins.help.BuildOptionGroupsPlugin;
+import org.apache.lucene.gradle.plugins.regenerate.RegenerateTasksSupportPlugin;
+import org.gradle.api.Project;
+import org.gradle.api.file.DuplicatesStrategy;
+import org.gradle.api.initialization.IncludedBuild;
+import org.gradle.api.plugins.BasePlugin;
+import org.gradle.api.plugins.BasePluginExtension;
+import org.gradle.api.plugins.ExtraPropertiesExtension;
+import org.gradle.api.plugins.PluginContainer;
+import org.gradle.api.tasks.TaskContainer;
+import org.gradle.api.tasks.bundling.AbstractArchiveTask;
+
+/** Initialization of the root project, globals, etc. */
+public class RootProjectSetupPlugin extends LuceneGradlePlugin {
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ // Register these plugins early, for everything.
+ rootProject
+ .getAllprojects()
+ .forEach(
+ project -> {
+ project.getPlugins().apply(BasePlugin.class);
+ project.getPlugins().apply(BuildOptionsPlugin.class);
+ project.getPlugins().apply(BuildOptionGroupsPlugin.class);
+ });
+
+ // Register other root-level plugins.
+ PluginContainer plugins = rootProject.getPlugins();
+ plugins.apply(RegisterBuildGlobalsPlugin.class);
+ plugins.apply(GitInfoPlugin.class);
+
+ // Apply common configuration to all projects.
+ rootProject.getAllprojects().forEach(this::applyCommonConfiguration);
+
+ // Register more root-level plugins
+ plugins.apply(RegenerateTasksSupportPlugin.class);
+ plugins.apply(GitGrepPlugin.class);
+ plugins.apply(AstGrepPlugin.class);
+ plugins.apply(EditorConfigLintPlugin.class);
+ plugins.apply(HelpPlugin.class);
+ plugins.apply(HacksPlugin.class);
+ plugins.apply(WipeGradleTempPlugin.class);
+
+ // wire up included composite builds to validation tasks.
+ connectCompositeTasksToMainBuild(rootProject);
+
+ // TODO: this shouldn't be here but it's used in multiple scripts that are racy in
+ // lazy-evaluation.
+ {
+ Project project = rootProject.project(":lucene:core");
+ var ext = project.getExtensions().getByType(ExtraPropertiesExtension.class);
+ ext.set("mrjarJavaVersions", List.of(24));
+ ext.set("apijars", project.getLayout().getProjectDirectory().dir("src/generated/jdk"));
+ }
+ }
+
+ private void applyCommonConfiguration(Project project) {
+ project.setGroup("org.apache.lucene");
+ if (project != project.getRootProject()) {
+ project.setVersion(project.getRootProject().getVersion());
+ }
+
+ project.getRepositories().mavenCentral();
+
+ // Common archive artifact naming.
+ var baseExt = project.getExtensions().getByType(BasePluginExtension.class);
+ baseExt.getArchivesName().convention(project.getPath().replaceAll("^:", "").replace(':', '-'));
+
+ // Register these tasks for each project, even if they don't use them.
+ project
+ .getTasks()
+ .register(
+ "tidy",
+ task -> {
+ task.setDescription(
+ "Applies all code formatters and other enforced cleanups to the project.");
+ task.setGroup("verification");
+ });
+
+ // Try to ensure builds are reproducible.
+ project
+ .getTasks()
+ .withType(AbstractArchiveTask.class)
+ .configureEach(
+ task -> {
+ task.setDuplicatesStrategy(DuplicatesStrategy.FAIL);
+ task.setPreserveFileTimestamps(false);
+ task.setReproducibleFileOrder(true);
+ task.dirPermissions(
+ permissions -> {
+ permissions.unix(0755);
+ });
+ task.filePermissions(
+ permissions -> {
+ permissions.unix(0644);
+ });
+ });
+ }
+
+ private void connectCompositeTasksToMainBuild(Project rootProject) {
+ TaskContainer tasks = rootProject.getTasks();
+ Collection<IncludedBuild> includedBuilds = rootProject.getGradle().getIncludedBuilds();
+
+ // Wire up top-level tidy and check from composite builds to the main project.
+ tasks
+ .named("tidy")
+ .configure(
+ task -> {
+ task.dependsOn(includedBuilds.stream().map(build -> build.task(":tidy")).toList());
+ });
+
+ tasks
+ .named("check")
+ .configure(
+ task -> {
+ task.dependsOn(includedBuilds.stream().map(build -> build.task(":check")).toList());
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTaskExtension.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTaskExtension.java
new file mode 100644
index 00000000000..5afc5de549e
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTaskExtension.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.regenerate;
+
+import org.gradle.api.provider.SetProperty;
+
+/**
+ * An extension added to all tasks that regenerate some Lucene sources. The extension can be used to
+ * add inputs and outputs used to compute hash signatures, which in turn control if the derived
+ * resources haven't been altered (with respect to their sources).
+ */
+public abstract class RegenerateTaskExtension {
+ public abstract SetProperty<String> getIgnoredInputs();
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTasksSupportPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTasksSupportPlugin.java
new file mode 100644
index 00000000000..f4086405fd5
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/regenerate/RegenerateTasksSupportPlugin.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.regenerate;
+
+import java.util.Set;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.apache.lucene.gradle.plugins.misc.QuietExec;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
+import org.gradle.api.tasks.TaskCollection;
+
+/** Adds infrastructure support for tasks that regenerate (versioned) sources within Lucene. */
+public class RegenerateTasksSupportPlugin extends LuceneGradlePlugin {
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ rootProject
+ .getAllprojects()
+ .forEach(
+ project -> {
+ TaskCollection<Task> regenerateTasks =
+ project
+ .getTasks()
+ .matching(task -> task.getName().matches("generate(?<name>.*)Internal"));
+
+ // Add an extension that allows tasks to customize signatures to all generate tasks.
+ regenerateTasks.configureEach(
+ task -> {
+ task.getExtensions().create("regenerate", RegenerateTaskExtension.class);
+ });
+
+ // configure only a subset of QuietExec's properties to be inputs to signatures.
+ regenerateTasks
+ .withType(QuietExec.class)
+ .configureEach(
+ task -> {
+ task.getExtensions()
+ .getByType(RegenerateTaskExtension.class)
+ .getIgnoredInputs()
+ .addAll(Set.of("args", "executable", "ignoreExitValue"));
+ });
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
index 4c4ca6cd824..0a52628ef7b 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/spotless/GoogleJavaFormatPlugin.java
@@ -19,6 +19,7 @@ package org.apache.lucene.gradle.plugins.spotless;
import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension;
import java.util.List;
import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.apache.lucene.gradle.plugins.misc.CheckEnvironmentPlugin;
import org.gradle.api.Project;
import org.gradle.api.file.ConfigurableFileTree;
import org.gradle.api.plugins.JavaPlugin;
@@ -66,15 +67,16 @@ public class GoogleJavaFormatPlugin extends LuceneGradlePlugin {
tasks.named("tidy", tidy -> tidy.dependsOn(applyTask));
tasks.named("check", check -> check.dependsOn(checkTask));
- // Configure details depending on the project.
-
for (var t : List.of(applyTask, checkTask)) {
t.configure(
task -> {
task.getBatchSize().set(batchSizeOption);
+ task.dependsOn(":" + CheckEnvironmentPlugin.CHECK_JDK_INTERNALS_EXPOSED_TO_GRADLE_TASK);
});
}
+ // Configure details depending on the project.
+
for (var t : List.of(applyTask, checkTask)) {
t.configure(
task -> {
diff --git a/build.gradle b/build.gradle
index 3b7cf817d35..10f5b8f38b6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,3 +1,4 @@
+import org.apache.lucene.gradle.plugins.misc.CheckEnvironmentPlugin
import org.apache.lucene.gradle.plugins.spotless.GoogleJavaFormatPlugin
/*
@@ -18,14 +19,12 @@ import org.apache.lucene.gradle.plugins.spotless.GoogleJavaFormatPlugin
*/
plugins {
- // Apply convention plugins from the composite build-infra project.
+ // Apply build plugins from the composite build-infra project.
// The order of plugins does matter (most of the time).
id "lucene.root-project.check-environment"
- id "lucene.root-project.setup"
-
- id "lucene.all-projects.conventions"
- id "lucene.help"
+ id "base"
+ id "lucene.root-project.setup"
id "lucene.java-projects.conventions"
@@ -59,8 +58,6 @@ plugins {
id "lucene.datasets.external-datasets"
- id "lucene.hacks.downloader-retries"
- id "lucene.hacks.wipe-gradle-temp"
id "lucene.hacks.turbocharge-jvm-opts"
id "lucene.hacks.dummy-outputs"
@@ -71,6 +68,7 @@ plugins {
id "lucene.regenerate"
id "lucene.regenerate.jflex"
+ id "lucene.regenerate.forUtil"
id "lucene.regenerate.moman"
id "lucene.regenerate.kuromoji"
id "lucene.regenerate.nori"
@@ -79,6 +77,7 @@ plugins {
id "lucene.regenerate.antlr"
id "lucene.regenerate.unicode-test-classes"
id "lucene.regenerate.extract-jdk-apis"
+ id "lucene.regenerate.snowball"
}
description = 'Grandparent project for Apache Lucene Core'
diff --git a/gradle/regenerate/snowball/snowball.sh b/gradle/regenerate/snowball/snowball.sh
index 329dd1a5cd4..d95ca53b1ea 100644
--- a/gradle/regenerate/snowball/snowball.sh
+++ b/gradle/regenerate/snowball/snowball.sh
@@ -47,7 +47,7 @@ for file in ${SRCDIR}/java/org/tartarus/snowball/ext/*.java; do
# title-case the classes (fooStemmer -> FooStemmer) so they obey normal java conventions
base=$(basename $file)
oldclazz="${base%.*}"
- newclazz=${oldclazz^}
+ newclazz=$(echo "$oldclazz" | perl -pe 's/^(.)/\U$1/')
echo ${newclazz} | sed -e 's/Stemmer//' >> ${TESTDSTDIR}/languages.txt
cat $file | sed "s/${oldclazz}/${newclazz}/g" > ${DESTDIR}/ext/${newclazz}.java
done
diff --git a/lucene/analysis/common/build.gradle b/lucene/analysis/common/build.gradle
index 85328c3ed7c..faa3a1db2b0 100644
--- a/lucene/analysis/common/build.gradle
+++ b/lucene/analysis/common/build.gradle
@@ -87,7 +87,7 @@ def cloningTasks = dictionaryProjects.collect { repoSpec ->
def gitExec = { List<String> cmdArgs ->
logger.lifecycle("Executing git " + cmdArgs.join(" "))
execOps.exec {
- executable project.externalTool("git")
+ executable = buildGlobals.externalTool("git")
ignoreExitValue = false
workingDir dotGitPath.getParent().toString()
args = cmdArgs
diff --git a/lucene/analysis/common/src/generated/checksums/snowball.json b/lucene/analysis/common/src/generated/checksums/generateSnowball.json
similarity index 81%
rename from lucene/analysis/common/src/generated/checksums/snowball.json
rename to lucene/analysis/common/src/generated/checksums/generateSnowball.json
index daac9d3d184..b53c20dea9f 100644
--- a/lucene/analysis/common/src/generated/checksums/snowball.json
+++ b/lucene/analysis/common/src/generated/checksums/generateSnowball.json
@@ -32,19 +32,19 @@
"lucene/analysis/common/src/java/org/tartarus/snowball/ext/TamilStemmer.java": "3f5f20f3622716d37935a32616a2afad91a23bc3",
"lucene/analysis/common/src/java/org/tartarus/snowball/ext/TurkishStemmer.java": "6392c0ac7b041717006e5847450be361f19a1e3f",
"lucene/analysis/common/src/java/org/tartarus/snowball/ext/YiddishStemmer.java": "9faaa89e7810fa81ca1f232f5f18bc83fe66c241",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt": "f3627b9037da730534aa008b9edf32582c16866e",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt": "3f84f1c2ae282bd1350fa246baaded095bebdecc",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt": "5822d03de10b6403512774492508f586ea55a7c7",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt": "f161b9b0e757fa4793272bb5d11fd0c0546f9129",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt": "315826e66bd1f9ae294f5a1fc7738887706fc9e1",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt": "301fa879d91631bc30169c12f4045f294aefd7ec",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt": "81837d5b861a876314b32fdaa2a4cee7c09fbbf8",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt": "b5e23c7a1b9893ed472bdbf27f952b9ace53d2d6",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt": "99dea155818fe3fb3c31a29ff7f67e77a76ccc0d",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt": "4df230f3d0f3898d9812b8d08c7b08bfc55477c3",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt": "b612f3c7df6d3f6fca1aff5d8d9e5c353df423cd",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt": "e7579ef190edfc939348353dca480d9cedae1d83",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt": "cbe87679fbabae13c8ea16be8a11fd78151f8bf7",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt": "852c0b6520a1d2ac9d2ec189c296c2707b5060aa",
- "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt": "2fcc6906c3d55f8087030c28f0f118be4aed6596"
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt": "ce45d41833f77aa5a444134de4e4587b696f40c6",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt": "f5e864c47ca680cf3b381152f37caafe1b694f57",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt": "976e921dfbc48fb30ef08bd598d3172f1e5bbb1c",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt": "01f82cae4a816649dfdf66a04eb1ea893df6bd4e",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt": "d86db9927e00edb7a692fc4f7064db643a0f093a",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt": "cd0b605c2f653ac7dbd9df40b90288b4611bc0f1",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt": "9c6f88f6d32f6489373b8579d8fe14fc07062970",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt": "aac55140cc63741827a973f5d940f2703300f437",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt": "2d55ab583ed22f0e2c104c4b79a18f192747e009",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt": "856035d2809575b42435219493635bca7f53893e",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt": "6221423e2cd3da80e8f0a1d3f791012c01ac1c1f",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt": "b07012eaaa0e5214946dfe117a0a687c0426c8ba",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt": "3154d6ee59dd3e55f30ec0afea8f76e1b7e36c96",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt": "01cfbe70abf03838405f2775d8f9676335bb02e6",
+ "lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt": "17579ee0a81cd692d7e187228657d1bcbba6eae2"
}
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt
index 6e90e8f1aae..94e7eebd2ec 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/danish_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/danish/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/danish/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Danish stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt
index 48c5515123a..e72ccf38766 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/dutch_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/dutch/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/dutch/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Dutch stop word list. Comments begin with vertical bar. Each stop
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt
index 00902dce6d7..1d568ea85fd 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/english_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/english/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/english/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| An English stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt
index c9ee2f16dc5..f0c0557232e 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/finnish_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/finnish/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/finnish/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| forms of BE
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt
index 658ae9c91ac..b41b2008d5b 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/french_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/french/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/french/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A French stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt
index 804bbbdb010..5c0f133afd3 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/german_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/german/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/german/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A German stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt
index 3fa279eac91..124daa1fca0 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/hungarian_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/hungarian/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/hungarian/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| Hungarian stop word list
| prepared by Anna Tordai
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt
index 225560bd833..a26732ac8cf 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/indonesian_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/indonesian/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/indonesian/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
yang | that
dan | and
di | in
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt
index 395db9e7ef2..0cc67fa9207 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/irish_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/irish/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/irish/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
a
ach
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt
index c74160e28ca..a1748466e75 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/italian_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/italian/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/italian/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| An Italian stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt
index f427609484f..e75688727fe 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/norwegian_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/norwegian/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/norwegian/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Norwegian stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt
index d03d7f234d5..3dc4bbf8bc5 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/portuguese_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/portuguese/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/portuguese/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Portuguese stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt
index 65512d49dbd..23a1ee8612c 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/russian_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/russian/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/russian/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| a russian stop word list. comments begin with vertical bar. each stop
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt
index 48bd65ef867..2936910b1e2 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/spanish_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/spanish/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/spanish/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Spanish stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt
index d1d0d100880..151cd6a888a 100644
--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt
+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/snowball/swedish_stop.txt
@@ -1,11 +1,11 @@
- | From https://snowballstem.org/algorithms/swedish/stop.txt
- | This file is distributed under the BSD License.
- | See https://snowballstem.org/license.html
- | Also see https://opensource.org/licenses/bsd-license.html
- | - Encoding was converted to UTF-8.
- | - This notice was added.
- |
- | NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
+| From https://snowballstem.org/algorithms/swedish/stop.txt
+| This file is distributed under the BSD License.
+| See https://snowballstem.org/license.html
+| Also see https://opensource.org/licenses/bsd-license.html
+| - Encoding was converted to UTF-8.
+| - This notice was added.
+|
+| NOTE: To use this file with StopFilterFactory, you must specify format="snowball"
| A Swedish stop word list. Comments begin with vertical bar. Each stop
| word is at the start of a line.
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil101.json b/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil101.json
index 5442618b4cc..b08480a3eda 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil101.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil101.json
@@ -1,4 +1,4 @@
{
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/ForDeltaUtil.java": "f4cff08d9a5dd99f5332c2f9f6d386f0d7f58677",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py": "ea46cd6b2384fc1cddb8c1dc5e30bf5f76054d91"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/ForDeltaUtil.java": "29fd59e9847d3012497c3079fa7ebc4f68fa6a94",
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py": "147b81236bc0373fe97e808c0ae7a2cb6276ae5a"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil912.json b/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil912.json
index 939c857b7b4..cf9daeb045a 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil912.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForDeltaUtil912.json
@@ -1,4 +1,4 @@
{
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/ForDeltaUtil.java": "b81961f0b277b1458ca259e0d23ccc4eeeb47fe7",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py": "3191d7591309b7876c5c709fb9375af5b87c2ef8"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/ForDeltaUtil.java": "3ba9d988a0c295bf71829b8a2e4d0c23fe01ad6e",
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py": "cc8a431724673c0c31915f1c4dd9d01514ef5cad"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForUtil101.json b/lucene/backward-codecs/src/generated/checksums/generateForUtil101.json
index b9772617f56..7ed8dc3da57 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForUtil101.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForUtil101.json
@@ -1,4 +1,4 @@
{
"lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/ForUtil.java": "5a7c2e1e09780a2ccd31c22a1e1fa47443cf2a32",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForUtil.py": "c98cce3be0698048ebda6beaa9d404f25089930d"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForUtil.py": "50425669816e038573cabf373a2b68a12d1a5339"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForUtil84.json b/lucene/backward-codecs/src/generated/checksums/generateForUtil84.json
index 547f5094c53..ce2933706a6 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForUtil84.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForUtil84.json
@@ -1,4 +1,4 @@
{
"lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/ForUtil.java": "c3bff5677f7d98fbb362018a4c1dbad4d670610f",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/gen_ForUtil.py": "e3c0b1d1d9fcc9f04ae8870e40aab44133321272"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene84/gen_ForUtil.py": "04fff02ed744b3f4efe0d7a7ff9faa06a2de6a6d"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForUtil90.json b/lucene/backward-codecs/src/generated/checksums/generateForUtil90.json
index b94d3d1e9fc..afc40a39b01 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForUtil90.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForUtil90.json
@@ -1,4 +1,4 @@
{
"lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/ForUtil.java": "861cab516c7424e6323831c16f0f521499391a90",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/gen_ForUtil.py": "b66e2f8012759d6d5ce0d73fabb329ae4a391aa0"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/gen_ForUtil.py": "eec54fabbd5c580dbe2bc131b1954c95a2b1ff3c"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForUtil912.json b/lucene/backward-codecs/src/generated/checksums/generateForUtil912.json
index 930fabb6fff..b5a92b5abfc 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForUtil912.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForUtil912.json
@@ -1,4 +1,4 @@
{
"lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/ForUtil.java": "e6db3c665dfebca8b93eb6b4651d2eb3af637b02",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForUtil.py": "993ecc9cf7ea821963384070669695257b16e040"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForUtil.py": "22f64aeeebd3c4e6ed411204a6cda3f6f5e73031"
}
diff --git a/lucene/backward-codecs/src/generated/checksums/generateForUtil99.json b/lucene/backward-codecs/src/generated/checksums/generateForUtil99.json
index e9bda36d1c8..e35d41f68bf 100644
--- a/lucene/backward-codecs/src/generated/checksums/generateForUtil99.json
+++ b/lucene/backward-codecs/src/generated/checksums/generateForUtil99.json
@@ -1,4 +1,4 @@
{
"lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene99/ForUtil.java": "f31797842f047626df6a1a6b97167bec60269fec",
- "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene99/gen_ForUtil.py": "325f2610974b0e76e278b6445405a098a3763feb"
+ "lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene99/gen_ForUtil.py": "b8fd3de65c18767522003fe430fa505747cce60e"
}
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py
index 00acb3af9ee..a120969ef30 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/gen_ForDeltaUtil.py
@@ -46,7 +46,41 @@ import java.io.IOException;
import org.apache.lucene.store.DataOutput;
import org.apache.lucene.util.packed.PackedInts;
-import static org.apache.lucene.backward_codecs.lucene101.ForUtil.*;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.BLOCK_SIZE;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_1;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_2;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_4;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_5;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_6;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_7;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK16_8;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_1;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_10;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_11;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_12;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_13;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_14;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_15;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_16;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_2;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_3;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_4;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_5;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_6;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_7;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_8;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.MASK32_9;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.collapse16;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.collapse8;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decode1;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decode10;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decode2;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decode3;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decode9;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.decodeSlow;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.encode;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.expand16;
+import static org.apache.lucene.backward_codecs.lucene101.ForUtil.expand8;
/**
* Inspired from https://fulmicoton.com/posts/bitpacking/
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py
index 4f479bb9f34..4d71bfce196 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene912/gen_ForDeltaUtil.py
@@ -47,7 +47,50 @@ import org.apache.lucene.store.DataOutput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.packed.PackedInts;
-import static org.apache.lucene.backward_codecs.lucene912.ForUtil.*;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.BLOCK_SIZE;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_1;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_2;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_4;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_5;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_6;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_7;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK16_8;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_1;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_12;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_13;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_14;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_15;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_16;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_2;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_3;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_4;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_5;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_6;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.MASK32_8;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.collapse16;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.collapse32;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.collapse8;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode1;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode10;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode11;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode17;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode18;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode19;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode2;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode20;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode21;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode22;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode23;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode24;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode3;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode4;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decode9;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.decodeSlow;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.encode;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.expand16;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.expand32;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.expand8;
+import static org.apache.lucene.backward_codecs.lucene912.ForUtil.splitLongs;
/**
* Inspired from https://fulmicoton.com/posts/bitpacking/
diff --git a/lucene/core/src/generated/checksums/generateForDeltaUtil.json b/lucene/core/src/generated/checksums/generateForDeltaUtil.json
index e6d0b679f91..9d70786985f 100644
--- a/lucene/core/src/generated/checksums/generateForDeltaUtil.json
+++ b/lucene/core/src/generated/checksums/generateForDeltaUtil.json
@@ -1,4 +1,4 @@
{
- "lucene/core/src/java/org/apache/lucene/codecs/lucene103/ForDeltaUtil.java": "1d463b5044c3498d2372a06e3cd536917786fdd1",
- "lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py": "722d50e56c0e805df0059e6ec89b30ca7d5f845a"
+ "lucene/core/src/java/org/apache/lucene/codecs/lucene103/ForDeltaUtil.java": "dc896d5df4b2a091918bfa14b30aad417feaffac",
+ "lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py": "d622cc9f9a13987a07c2472a1c5b0111a3a7bc62"
}
diff --git a/lucene/core/src/generated/checksums/generateForUtil.json b/lucene/core/src/generated/checksums/generateForUtil.json
index 0334d806bd6..8a50acc81d5 100644
--- a/lucene/core/src/generated/checksums/generateForUtil.json
+++ b/lucene/core/src/generated/checksums/generateForUtil.json
@@ -1,4 +1,4 @@
{
"lucene/core/src/java/org/apache/lucene/codecs/lucene103/ForUtil.java": "1ea2dac2a26be521a70cf74c37fe9134f7b42cb7",
- "lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForUtil.py": "0eb3ae0815b4b25e4d33074d96546e622e4278be"
+ "lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForUtil.py": "cd186fe09ceeedb4e2dd3be191d7461e67fa1c2b"
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py b/lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py
index 850dd911dad..eccf30d28d8 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene103/gen_ForDeltaUtil.py
@@ -47,7 +47,41 @@ import org.apache.lucene.internal.vectorization.PostingDecodingUtil;
import org.apache.lucene.store.DataOutput;
import org.apache.lucene.util.packed.PackedInts;
-import static org.apache.lucene.codecs.lucene103.ForUtil.*;
+import static org.apache.lucene.codecs.lucene103.ForUtil.BLOCK_SIZE;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_1;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_2;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_4;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_5;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_6;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_7;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK16_8;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_1;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_10;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_11;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_12;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_13;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_14;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_15;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_16;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_2;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_3;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_4;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_5;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_6;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_7;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_8;
+import static org.apache.lucene.codecs.lucene103.ForUtil.MASK32_9;
+import static org.apache.lucene.codecs.lucene103.ForUtil.collapse16;
+import static org.apache.lucene.codecs.lucene103.ForUtil.collapse8;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decode1;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decode10;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decode2;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decode3;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decode9;
+import static org.apache.lucene.codecs.lucene103.ForUtil.decodeSlow;
+import static org.apache.lucene.codecs.lucene103.ForUtil.encode;
+import static org.apache.lucene.codecs.lucene103.ForUtil.expand16;
+import static org.apache.lucene.codecs.lucene103.ForUtil.expand8;
/**
* Inspired from https://fulmicoton.com/posts/bitpacking/
diff --git a/lucene/distribution/build.gradle b/lucene/distribution/build.gradle
index a0f4ca8983e..b2f6089470c 100644
--- a/lucene/distribution/build.gradle
+++ b/lucene/distribution/build.gradle
@@ -20,6 +20,7 @@ import org.apache.lucene.gradle.plugins.gitinfo.GitInfoExtension
import java.nio.charset.StandardCharsets
import java.nio.file.Files
+import org.apache.lucene.gradle.plugins.misc.QuietExec
plugins {
id 'signing'
@@ -42,33 +43,28 @@ Provider<String> gitRev = gitStatus.getting("git.commit")
// Prepare the "source" distribution artifact. We use raw git export, no additional complexity needed.
Provider<RegularFile> sourceTgzFile = project.layout.buildDirectory.file("packages/lucene-${version}-src.tgz")
-tasks.register("assembleSourceTgz", {
+tasks.register("assembleSourceTgz", QuietExec, {
description = "Assemble source Lucene artifact as a .tgz file."
inputs.property("git-revision", gitRev)
-
outputs.file sourceTgzFile
- doFirst {
- quietExec {
- executable = project.externalTool("git")
- workingDir = project.rootDir
-
- // An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
- environment("GIT_DIR", gitInfoExt.getDotGitDir().get().asFile)
-
- args += [
- "archive",
- "--format",
- "tgz",
- "--prefix",
- "lucene-${version}/",
- "--output",
- sourceTgzFile.get().asFile,
- "HEAD"
- ]
- }
- }
+ executable = buildGlobals.externalTool("git")
+ workingDir = project.rootDir
+
+ // An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
+ environment("GIT_DIR", gitInfoExt.getDotGitDir().get().asFile)
+
+ args += [
+ "archive",
+ "--format",
+ "tgz",
+ "--prefix",
+ "lucene-${version}/",
+ "--output",
+ sourceTgzFile.get().asFile,
+ "HEAD"
+ ]
})