Skip to content

Commit

Permalink
Update to Gradle 8.2 (opensearch-project#8018)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored Jul 6, 2023
1 parent 431b246 commit a0da953
Show file tree
Hide file tree
Showing 34 changed files with 139 additions and 78 deletions.
10 changes: 8 additions & 2 deletions benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ import org.opensearch.gradle.info.BuildParams

apply plugin: 'opensearch.build'
apply plugin: 'application'
mainClassName = 'org.openjdk.jmh.Main'

assemble.enabled = false
archivesBaseName = 'opensearch-benchmarks'

application {
mainClass = 'org.openjdk.jmh.Main'
}

base {
archivesBaseName = 'opensearch-benchmarks'
}

test.enabled = false

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ allprojects {
javadoc.options.addStringOption('Xwerror', '-quiet')
}
javadoc.options.tags = ["opensearch.internal", "opensearch.api", "opensearch.experimental"]
javadoc.options.addStringOption("-release", targetCompatibility.majorVersion)
javadoc.options.addStringOption("-release", java.targetCompatibility.majorVersion)
}

// support for reproducible builds
Expand Down Expand Up @@ -375,7 +375,7 @@ allprojects {
} else {
// Link to non-shadowed dependant projects
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
String externalLinkName = upstreamProject.archivesBaseName
String externalLinkName = upstreamProject.base.archivesBaseName
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + externalLinkName.replaceAll('\\.', '/') + '/' + dep.version
String projectRelativePath = project.relativePath(upstreamProject.buildDir)
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${projectRelativePath}/docs/javadoc/"
Expand Down Expand Up @@ -452,7 +452,7 @@ gradle.projectsEvaluated {
testReportAggregation it
}
subprojects.findAll { it.pluginManager.hasPlugin('jacoco') }.forEach {
jacocoAggregation it
jacocoAggregation it
}
}
}
Expand Down
33 changes: 18 additions & 15 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.gradle.util.GradleVersion
plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'java-test-fixtures'
}

group = 'org.opensearch.gradle'
Expand Down Expand Up @@ -79,9 +78,17 @@ if (JavaVersion.current() < JavaVersion.VERSION_11) {
}

sourceSets {
test {
java {
srcDirs += ['src/testFixtures/java']
}
}
integTest {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
java {
srcDirs += ['src/testFixtures/java']
}
}
}

