Skip to content

Commit 0d0a7ab

Browse files
SOLR-18289: Build: upgrade Gradle to 9.6.0 (#4539)
- `gradle-wrapper.properties`, `libs.versions.toml` — bump Gradle 8.10 → 9.6.0; Lucene already completed this same migration, making the path well-trodden - `globals.gradle`, `changes-to-html.gradle`, `check-broken-links.gradle`, `javacc.gradle`, `docker/build.gradle` — `Project.exec`/`javaexec` removed in Gradle 9; inject `ExecOperations` via holder pattern (same approach already used in `globals.gradle`); docker tasks use minimal injection to avoid script-local scoping issues with typed task classes - `gradle-archives.gradle`, `jar-manifest.gradle`, `javac.gradle`, `packaging.gradle`, `defaults-maven.gradle`, `build.gradle`, `jwt-auth/build.gradle` — remaining Gradle 9 API migrations: `archivesBaseName` → `base { archivesName }`, `sourceCompatibility`/`targetCompatibility` under `java {}`, archive/copy file modes → `dirPermissions`/`filePermissions`, `dependencyProject` → `project(dep.path)`, drop forbidden `setCanBeConsumed(true)` on resolvable config, `webAppDirName` → `from("web")` - `rat-sources.gradle` — resolve RAT classpath at configuration time; Gradle 9 forbids configuration resolution at execution time; also add explicit `import groovy.xml.XmlParser` for Groovy 4 compatibility - `render-javadoc.gradle` — make `findRenderTasksInDependencies()` non-private; Groovy 4 dispatch on decorated task instances requires it - `dependency-analyze.gradle` — removed; `ca.cutterslade.analyze` has no Gradle-9-compatible release and produces false-positive failures with dependency locking; adopting a replacement is a separate follow-up (matches Lucene main) - `netty-tcnative-*` license sha1 files — align pin 2.0.75 → 2.0.77 to match version forced by the netty BOM, resolving the two-version conflict
1 parent 872bdc9 commit 0d0a7ab

64 files changed

Lines changed: 1199 additions & 1186 deletions

File tree

Some content is hidden

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

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ plugins {
2323
id 'solr.build-infra'
2424

2525
alias(libs.plugins.owasp.dependencycheck)
26-
alias(libs.plugins.cutterslade.analyze)
2726
alias(libs.plugins.benmanes.versions)
2827
alias(libs.plugins.kotlin.multiplatform) apply false
2928
alias(libs.plugins.littlerobots.versioncatalogupdate) apply false
@@ -173,7 +172,6 @@ apply from: file('gradle/validation/git-status.gradle')
173172
apply from: file('gradle/validation/validate-source-patterns.gradle')
174173
apply from: file('gradle/validation/rat-sources.gradle')
175174
apply from: file('gradle/validation/owasp-dependency-check.gradle')
176-
apply from: file('gradle/validation/dependency-analyze.gradle')
177175
apply from: file('gradle/validation/ecj-lint.gradle')
178176
apply from: file('gradle/validation/gradlew-scripts-tweaked.gradle')
179177
apply from: file('gradle/validation/validate-log-calls.gradle')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
2+
title: The build now uses Gradle 9.6.0 (upgraded from 8.10).
3+
type: other
4+
authors:
5+
- name: Serhiy Bzhezytskyy
6+
links:
7+
- name: SOLR-18289
8+
url: https://issues.apache.org/jira/browse/SOLR-18289

gradle.lockfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This is a Gradle generated file for dependency locking.
22
# Manual edits can break the build and are not advised.
33
# This file is expected to be part of source control.
4+
# To regenerate this file, run: ./gradlew :dependencies --write-locks
45
commons-cli:commons-cli:1.5.0=ratDeps
56
commons-io:commons-io:2.11.0=ratDeps
67
junit:junit:3.8.1=javacc

gradle/documentation/changes-to-html.gradle

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

18+
import org.gradle.process.ExecOperations
19+
import javax.inject.Inject
20+
1821
def resources = scriptResources(buildscript)
1922

2023
configure(project(':solr:documentation')) {
@@ -37,7 +40,10 @@ configure(project(':solr:documentation')) {
3740
}
3841

3942
// compile CHANGELOG.md into an html file
40-
class ChangesToHtmlTask extends DefaultTask {
43+
abstract class ChangesToHtmlTask extends DefaultTask {
44+
45+
@Inject
46+
abstract ExecOperations getExecOperations()
4147

4248
@Internal
4349
Project productProject = project.parent
@@ -67,7 +73,7 @@ class ChangesToHtmlTask extends DefaultTask {
6773
return
6874
}
6975

70-
def result = project.exec {
76+
def result = execOperations.exec {
7177
executable "python3"
7278
standardOutput project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()
7379
errorOutput = output

gradle/documentation/render-javadoc.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ configure(subprojects) {
196196
task
197197
.project
198198
.configurations.implementation.allDependencies.withType(ProjectDependency).collect {dep ->
199-
def otherProject = dep.dependencyProject
199+
def otherProject = task.project.project(dep.path)
200200
return otherProject.tasks.findByName(task.name)
201201
}.findAll {
202202
// Do not depend on disabled tasks or tasks that do not exist
@@ -294,7 +294,7 @@ class RenderJavadocTask extends DefaultTask {
294294
File taskResources
295295

296296
/** Utility method to recursively collect all tasks with same name like this one that we depend on */
297-
private Set findRenderTasksInDependencies() {
297+
Set findRenderTasksInDependencies() {
298298
Set found = []
299299
def collectDeps
300300
collectDeps = {task ->

gradle/generation/javacc.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import java.nio.charset.Charset
2+
import org.gradle.process.ExecOperations
3+
import javax.inject.Inject
24

35
/*
46
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -116,7 +118,10 @@ configure(project(":solr:core")) {
116118
}
117119

118120
// We always regenerate, no need to declare outputs.
119-
class JavaCCTask extends DefaultTask {
121+
abstract class JavaCCTask extends DefaultTask {
122+
@Inject
123+
abstract ExecOperations getExecOperations()
124+
120125
@InputFile
121126
File javaccFile
122127

@@ -164,7 +169,7 @@ class JavaCCTask extends DefaultTask {
164169
logger.lifecycle("Recompiling JavaCC: ${project.rootDir.relativePath(javaccFile)}")
165170

166171
def output = new ByteArrayOutputStream()
167-
def result = project.javaexec {
172+
def result = execOperations.javaexec {
168173
classpath {
169174
project.rootProject.configurations.javacc
170175
}

gradle/globals.gradle

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

18+
import javax.inject.Inject
19+
import org.gradle.process.ExecOperations
20+
21+
interface ExecOperationsHolder {
22+
@Inject
23+
ExecOperations getExecOperations()
24+
}
25+
1826
allprojects {
1927
apply plugin: 'base'
2028

@@ -35,10 +43,12 @@ allprojects {
3543

3644
// Artifacts will have names after full gradle project path
3745
// so :solr:core will have solr-core.jar, etc.
38-
project.archivesBaseName = project.path
39-
.replaceAll("^:", "")
40-
.replace(':', '-')
41-
.replace("-modules-", "-")
46+
project.base {
47+
archivesName = project.path
48+
.replaceAll("^:", "")
49+
.replace(':', '-')
50+
.replace("-modules-", "-")
51+
}
4252

4353
project.ext {
4454
// Utility method to support passing overrides via -P or -D.
@@ -110,7 +120,8 @@ allprojects {
110120
}
111121
}
112122

113-
result = project.exec {ExecSpec execSpec ->
123+
def execOps = project.objects.newInstance(ExecOperationsHolder).execOperations
124+
result = execOps.exec {ExecSpec execSpec ->
114125
project.configure(execSpec, closure)
115126

116127
saveIgnoreExitValue = execSpec.ignoreExitValue

gradle/hacks/gradle-archives.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ allprojects {
2020
tasks.withType(AbstractArchiveTask).configureEach {task ->
2121
duplicatesStrategy = DuplicatesStrategy.FAIL
2222
reproducibleFileOrder = true
23-
dirMode = 0755
24-
fileMode = 0644
23+
dirPermissions { unix("0755") }
24+
filePermissions { unix("0644") }
2525
}
2626
}

gradle/java/jar-manifest.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ subprojects {
6363
"Specification-Title": title,
6464

6565
// Evaluate these properties lazily so that the defaults are applied properly.
66-
"X-Compile-Source-JDK": "${-> project.sourceCompatibility}",
67-
"X-Compile-Target-JDK": "${-> project.targetCompatibility}",
66+
"X-Compile-Source-JDK": "${-> project.java.sourceCompatibility}",
67+
"X-Compile-Target-JDK": "${-> project.java.targetCompatibility}",
6868

6969
"X-Build-JDK": "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
7070
"X-Build-OS": "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"

gradle/java/javac.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
allprojects {
2121
plugins.withType(JavaPlugin) {
22-
sourceCompatibility = project.minJavaVersion
23-
targetCompatibility = project.minJavaVersion
22+
java {
23+
sourceCompatibility = project.minJavaVersion
24+
targetCompatibility = project.minJavaVersion
25+
}
2426
// Use 'release' flag instead of 'source' and 'target'
2527
tasks.withType(JavaCompile) {
2628
compileTestJava {

0 commit comments

Comments
 (0)