Skip to content

Apache Lucene open-source search software

Fix assemble source release (#14800)

Dawid Weissf3053149a412
diff --git a/.github/workflows/run-checks-gradle-upgrade.yml b/.github/workflows/run-checks-gradle-upgrade.yml
index 4e290672a9d..0909ccb8a8c 100644
--- a/.github/workflows/run-checks-gradle-upgrade.yml
+++ b/.github/workflows/run-checks-gradle-upgrade.yml
@@ -85,10 +85,10 @@ jobs:
git reset --hard && git clean -xfd .
fi
- - run: ./gradlew testOpts
+ - run: ./gradlew allOptions
- run: ./gradlew helpWorkflow
- run: ./gradlew licenses updateLicenses
- - run: ./gradlew check -x test -Pvalidation.git.failOnModified=false
+ - run: ./gradlew check -x test
- run: ./gradlew assembleRelease mavenToLocal
# Conserve resources: only run these in non-alt-java mode.
diff --git a/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle b/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
index 87c67558d99..be40f16cca5 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
@@ -29,7 +29,7 @@ configure(rootProject) {
return null
} else {
// release build
- return "https://lucene.apache.org/core/${urlVersion}"
+ return "https://lucene.apache.org/core/${urlVersion}".toString()
}
})
diff --git a/build-tools/build-infra/src/main/groovy/lucene.validation.jar-checks.gradle b/build-tools/build-infra/src/main/groovy/lucene.validation.jar-checks.gradle
index c949e518263..1550fdaf26f 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.validation.jar-checks.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.validation.jar-checks.gradle
@@ -297,7 +297,7 @@ configure(project(":lucene")) {
def updateLicenses = tasks.register("updateLicenses", {
group = 'Dependency validation'
description = "Write or update checksums of dependencies. May need to run gradlew --write-locks first if changing dependency versions"
- dependsOn "jarInfoTasks"
+ dependsOn jarInfoTasks
doLast {
licensesDir.asFile.mkdirs()
@@ -334,7 +334,13 @@ configure(project(":lucene")) {
// We add an ordering constraint that any validation task (or its dependency subgraph)
// must run after updateLicenses
configure(subprojects) {
- tasks.matching { it.name == "licenses" }.configureEach {
+ tasks.matching {
+ it.name in [
+ "licenses",
+ "validateJarChecksums",
+ "validateJarLicenses"
+ ]
+ }.configureEach {
mustRunAfter updateLicenses
}
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoExtension.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoExtension.java
index fde1c6c6a61..32edb8bb2fa 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoExtension.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoExtension.java
@@ -1,9 +1,19 @@
package org.apache.lucene.gradle.plugins.gitinfo;
+import org.gradle.api.file.FileSystemLocation;
import org.gradle.api.provider.MapProperty;
+import org.gradle.api.provider.Property;
public abstract class GitInfoExtension {
public static final String NAME = "gitinfo";
+ /**
+ * @return Return a map of key-value pairs extracted from the current git status.
+ */
public abstract MapProperty<String, String> getGitInfo();
+
+ /**
+ * @return Return the location of {@code .git} directory (or file, if worktrees are used).
+ */
+ public abstract Property<FileSystemLocation> getDotGitDir();
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoPlugin.java
index d9a67b79fe8..6579b8d9f3b 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoPlugin.java
@@ -1,8 +1,11 @@
package org.apache.lucene.gradle.plugins.gitinfo;
+import java.nio.file.Files;
+import java.nio.file.Path;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
+import org.gradle.api.file.Directory;
public class GitInfoPlugin implements Plugin<Project> {
@Override
@@ -24,5 +27,33 @@ public class GitInfoPlugin implements Plugin<Project> {
project.getExtensions().create(GitInfoExtension.NAME, GitInfoExtension.class);
gitInfoExtension.getGitInfo().value(gitInfoProvider).finalizeValueOnRead();
+
+ gitInfoExtension
+ .getDotGitDir()
+ .convention(
+ project
+ .getProviders()
+ .provider(
+ () -> {
+ Directory projectDirectory =
+ project.getRootProject().getLayout().getProjectDirectory();
+ Path gitLocation = projectDirectory.getAsFile().toPath().resolve(".git");
+ if (!Files.exists(gitLocation)) {
+ throw new GradleException(
+ "Can't locate .git (probably not a git clone?): "
+ + gitLocation.toAbsolutePath());
+ }
+
+ if (Files.isDirectory(gitLocation)) {
+ return projectDirectory.dir(".git");
+ } else if (Files.isRegularFile(gitLocation)) {
+ return projectDirectory.file(".git");
+ } else {
+ throw new GradleException(
+ "Panic, .git location not a directory or file: "
+ + gitLocation.toAbsolutePath());
+ }
+ }))
+ .finalizeValueOnRead();
}
}
diff --git a/dev-tools/scripts/buildAndPushRelease.py b/dev-tools/scripts/buildAndPushRelease.py
index ca27fd71786..24601fb3126 100755
--- a/dev-tools/scripts/buildAndPushRelease.py
+++ b/dev-tools/scripts/buildAndPushRelease.py
@@ -130,8 +130,6 @@ def prepare(root: str, version: str, pause_before_sign: bool, gpg_key_id: str |
print(" prepare-release")
cmd = "./gradlew --stacktrace --no-daemon assembleRelease -Dversion.release=%s" % version
- if dev_mode:
- cmd += " -Pvalidation.git.failOnModified=false"
if gpg_key_id is not None:
cmd += " -Psign --max-workers 2"
if sign_gradle:
diff --git a/help/tests.txt b/help/tests.txt
index 7e12b6c5585..1d40e7a9ea8 100644
--- a/help/tests.txt
+++ b/help/tests.txt
@@ -42,10 +42,14 @@ gradlew :lucene:misc:test -Ptests.seed=DEADBEEF
There are a lot of other test randomization properties
available. To list them, their defaults and current values
-run the testOpts task against a project that has tests.
+run the 'buildOptions' task against a project that has tests.
For example:
-gradlew -p lucene/core testOpts
+gradlew -p lucene/core buildOptions
+
+or list all options with:
+
+gradlew allOptions
Filtering
diff --git a/lucene/analysis/common/build.gradle b/lucene/analysis/common/build.gradle
index fa99f6383f5..85328c3ed7c 100644
--- a/lucene/analysis/common/build.gradle
+++ b/lucene/analysis/common/build.gradle
@@ -92,7 +92,7 @@ def cloningTasks = dictionaryProjects.collect { repoSpec ->
workingDir dotGitPath.getParent().toString()
args = cmdArgs
- // An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
+ // An explicit GIT_DIR to prevent .git upward scanning.
environment("GIT_DIR", dotGitPath.toString())
}
}
diff --git a/lucene/distribution/build.gradle b/lucene/distribution/build.gradle
index b5a056450f9..a0f4ca8983e 100644
--- a/lucene/distribution/build.gradle
+++ b/lucene/distribution/build.gradle
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+
+import org.apache.lucene.gradle.plugins.gitinfo.GitInfoExtension
+
import java.nio.charset.StandardCharsets
import java.nio.file.Files
@@ -33,7 +36,8 @@ ext {
}
// Collect git revision.
-MapProperty<String, String> gitStatus = rootProject.extensions.getByName("gitinfo").getGitInfo()
+GitInfoExtension gitInfoExt = rootProject.extensions.getByName("gitinfo")
+MapProperty<String, String> gitStatus = gitInfoExt.getGitInfo()
Provider<String> gitRev = gitStatus.getting("git.commit")
// Prepare the "source" distribution artifact. We use raw git export, no additional complexity needed.
@@ -51,7 +55,7 @@ tasks.register("assembleSourceTgz", {
workingDir = project.rootDir
// An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
- environment("GIT_DIR", dotGitPath.toString())
+ environment("GIT_DIR", gitInfoExt.getDotGitDir().get().asFile)
args += [
"archive",