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.5 #377

Merged
merged 6 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ class BuildPlugin implements Plugin<Project> {
*/
private static void configureBuildTasks(Project project) {
// Target Java 1.8 compilation
project.sourceCompatibility = '1.8'
project.targetCompatibility = '1.8'
project.java.sourceCompatibility = '1.8'
project.java.targetCompatibility = '1.8'

// TODO: Remove all root project distribution logic. It should exist in a separate dist project.
if (project != project.rootProject) {
Expand Down Expand Up @@ -679,7 +679,7 @@ class BuildPlugin implements Plugin<Project> {
// Set the pom's destination to the distribution directory
project.tasks.withType(GenerateMavenPom).all { GenerateMavenPom pom ->
if (pom.name == "generatePomFileFor${publication.name.capitalize()}Publication") {
pom.destination = project.provider({"${project.buildDir}/poms/${project.archivesBaseName}-${project.getVersion()}.pom"})
pom.destination = project.provider({"${project.buildDir}/poms/${project.base.archivesName}-${project.getVersion()}.pom"})
}
}

Expand Down Expand Up @@ -738,7 +738,7 @@ class BuildPlugin implements Plugin<Project> {
private static void updateVariantPomLocationAndArtifactId(Project project, MavenPublication publication, SparkVariant variant) {
// Add variant classifier to the pom file name if required
String classifier = variant.shouldClassifySparkVersion() && variant.isDefaultVariant() == false ? "-${variant.getName()}" : ''
String filename = "${project.archivesBaseName}_${variant.scalaMajorVersion}-${project.getVersion()}${classifier}"
String filename = "${project.base.archivesName}_${variant.scalaMajorVersion}-${project.getVersion()}${classifier}"
// Fix the pom name
project.tasks.withType(GenerateMavenPom).all { GenerateMavenPom pom ->
if (pom.name == "generatePomFileFor${publication.name.capitalize()}Publication") {
Expand All @@ -749,7 +749,7 @@ class BuildPlugin implements Plugin<Project> {
publication.getPom().withXml { XmlProvider xml ->
Node root = xml.asNode()
Node artifactId = (root.get('artifactId') as NodeList).get(0) as Node
artifactId.setValue("${project.archivesBaseName}_${variant.scalaMajorVersion}")
artifactId.setValue("${project.base.archivesName}_${variant.scalaMajorVersion}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.opensearch.hadoop.gradle.fixture.hadoop.services.SparkYarnServiceDesc
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.util.ConfigureUtil
import org.gradle.util.internal.ConfigureUtil

/**
* Configuration for a Hadoop cluster, used for integration tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.opensearch.gradle.testclusters.OpenSearchCluster
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.util.ConfigureUtil
import org.gradle.util.internal.ConfigureUtil

/**
* All the configurations that can be set hierarchically for a cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package org.opensearch.hadoop.gradle.fixture.hadoop.conf
import org.opensearch.hadoop.gradle.fixture.hadoop.RoleDescriptor
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.util.ConfigureUtil
import org.gradle.util.internal.ConfigureUtil

/**
* Shared configurations for all instances of a role within a Hadoop service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.opensearch.hadoop.gradle.fixture.hadoop.RoleDescriptor
import org.opensearch.hadoop.gradle.fixture.hadoop.ServiceDescriptor
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.util.ConfigureUtil
import org.gradle.util.internal.ConfigureUtil

/**
* Handles configurations for a sub-cluster of services within the larger Hadoop cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 @@ -144,7 +144,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 @@ -154,7 +154,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
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.internal.jvm.Jvm;
import org.gradle.internal.jvm.inspection.JavaInstallationRegistry;
import org.gradle.internal.jvm.inspection.JvmInstallationMetadata;
import org.gradle.internal.jvm.inspection.JvmMetadataDetector;
import org.gradle.internal.jvm.inspection.JvmToolchainMetadata;
import org.gradle.internal.jvm.inspection.JvmVendor;
import org.gradle.jvm.toolchain.internal.InstallationLocation;
import org.gradle.jvm.toolchain.internal.JavaInstallationRegistry;
import org.gradle.util.GradleVersion;

import javax.inject.Inject;
Expand Down Expand Up @@ -203,7 +204,7 @@ private List<JavaHome> getAvailableJavaVersions() {

private Stream<InstallationLocation> getAvailableJavaInstallationLocationSteam() {
return Stream.concat(
javaInstallationRegistry.listInstallations().stream(),
javaInstallationRegistry.toolchains().stream().map(t -> t.location),
Stream.of(new InstallationLocation(Jvm.current().getJavaHome(), "Current JVM"))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
Expand Down Expand Up @@ -284,18 +283,16 @@ public void execute(ComponentMetadataContext componentMetadataContext) {
@Override
public void apply(final Project project) {
SparkVariantPluginExtension extension = project.getExtensions().create("sparkVariants", SparkVariantPluginExtension.class, project);
final JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
final JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);

// Add a rule that annotates scala-library dependencies with the scala-library capability
project.getDependencies().getComponents().all(ScalaRuntimeCapability.class);

extension.defaultVariant(sparkVariant -> configureDefaultVariant(project, sparkVariant, javaPluginExtension, javaPluginConvention));
extension.featureVariants(sparkVariant -> configureVariant(project, sparkVariant, javaPluginExtension, javaPluginConvention));
extension.defaultVariant(sparkVariant -> configureDefaultVariant(project, sparkVariant, javaPluginExtension));
extension.featureVariants(sparkVariant -> configureVariant(project, sparkVariant, javaPluginExtension));
}

private static void configureDefaultVariant(Project project, SparkVariant sparkVariant, JavaPluginExtension javaPluginExtension,
JavaPluginConvention javaPluginConvention) {
private static void configureDefaultVariant(Project project, SparkVariant sparkVariant, JavaPluginExtension javaPluginExtension) {
ConfigurationContainer configurations = project.getConfigurations();
String capability = sparkVariant.getCapabilityName(project.getVersion());

Expand All @@ -308,9 +305,8 @@ private static void configureDefaultVariant(Project project, SparkVariant sparkV
configureScalaJarClassifiers(project, sparkVariant);
}

private static void configureVariant(Project project, SparkVariant sparkVariant, JavaPluginExtension javaPluginExtension,
JavaPluginConvention javaPluginConvention) {
SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
private static void configureVariant(Project project, SparkVariant sparkVariant, JavaPluginExtension javaPluginExtension) {
SourceSetContainer sourceSets = javaPluginExtension.getSourceSets();
ConfigurationContainer configurations = project.getConfigurations();
TaskContainer tasks = project.getTasks();
Object version = project.getVersion();
Expand All @@ -333,9 +329,8 @@ private static void configureVariant(Project project, SparkVariant sparkVariant,
}

public static SourceSet configureAdditionalVariantSourceSet(Project project, SparkVariant sparkVariant, String sourceSetName) {
final JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
final JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
SourceSetContainer sourceSets = javaPluginExtension.getSourceSets();
ConfigurationContainer configurations = project.getConfigurations();
String version = project.getVersion().toString();

Expand Down
7 changes: 5 additions & 2 deletions dist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import org.opensearch.hadoop.gradle.BuildPlugin
apply plugin: 'opensearch.hadoop.build'

description = "OpenSearch for Apache Hadoop"
project.archivesBaseName = 'opensearch-hadoop'

base {
archivesName = 'opensearch-hadoop'
}

def sparkVariantIncluded = 'spark30scala212'

Expand Down Expand Up @@ -142,7 +145,7 @@ publishing {
repository.appendNode('url', 'https://clojars.org/repo')

// Correct the artifact Id, otherwise it is listed as 'dist'
root.get('artifactId').get(0).setValue(project.archivesBaseName)
root.get('artifactId').get(0).setValue(project.archivesName)
}
}
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
18 changes: 6 additions & 12 deletions mr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,18 @@ configurations {
// This will force the MR project to require jars from upstream project dependencies, which shouldn't be a problem since
// there should only be one upstream project.
compileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
testCompileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
itestCompileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions qa/kerberos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ boolean localRepo = project.getProperties().containsKey("localRepo")
// TODO: Clean this up when we get to variants, they should persist their classes dirs in a sane way
configurations {
compileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/minikdc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ dependencies {
}

// Target Java 1.8 compilation
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
java {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

// for testing, until fixture are actually debuggable.
// gradle hides EVERYTHING so you have no clue what went wrong.
Expand Down
18 changes: 6 additions & 12 deletions test/shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,18 @@ configurations {
// This will force the MR project to require jars from upstream project dependencies, which shouldn't be a problem since
// there should only be one upstream project.
compileClasspath {
beforeLocking {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See please gradle/gradle#25126

attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
testCompileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
itestCompileClasspath {
beforeLocking {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
}
}
}
Expand Down
Loading