Skip to content

Commit 9b8b9fd

Browse files
authored
Update Gradle to 8.11 (#16386)
Signed-off-by: Andriy Redko <[email protected]>
1 parent ac44300 commit 9b8b9fd

File tree

9 files changed

+59
-20
lines changed

9 files changed

+59
-20
lines changed

build.gradle

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,20 @@ Map<String, String> buildMetadataMap = buildMetadataValue.tokenize(';').collectE
162162
return [key, value]
163163
}
164164

165-
/**
166-
* Using 'git' command line (if available), tries to fetch the commit date of the current revision
167-
* @return commit date of the current revision or 0 if it is not available
168-
*/
165+
// See please https://docs.gradle.org/8.11/userguide/service_injection.html#execoperations
166+
interface InjectedExecOps {
167+
@Inject ExecOperations getExecOps()
168+
}
169+
170+
/**
171+
* Using 'git' command line (if available), tries to fetch the commit date of the current revision
172+
* @return commit date of the current revision or 0 if it is not available
173+
*/
169174
long gitRevisionDate = {
175+
def execOps = project.objects.newInstance(InjectedExecOps)
170176
// Try to get last commit date as Unix timestamp
171177
try (ByteArrayOutputStream stdout = new ByteArrayOutputStream()) {
172-
ExecResult result = project.exec(spec -> {
178+
ExecResult result = execOps.execOps.exec(spec -> {
173179
spec.setIgnoreExitValue(true);
174180
spec.setStandardOutput(stdout);
175181
spec.commandLine("git", "log", "-1", "--format=%ct");
@@ -362,7 +368,7 @@ allprojects {
362368
if ((dep instanceof ProjectDependency) == false) {
363369
return
364370
}
365-
Project upstreamProject = dep.dependencyProject
371+
Project upstreamProject = project.project(dep.path)
366372
if (upstreamProject == null) {
367373
return
368374
}
@@ -438,7 +444,7 @@ gradle.projectsEvaluated {
438444

439445
configurations.matching { it.canBeResolved }.all { Configuration configuration ->
440446
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
441-
Project upstreamProject = dep.dependencyProject
447+
Project upstreamProject = project.project(dep.path)
442448
if (upstreamProject != null) {
443449
if (project.path == upstreamProject.path) {
444450
// TODO: distribution integ tests depend on themselves (!), fix that

buildSrc/src/main/groovy/org/opensearch/gradle/test/TestWithDependenciesPlugin.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ class TestWithDependenciesPlugin implements Plugin<Project> {
5656

5757
project.configurations.testImplementation.dependencies.all { Dependency dep ->
5858
// this closure is run every time a compile dependency is added
59-
if (dep instanceof ProjectDependency && dep.dependencyProject.plugins.hasPlugin(PluginBuildPlugin)) {
60-
project.gradle.projectsEvaluated {
61-
addPluginResources(project, dep.dependencyProject)
59+
if (dep instanceof ProjectDependency) {
60+
Project dependencyProject = project.project(((ProjectDependency)dep).path)
61+
if (dependencyProject.plugins.hasPlugin(PluginBuildPlugin)) {
62+
project.gradle.projectsEvaluated {
63+
addPluginResources(project, dependencyProject)
64+
}
6265
}
6366
}
6467
}

buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class LoggedExec extends Exec implements FileSystemOperationsAware {
7171
private Consumer<Logger> outputLogger;
7272
private FileSystemOperations fileSystemOperations;
7373

74+
interface InjectedExecOps {
75+
@Inject
76+
ExecOperations getExecOps();
77+
}
78+
7479
@Inject
7580
public LoggedExec(FileSystemOperations fileSystemOperations) {
7681
this.fileSystemOperations = fileSystemOperations;
@@ -133,15 +138,17 @@ public void setSpoolOutput(boolean spoolOutput) {
133138
}
134139

135140
public static ExecResult exec(Project project, Action<ExecSpec> action) {
136-
return genericExec(project::exec, action);
141+
final InjectedExecOps execOps = project.getObjects().newInstance(InjectedExecOps.class);
142+
return exec(execOps.getExecOps(), action);
137143
}
138144

139145
public static ExecResult exec(ExecOperations execOperations, Action<ExecSpec> action) {
140146
return genericExec(execOperations::exec, action);
141147
}
142148

143149
public static ExecResult javaexec(Project project, Action<JavaExecSpec> action) {
144-
return genericExec(project::javaexec, action);
150+
final InjectedExecOps execOps = project.getObjects().newInstance(InjectedExecOps.class);
151+
return genericExec(execOps.getExecOps()::javaexec, action);
145152
}
146153

147154
/** Returns JVM arguments suitable for a short-lived forked task */

buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public String call() throws Exception {
121121
Node dependencyNode = dependenciesNode.appendNode("dependency");
122122
dependencyNode.appendNode("groupId", dependency.getGroup());
123123
ProjectDependency projectDependency = (ProjectDependency) dependency;
124-
String artifactId = getArchivesBaseName(projectDependency.getDependencyProject());
124+
String artifactId = getArchivesBaseName(project.project(projectDependency.getPath()));
125125
dependencyNode.appendNode("artifactId", artifactId);
126126
dependencyNode.appendNode("version", dependency.getVersion());
127127
dependencyNode.appendNode("scope", "compile");

buildSrc/src/main/java/org/opensearch/gradle/precommit/ThirdPartyAuditTask.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@
6060
import org.gradle.api.tasks.PathSensitivity;
6161
import org.gradle.api.tasks.SkipWhenEmpty;
6262
import org.gradle.api.tasks.TaskAction;
63+
import org.gradle.process.ExecOperations;
6364
import org.gradle.process.ExecResult;
6465

66+
import javax.inject.Inject;
67+
6568
import java.io.ByteArrayOutputStream;
6669
import java.io.File;
6770
import java.io.IOException;
@@ -108,6 +111,11 @@ public class ThirdPartyAuditTask extends DefaultTask {
108111

109112
public boolean jarHellEnabled = true;
110113

114+
interface InjectedExecOps {
115+
@Inject
116+
ExecOperations getExecOps();
117+
}
118+
111119
@Input
112120
public Property<JavaVersion> getTargetCompatibility() {
113121
return targetCompatibility;
@@ -357,7 +365,8 @@ private String formatClassList(Set<String> classList) {
357365

358366
private String runForbiddenAPIsCli() throws IOException {
359367
ByteArrayOutputStream errorOut = new ByteArrayOutputStream();
360-
ExecResult result = getProject().javaexec(spec -> {
368+
InjectedExecOps execOps = getProject().getObjects().newInstance(InjectedExecOps.class);
369+
ExecResult result = execOps.getExecOps().javaexec(spec -> {
361370
if (javaHome != null) {
362371
spec.setExecutable(javaHome + "/bin/java");
363372
}
@@ -391,7 +400,8 @@ private String runForbiddenAPIsCli() throws IOException {
391400

392401
private Set<String> runJdkJarHellCheck() throws IOException {
393402
ByteArrayOutputStream standardOut = new ByteArrayOutputStream();
394-
ExecResult execResult = getProject().javaexec(spec -> {
403+
InjectedExecOps execOps = getProject().getObjects().newInstance(InjectedExecOps.class);
404+
ExecResult execResult = execOps.getExecOps().javaexec(spec -> {
395405
spec.classpath(
396406
jdkJarHellClasspath,
397407
getRuntimeConfiguration(),

gradle/missing-javadoc.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
import javax.annotation.Nullable
11+
import javax.inject.Inject
1112
import org.gradle.api.tasks.PathSensitive;
1213
import org.gradle.api.tasks.PathSensitivity;
1314
import org.gradle.internal.jvm.Jvm
@@ -227,6 +228,11 @@ class MissingJavadocTask extends DefaultTask {
227228
@PathSensitive(PathSensitivity.RELATIVE)
228229
def taskResources
229230

231+
// See please https://docs.gradle.org/8.11/userguide/service_injection.html#execoperations
232+
interface InjectedExecOps {
233+
@Inject ExecOperations getExecOps()
234+
}
235+
230236
/** Utility method to recursively collect all tasks with same name like this one that we depend on */
231237
private Set findRenderTasksInDependencies() {
232238
Set found = []
@@ -317,11 +323,12 @@ class MissingJavadocTask extends DefaultTask {
317323
}
318324
}()
319325

326+
def execOps = project.objects.newInstance(InjectedExecOps)
320327
def outputFile = project.file("${getTemporaryDir()}/javadoc-output.txt")
321328
def result
322329

323330
outputFile.withOutputStream { output ->
324-
result = project.exec {
331+
result = execOps.execOps.exec {
325332
executable javadocCmd
326333

327334
// we want to capture both stdout and stderr to the same

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
distributionBase=GRADLE_USER_HOME
1313
distributionPath=wrapper/dists
14-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
14+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip
1515
zipStoreBase=GRADLE_USER_HOME
1616
zipStorePath=wrapper/dists
17-
distributionSha256Sum=2ab88d6de2c23e6adae7363ae6e29cbdd2a709e992929b48b6530fd0c7133bd6
17+
distributionSha256Sum=73d2d553933194d8eefed0a291acbe45392ca3572ba13834cbbf373da375276d

libs/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ subprojects {
4242
project.afterEvaluate {
4343
configurations.all { Configuration conf ->
4444
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
45-
Project depProject = dep.dependencyProject
45+
Project depProject = project.project(dep.path)
4646
if (depProject != null
4747
&& (false == depProject.path.equals(':libs:opensearch-core') &&
4848
false == depProject.path.equals(':libs:opensearch-common'))

modules/lang-painless/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,17 @@ testClusters {
115115
}
116116
}
117117

118+
interface InjectedExecOps {
119+
@Inject ExecOperations getExecOps()
120+
}
121+
122+
118123
tasks.register("generateContextDoc", DefaultTestClustersTask) {
119124
dependsOn sourceSets.doc.runtimeClasspath
120125
useCluster testClusters.generateContextCluster
121126
doFirst {
122-
project.javaexec {
127+
def execOps = project.objects.newInstance(InjectedExecOps)
128+
execOps.execOps.javaexec {
123129
mainClass = 'org.opensearch.painless.ContextDocGenerator'
124130
classpath = sourceSets.doc.runtimeClasspath
125131
systemProperty "cluster.uri", "${-> testClusters.generateContextCluster.singleNode().getAllHttpSocketURI().get(0)}"

0 commit comments

Comments
 (0)