Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle to 8.12 #16884

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ subprojects {
name = 'Snapshots'
url = 'https://aws.oss.sonatype.org/content/repositories/snapshots'
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
username = "$System.env.SONATYPE_USERNAME"
password = "$System.env.SONATYPE_PASSWORD"
}
}
}
Expand Down Expand Up @@ -420,7 +420,7 @@ allprojects {
gradle.projectsEvaluated {
allprojects {
project.tasks.withType(JavaForkOptions) {
maxHeapSize project.property('options.forkOptions.memoryMaximumSize')
maxHeapSize = project.property('options.forkOptions.memoryMaximumSize')
}

if (project.path == ':test:framework') {
Expand Down Expand Up @@ -736,7 +736,7 @@ tasks.named(JavaBasePlugin.CHECK_TASK_NAME) {
}

tasks.register('checkCompatibility', CheckCompatibilityTask) {
description('Checks the compatibility with child components')
description = 'Checks the compatibility with child components'
}

allprojects { project ->
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ dependencies {
api "org.apache.commons:commons-compress:${props.getProperty('commonscompress')}"
api 'org.apache.ant:ant:1.10.14'
api 'com.netflix.nebula:gradle-extra-configurations-plugin:10.0.0'
api 'com.netflix.nebula:nebula-publishing-plugin:21.0.0'
api 'com.netflix.nebula:nebula-publishing-plugin:21.1.0'
api 'com.netflix.nebula:gradle-info-plugin:12.1.6'
api 'org.apache.rat:apache-rat:0.15'
api "commons-io:commons-io:${props.getProperty('commonsio')}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
package org.opensearch.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileTree
import org.gradle.api.file.SourceDirectorySet
Expand All @@ -39,6 +40,8 @@
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

import javax.inject.Inject

import java.nio.file.Files
import java.nio.file.attribute.PosixFilePermissions

Expand All @@ -58,8 +61,12 @@
/** Directories to include notices from */
private List<File> licensesDirs = new ArrayList<>()

NoticeTask() {
description = 'Create a notice file from dependencies'
private final Project project

@Inject
NoticeTask(Project project) {
this.project = project
this.description = 'Create a notice file from dependencies'

Check warning on line 69 in buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy#L68-L69

Added lines #L68 - L69 were not covered by tests
// Default licenses directory is ${projectDir}/licenses (if it exists)
File licensesDir = new File(project.projectDir, 'licenses')
if (licensesDir.exists()) {
Expand Down Expand Up @@ -161,11 +168,12 @@
@Optional
FileCollection getNoticeFiles() {
FileTree tree
def p = project

Check warning on line 171 in buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy#L171

Added line #L171 was not covered by tests
licensesDirs.each { dir ->
if (tree == null) {
tree = project.fileTree(dir)
tree = p.fileTree(dir)

Check warning on line 174 in buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy#L174

Added line #L174 was not covered by tests
} else {
tree += project.fileTree(dir)
tree += p.fileTree(dir)

Check warning on line 176 in buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/NoticeTask.groovy#L176

Added line #L176 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@
archiveBaseName = archiveBaseName.get() + "-client"
}
// always configure publishing for client jars
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name + "-client")
project.publishing.publications.nebula(MavenPublication).artifactId = extension.name + "-client"

Check warning on line 163 in buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy#L163

Added line #L163 was not covered by tests
final BasePluginExtension base = project.getExtensions().findByType(BasePluginExtension.class)
project.tasks.withType(GenerateMavenPom.class).configureEach { GenerateMavenPom generatePOMTask ->
generatePOMTask.destination = "${project.buildDir}/distributions/${base.archivesName}-client-${project.versions.opensearch}.pom"
}
} else {
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name)
project.publishing.publications.nebula(MavenPublication).artifactId = extension.name

Check warning on line 170 in buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy#L170

Added line #L170 was not covered by tests
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.rat.anttasks.SubstringLicenseMatcher
import org.apache.rat.license.SimpleLicenseFamily
import org.opensearch.gradle.AntTask
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
Expand All @@ -41,6 +42,8 @@
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.SkipWhenEmpty

import javax.inject.Inject

import java.nio.file.Files

/**
Expand All @@ -65,14 +68,18 @@
@Input
List<String> excludes = []

private final Project project

/**
* Additional license families that may be found. The key is the license category name (5 characters),
* followed by the family name and the value list of patterns to search for.
*/
protected Map<String, String> additionalLicenses = new HashMap<>()

LicenseHeadersTask() {
description = "Checks sources for missing, incorrect, or unacceptable license headers"
@Inject
LicenseHeadersTask(Project project) {
this.project = project
this.description = "Checks sources for missing, incorrect, or unacceptable license headers"

Check warning on line 82 in buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/precommit/LicenseHeadersTask.groovy#L81-L82

Added lines #L81 - L82 were not covered by tests
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@
package org.opensearch.gradle.test

import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.Project
import org.gradle.api.GradleException
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskProvider
import org.opensearch.gradle.AntTask
import org.opensearch.gradle.LoggedExec

import javax.inject.Inject

/**
* A fixture for integration tests which runs in a separate process launched by Ant.
*/
Expand Down Expand Up @@ -90,9 +94,12 @@
}

private final TaskProvider stopTask
private final Project project

AntFixture() {
stopTask = createStopTask()
@Inject
AntFixture(Project project) {
this.project = project

Check warning on line 101 in buildSrc/src/main/groovy/org/opensearch/gradle/test/AntFixture.groovy

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/groovy/org/opensearch/gradle/test/AntFixture.groovy#L101

Added line #L101 was not covered by tests
this.stopTask = createStopTask()
finalizedBy(stopTask)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package org.opensearch.gradle;

import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
Expand All @@ -48,6 +49,12 @@

private File dir;
private int dirMode = 0755;
private final Project project;

@Inject
public EmptyDirTask(Project project) {
this.project = project;
}

/**
* Creates an empty directory with the configured permissions.
Expand Down Expand Up @@ -84,7 +91,7 @@
* @param dir The path of the directory to create. Takes a String and coerces it to a file.
*/
public void setDir(String dir) {
this.dir = getProject().file(dir);
this.dir = project.file(dir);

Check warning on line 94 in buildSrc/src/main/java/org/opensearch/gradle/EmptyDirTask.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/EmptyDirTask.java#L94

Added line #L94 was not covered by tests
}

@Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
Expand All @@ -42,6 +43,8 @@
import org.gradle.api.tasks.StopExecutionException;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -67,8 +70,9 @@

private DirectoryProperty outputDir;

public ExportOpenSearchBuildResourcesTask() {
outputDir = getProject().getObjects().directoryProperty();
@Inject
public ExportOpenSearchBuildResourcesTask(Project project) {
outputDir = project.getObjects().directoryProperty();

Check warning on line 75 in buildSrc/src/main/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/ExportOpenSearchBuildResourcesTask.java#L74-L75

Added lines #L74 - L75 were not covered by tests
}

@OutputDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@
private static final Logger LOGGER = Logging.getLogger(LoggedExec.class);
private Consumer<Logger> outputLogger;
private FileSystemOperations fileSystemOperations;
private final Project project;

interface InjectedExecOps {
@Inject
ExecOperations getExecOps();
}

@Inject
public LoggedExec(FileSystemOperations fileSystemOperations) {
public LoggedExec(FileSystemOperations fileSystemOperations, Project project) {

Check warning on line 81 in buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L81 was not covered by tests
this.fileSystemOperations = fileSystemOperations;
this.project = project;

Check warning on line 83 in buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L83 was not covered by tests
if (getLogger().isInfoEnabled() == false) {
setIgnoreExitValue(true);
setSpoolOutput(false);
Expand Down Expand Up @@ -111,7 +113,7 @@
public void setSpoolOutput(boolean spoolOutput) {
final OutputStream out;
if (spoolOutput) {
File spoolFile = new File(getProject().getBuildDir() + "/buffered-output/" + this.getName());
File spoolFile = new File(project.getBuildDir() + "/buffered-output/" + this.getName());

Check warning on line 116 in buildSrc/src/main/java/org/opensearch/gradle/LoggedExec.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L116 was not covered by tests
out = new LazyFileOutputStream(spoolFile);
outputLogger = logger -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.opensearch.gradle.LoggedExec;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.logging.Logger;
Expand All @@ -60,18 +61,22 @@
private static final Logger LOGGER = Logging.getLogger(DockerBuildTask.class);

private final WorkerExecutor workerExecutor;
private final RegularFileProperty markerFile = getProject().getObjects().fileProperty();
private final DirectoryProperty dockerContext = getProject().getObjects().directoryProperty();
private final RegularFileProperty markerFile;
private final DirectoryProperty dockerContext;

private String[] tags;
private boolean pull = true;
private boolean noCache = true;
private String[] baseImages;
private final Project project;

@Inject
public DockerBuildTask(WorkerExecutor workerExecutor) {
public DockerBuildTask(WorkerExecutor workerExecutor, Project project) {

Check warning on line 74 in buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java#L74

Added line #L74 was not covered by tests
this.workerExecutor = workerExecutor;
this.markerFile.set(getProject().getLayout().getBuildDirectory().file("markers/" + this.getName() + ".marker"));
this.project = project;
this.markerFile = project.getObjects().fileProperty();
this.dockerContext = project.getObjects().directoryProperty();
this.markerFile.set(project.getLayout().getBuildDirectory().file("markers/" + this.getName() + ".marker"));

Check warning on line 79 in buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/docker/DockerBuildTask.java#L76-L79

Added lines #L76 - L79 were not covered by tests
}

@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Project;
import org.gradle.api.file.FileCollection;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
Expand All @@ -48,6 +49,8 @@
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -127,7 +130,7 @@
/**
* The directory to find the license and sha files in.
*/
private File licensesDir = new File(getProject().getProjectDir(), "licenses");
private File licensesDir;

/**
* A map of patterns to prefix, used to find the LICENSE and NOTICE file.
Expand All @@ -139,6 +142,14 @@
*/
private Set<String> ignoreShas = new HashSet<>();

private final Project project;

@Inject
public DependencyLicensesTask(Project project) {
this.project = project;
this.licensesDir = new File(project.getProjectDir(), "licenses");
}

/**
* Add a mapping from a regex pattern for the jar name, to a prefix to find
* the LICENSE and NOTICE file for that jar.
Expand All @@ -161,7 +172,7 @@
@InputFiles
public Property<FileCollection> getDependencies() {
if (dependenciesProvider == null) {
dependenciesProvider = getProject().getObjects().property(FileCollection.class);
dependenciesProvider = project.getObjects().property(FileCollection.class);
}
return dependenciesProvider;
}
Expand Down Expand Up @@ -250,7 +261,7 @@
// by this output but when successful we can safely mark the task as up-to-date.
@OutputDirectory
public File getOutputMarker() {
return new File(getProject().getBuildDir(), "dependencyLicense");
return new File(project.getBuildDir(), "dependencyLicense");

Check warning on line 264 in buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java#L264

Added line #L264 was not covered by tests
}

private void failIfAnyMissing(String item, Boolean exists, String type) {
Expand Down
Loading
Loading