Skip to content

Commit 5638a8d

Browse files
authored
Fix deprecated Gradle API usage scheduled to be removed in Gradle 9.0 (#14781)
With Gradle 9.0 approaching soon, this fixes incompatibilities with Gradle 9.0 by fixing two types of deprecated api usage in the build logic: 1. The org.gradle.api.plugins.JavaPluginConvention type has been deprecated 2. The Project.exec(Closure) method has been deprecated.
1 parent 0bbaf70 commit 5638a8d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class ChangesToHtmlTask extends DefaultTask {
6868
@InputFile
6969
def script
7070

71+
private ExecOperations execOperations;
72+
73+
@Inject
74+
ChangesToHtmlTask(ExecOperations execOperations) {
75+
this.execOperations = execOperations
76+
}
77+
7178
def loadVersions(File outfile) {
7279
// load version properties from DOAP RDF
7380
def prefix = "doap.${productName}".toString()
@@ -80,7 +87,7 @@ class ChangesToHtmlTask extends DefaultTask {
8087

8188
def toHtml(File versionsFile) {
8289
def output = new ByteArrayOutputStream()
83-
def result = project.exec {
90+
def result = execOperations.exec {
8491
executable project.externalTool("perl")
8592
standardInput = changesFile.newInputStream()
8693
standardOutput = project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()

build-tools/build-infra/src/main/groovy/lucene.java.jar-manifest.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ tasks.withType(Jar).configureEach { task ->
4646
}
4747
}
4848

49+
def javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension)
4950
def manifestAttrs = [
5051
"Extension-Name" : implementationTitle,
5152

@@ -58,8 +59,8 @@ tasks.withType(Jar).configureEach { task ->
5859
"Specification-Title" : title,
5960

6061
// Evaluate these properties lazily so that the defaults are applied properly.
61-
"X-Compile-Source-JDK" : "${-> project.sourceCompatibility}",
62-
"X-Compile-Target-JDK" : "${-> project.targetCompatibility}",
62+
"X-Compile-Source-JDK" : "${-> javaPluginExtension.getSourceCompatibility().toString() }",
63+
"X-Compile-Target-JDK" : "${-> javaPluginExtension.getTargetCompatibility().toString() }",
6364

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

build-tools/build-infra/src/main/groovy/lucene.root-project.setup.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ ext.externalTool = { String name ->
165165
throw new GradleException("External tool named '${name}' is not defined.")
166166
}
167167

168+
169+
interface InjectedExec {
170+
@Inject ExecOperations getOps()
171+
}
172+
168173
// TODO: These utility methods should be moved somewhere else or removed.
169174
allprojects {
170175
ext {
@@ -192,7 +197,8 @@ allprojects {
192197
}
193198
}
194199

195-
result = project.exec { ExecSpec execSpec ->
200+
def injected = project.objects.newInstance(InjectedExec)
201+
result = injected.ops.exec { ExecSpec execSpec ->
196202
project.configure(execSpec, closure)
197203

198204
saveIgnoreExitValue = execSpec.ignoreExitValue

0 commit comments

Comments
 (0)