Skip to content

Commit f305314

Browse files
authored
Fix assemble source release (#14800)
* Remove refs to the removed option: validation.git.failOnModified. * Fix regression in assembleSourceTgz #14796 * Use allOptions in gradle upgrade workflow. Remove references to testOpts. * Correct reference typo in jarInfoTasks. * mustRunAfter doesn't include a subgraph of dependencies of a task, have to list them explicitly. * Tidy.
1 parent dc8c3b5 commit f305314

File tree

9 files changed

+65
-12
lines changed

9 files changed

+65
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ jobs:
8585
git reset --hard && git clean -xfd .
8686
fi
8787
88-
- run: ./gradlew testOpts
88+
- run: ./gradlew allOptions
8989
- run: ./gradlew helpWorkflow
9090
- run: ./gradlew licenses updateLicenses
91-
- run: ./gradlew check -x test -Pvalidation.git.failOnModified=false
91+
- run: ./gradlew check -x test
9292
- run: ./gradlew assembleRelease mavenToLocal
9393

9494
# Conserve resources: only run these in non-alt-java mode.

build-tools/build-infra/src/main/groovy/lucene.documentation.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ configure(rootProject) {
2929
return null
3030
} else {
3131
// release build
32-
return "https://lucene.apache.org/core/${urlVersion}"
32+
return "https://lucene.apache.org/core/${urlVersion}".toString()
3333
}
3434
})
3535

build-tools/build-infra/src/main/groovy/lucene.validation.jar-checks.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ configure(project(":lucene")) {
297297
def updateLicenses = tasks.register("updateLicenses", {
298298
group = 'Dependency validation'
299299
description = "Write or update checksums of dependencies. May need to run gradlew --write-locks first if changing dependency versions"
300-
dependsOn "jarInfoTasks"
300+
dependsOn jarInfoTasks
301301

302302
doLast {
303303
licensesDir.asFile.mkdirs()
@@ -334,7 +334,13 @@ configure(project(":lucene")) {
334334
// We add an ordering constraint that any validation task (or its dependency subgraph)
335335
// must run after updateLicenses
336336
configure(subprojects) {
337-
tasks.matching { it.name == "licenses" }.configureEach {
337+
tasks.matching {
338+
it.name in [
339+
"licenses",
340+
"validateJarChecksums",
341+
"validateJarLicenses"
342+
]
343+
}.configureEach {
338344
mustRunAfter updateLicenses
339345
}
340346
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
package org.apache.lucene.gradle.plugins.gitinfo;
22

3+
import org.gradle.api.file.FileSystemLocation;
34
import org.gradle.api.provider.MapProperty;
5+
import org.gradle.api.provider.Property;
46

57
public abstract class GitInfoExtension {
68
public static final String NAME = "gitinfo";
79

10+
/**
11+
* @return Return a map of key-value pairs extracted from the current git status.
12+
*/
813
public abstract MapProperty<String, String> getGitInfo();
14+
15+
/**
16+
* @return Return the location of {@code .git} directory (or file, if worktrees are used).
17+
*/
18+
public abstract Property<FileSystemLocation> getDotGitDir();
919
}

build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/gitinfo/GitInfoPlugin.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.apache.lucene.gradle.plugins.gitinfo;
22

3+
import java.nio.file.Files;
4+
import java.nio.file.Path;
35
import org.gradle.api.GradleException;
46
import org.gradle.api.Plugin;
57
import org.gradle.api.Project;
8+
import org.gradle.api.file.Directory;
69

710
public class GitInfoPlugin implements Plugin<Project> {
811
@Override
@@ -24,5 +27,33 @@ public void apply(Project project) {
2427
project.getExtensions().create(GitInfoExtension.NAME, GitInfoExtension.class);
2528

2629
gitInfoExtension.getGitInfo().value(gitInfoProvider).finalizeValueOnRead();
30+
31+
gitInfoExtension
32+
.getDotGitDir()
33+
.convention(
34+
project
35+
.getProviders()
36+
.provider(
37+
() -> {
38+
Directory projectDirectory =
39+
project.getRootProject().getLayout().getProjectDirectory();
40+
Path gitLocation = projectDirectory.getAsFile().toPath().resolve(".git");
41+
if (!Files.exists(gitLocation)) {
42+
throw new GradleException(
43+
"Can't locate .git (probably not a git clone?): "
44+
+ gitLocation.toAbsolutePath());
45+
}
46+
47+
if (Files.isDirectory(gitLocation)) {
48+
return projectDirectory.dir(".git");
49+
} else if (Files.isRegularFile(gitLocation)) {
50+
return projectDirectory.file(".git");
51+
} else {
52+
throw new GradleException(
53+
"Panic, .git location not a directory or file: "
54+
+ gitLocation.toAbsolutePath());
55+
}
56+
}))
57+
.finalizeValueOnRead();
2758
}
2859
}

dev-tools/scripts/buildAndPushRelease.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ def prepare(root: str, version: str, pause_before_sign: bool, gpg_key_id: str |
130130

131131
print(" prepare-release")
132132
cmd = "./gradlew --stacktrace --no-daemon assembleRelease -Dversion.release=%s" % version
133-
if dev_mode:
134-
cmd += " -Pvalidation.git.failOnModified=false"
135133
if gpg_key_id is not None:
136134
cmd += " -Psign --max-workers 2"
137135
if sign_gradle:

help/tests.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ gradlew :lucene:misc:test -Ptests.seed=DEADBEEF
4242

4343
There are a lot of other test randomization properties
4444
available. To list them, their defaults and current values
45-
run the testOpts task against a project that has tests.
45+
run the 'buildOptions' task against a project that has tests.
4646
For example:
4747

48-
gradlew -p lucene/core testOpts
48+
gradlew -p lucene/core buildOptions
49+
50+
or list all options with:
51+
52+
gradlew allOptions
4953

5054

5155
Filtering

lucene/analysis/common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def cloningTasks = dictionaryProjects.collect { repoSpec ->
9292
workingDir dotGitPath.getParent().toString()
9393
args = cmdArgs
9494

95-
// An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
95+
// An explicit GIT_DIR to prevent .git upward scanning.
9696
environment("GIT_DIR", dotGitPath.toString())
9797
}
9898
}

lucene/distribution/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
19+
import org.apache.lucene.gradle.plugins.gitinfo.GitInfoExtension
20+
1821
import java.nio.charset.StandardCharsets
1922
import java.nio.file.Files
2023

@@ -33,7 +36,8 @@ ext {
3336
}
3437

3538
// Collect git revision.
36-
MapProperty<String, String> gitStatus = rootProject.extensions.getByName("gitinfo").getGitInfo()
39+
GitInfoExtension gitInfoExt = rootProject.extensions.getByName("gitinfo")
40+
MapProperty<String, String> gitStatus = gitInfoExt.getGitInfo()
3741
Provider<String> gitRev = gitStatus.getting("git.commit")
3842

3943
// Prepare the "source" distribution artifact. We use raw git export, no additional complexity needed.
@@ -51,7 +55,7 @@ tasks.register("assembleSourceTgz", {
5155
workingDir = project.rootDir
5256

5357
// An explicit GIT_DIR to prevent .git upward scanning if something goes wrong.
54-
environment("GIT_DIR", dotGitPath.toString())
58+
environment("GIT_DIR", gitInfoExt.getDotGitDir().get().asFile)
5559

5660
args += [
5761
"archive",

0 commit comments

Comments
 (0)