Expand Down Expand Up @@ -111,7 +118,7 @@ dependencies {
api 'org.apache.rat:apache-rat:0.15'
api 'commons-io:commons-io:2.13.0'
api "net.java.dev.jna:jna:5.13.0"
api 'gradle.plugin.com.github.johnrengelman:shadow:8.0.0'
api 'com.github.johnrengelman:shadow:8.1.1'
api 'org.jdom:jdom2:2.0.6.1'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${props.getProperty('kotlin')}"
api 'de.thetaphi:forbiddenapis:3.5.1'
Expand All @@ -124,10 +131,10 @@ dependencies {
api "com.fasterxml.jackson.core:jackson-databind:${props.getProperty('jackson_databind')}"
api "org.ajoberstar.grgit:grgit-core:5.2.0"

testFixturesApi "junit:junit:${props.getProperty('junit')}"
testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
testFixturesApi gradleApi()
testFixturesApi gradleTestKit()
testImplementation "junit:junit:${props.getProperty('junit')}"
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
testRuntimeOnly gradleApi()
testRuntimeOnly gradleTestKit()
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.35.0'
testImplementation "org.mockito:mockito-core:${props.getProperty('mockito')}"
integTestImplementation('org.spockframework:spock-core:2.3-groovy-3.0') {
Expand Down Expand Up @@ -164,8 +171,10 @@ if (project != rootProject) {
apply plugin: 'opensearch.publish'

allprojects {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}
}

// groovydoc succeeds, but has some weird internal exception...
Expand All @@ -174,7 +183,7 @@ if (project != rootProject) {
// build-tools is not ready for primetime with these...
tasks.named("dependencyLicenses").configure { it.enabled = false }
dependenciesInfo.enabled = false
disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures')
disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest')
jarHell.enabled = false
thirdPartyAudit.enabled = false
if (org.opensearch.gradle.info.BuildParams.inFipsJvm) {
Expand Down Expand Up @@ -241,12 +250,6 @@ if (project != rootProject) {
}
}

// disable fail-on-warnings for this specific task which trips Java 11 bug
// https://bugs.openjdk.java.net/browse/JDK-8209058
tasks.named("compileTestFixturesJava").configure {
options.compilerArgs -= '-Werror'
}

tasks.register("integTest", Test) {
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
systemProperty 'test.version_under_test', version
Expand Down
6 changes: 4 additions & 2 deletions buildSrc/reaper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

apply plugin: 'java'

targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

jar {
archiveFileName = "${project.name}.jar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.BasePluginExtension
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
Expand Down Expand Up @@ -85,7 +87,9 @@ class PluginBuildPlugin implements Plugin<Project> {
PluginPropertiesExtension extension1 = project.getExtensions().getByType(PluginPropertiesExtension.class)
configurePublishing(project, extension1)
String name = extension1.name
project.archivesBaseName = name

BasePluginExtension base = project.getExtensions().findByType(BasePluginExtension.class)
base.archivesBaseName = name
project.description = extension1.description

if (extension1.name == null) {
Expand All @@ -98,12 +102,13 @@ class PluginBuildPlugin implements Plugin<Project> {
throw new InvalidUserDataException('classname is a required setting for opensearchplugin')
}

JavaPluginExtension java = project.getExtensions().findByType(JavaPluginExtension.class)
Map<String, String> properties = [
'name' : extension1.name,
'description' : extension1.description,
'version' : extension1.version,
'opensearchVersion' : Version.fromString(VersionProperties.getOpenSearch()).toString(),
'javaVersion' : project.targetCompatibility as String,
'javaVersion' : java.targetCompatibility as String,
'classname' : extension1.classname,
'customFolderName' : extension1.customFolderName,
'extendedPlugins' : extension1.extendedPlugins.join(','),
Expand Down Expand Up @@ -156,8 +161,9 @@ class PluginBuildPlugin implements Plugin<Project> {
}
// always configure publishing for client jars
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name + "-client")
final BasePluginExtension base = project.getExtensions().findByType(BasePluginExtension.class)
project.tasks.withType(GenerateMavenPom.class).configureEach { GenerateMavenPom generatePOMTask ->
generatePOMTask.destination = "${project.buildDir}/distributions/${project.archivesBaseName}-client-${project.versions.opensearch}.pom"
generatePOMTask.destination = "${project.buildDir}/distributions/${base.archivesBaseName}-client-${project.versions.opensearch}.pom"
}
} else {
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.gradle.api.XmlProvider;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.BasePluginConvention;
import org.gradle.api.plugins.BasePluginExtension;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
Expand Down Expand Up @@ -77,7 +77,7 @@ public void apply(Project project) {
}

private static String getArchivesBaseName(Project project) {
return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
return project.getExtensions().getByType(BasePluginExtension.class).getArchivesBaseName();
}

/**Configuration generation of maven poms. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
Expand Down Expand Up @@ -106,8 +106,8 @@ public ForbiddenPatternsTask() {
@IgnoreEmptyDirectories
@PathSensitive(PathSensitivity.RELATIVE)
public FileCollection getFiles() {
return getProject().getConvention()
.getPlugin(JavaPluginConvention.class)
return getProject().getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.stream()
.map(sourceSet -> sourceSet.getAllSource().matching(filesFilter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import org.opensearch.gradle.LoggedExec;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.Classpath;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
Expand Down Expand Up @@ -82,8 +82,8 @@ public void setClasspath(FileCollection classpath) {
@SkipWhenEmpty
@IgnoreEmptyDirectories
public FileCollection getClassDirectories() {
return getProject().getConvention()
.getPlugin(JavaPluginConvention.class)
return getProject().getExtensions()
.getByType(JavaPluginExtension.class)
.getSourceSets()
.stream()
// Don't pick up all source sets like the java9 ones as logger-check doesn't support the class format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
import org.gradle.api.tasks.Input;
Expand Down Expand Up @@ -240,7 +240,7 @@ private File getTestOutputResourceDir() {

private Optional<SourceSet> getSourceSet() {
Project project = getProject();
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
return project.getExtensions().findByType(JavaPluginExtension.class) == null
? Optional.empty()
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(getSourceSetName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
import org.gradle.api.tasks.Input;
Expand Down Expand Up @@ -178,7 +178,7 @@ void copy() {

private Optional<SourceSet> getSourceSet() {
Project project = getProject();
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
return project.getExtensions().findByType(JavaPluginExtension.class) == null
? Optional.empty()
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(getSourceSetName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceRegistration;
Expand Down Expand Up @@ -68,7 +68,7 @@ public static <T> Action<T> noop() {
}

public static SourceSetContainer getJavaSourceSets(Project project) {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
return project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
}

public static <T extends Task> TaskProvider<T> maybeRegister(TaskContainer tasks, String name, Class<T> clazz, Action<T> action) {
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/org/opensearch/gradle/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.util.PatternFilterable;

Expand Down Expand Up @@ -149,7 +149,7 @@ public static FileTree getJavaTestAndMainSourceResources(Project project, Action
* @return An Optional that contains the Java test SourceSet if it exists.
*/
public static Optional<SourceSet> getJavaTestSourceSet(Project project) {
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
return project.getExtensions().findByType(JavaPluginExtension.class) == null
? Optional.empty()
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.TEST_SOURCE_SET_NAME));
}
Expand All @@ -159,7 +159,7 @@ public static Optional<SourceSet> getJavaTestSourceSet(Project project) {
* @return An Optional that contains the Java main SourceSet if it exists.
*/
public static Optional<SourceSet> getJavaMainSourceSet(Project project) {
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
return project.getExtensions().findByType(JavaPluginExtension.class) == null
? Optional.empty()
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME));
}
Expand Down
10 changes: 7 additions & 3 deletions client/benchmark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
apply plugin: 'opensearch.build'
apply plugin: 'application'

group = 'org.opensearch.client'
base {
group = 'org.opensearch.client'
archivesBaseName = 'client-benchmarks'
}

// Not published so no need to assemble
assemble.enabled = true

archivesBaseName = 'client-benchmarks'
mainClassName = 'org.opensearch.client.benchmark.BenchmarkMain'
application {
mainClass = 'org.opensearch.client.benchmark.BenchmarkMain'
}

// never try to invoke tests on the benchmark project - there aren't any
test.enabled = false
Expand Down
6 changes: 4 additions & 2 deletions client/rest-high-level/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ apply plugin: 'opensearch.rest-test'
apply plugin: 'opensearch.publish'
apply plugin: 'opensearch.rest-resources'

group = 'org.opensearch.client'
archivesBaseName = 'opensearch-rest-high-level-client'
base {
group = 'org.opensearch.client'
archivesBaseName = 'opensearch-rest-high-level-client'
}

restResources {
//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
Expand Down
12 changes: 8 additions & 4 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
apply plugin: 'opensearch.build'
apply plugin: 'opensearch.publish'

targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}

group = 'org.opensearch.client'
archivesBaseName = 'opensearch-rest-client'
base {
group = 'org.opensearch.client'
archivesBaseName = 'opensearch-rest-client'
}

dependencies {
api "org.apache.httpcomponents.client5:httpclient5:${versions.httpclient5}"
Expand Down
Loading

0 comments on commit a0da953

Please sign in to comment.