Skip to content

Commit

Permalink
Update gradle wrapper to 8.2 (elastic#2109)
Browse files Browse the repository at this point in the history
Updates wrapper and fix Gradle 8.2 deprecations
  • Loading branch information
breskeby authored Jul 6, 2023
1 parent e3627e8 commit 9e39023
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,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 @@ -728,7 +728,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.elasticsearch.hadoop.gradle.fixture.hadoop.services.SparkYarnServiceD
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.util.ConfigureUtil
import org.elasticsearch.hadoop.gradle.util.ConfigureUtil

/**
* Configuration for a Hadoop cluster, used for integration tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.util.ConfigureUtil
import org.elasticsearch.hadoop.gradle.util.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 @@ -23,7 +23,7 @@ import org.elasticsearch.hadoop.gradle.fixture.hadoop.RoleDescriptor
import org.gradle.api.GradleException
import org.gradle.api.GradleScriptException
import org.gradle.api.Project
import org.gradle.util.ConfigureUtil
import org.elasticsearch.hadoop.gradle.util.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 @@ -24,7 +24,7 @@ import org.elasticsearch.hadoop.gradle.fixture.hadoop.RoleDescriptor
import org.elasticsearch.hadoop.gradle.fixture.hadoop.ServiceDescriptor
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.util.ConfigureUtil
import org.elasticsearch.hadoop.gradle.util.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 @@ -29,11 +29,17 @@
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.JvmVendor;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.jvm.toolchain.JavaToolchainService;
import org.gradle.jvm.toolchain.JavaToolchainSpec;
import org.gradle.jvm.toolchain.JvmVendorSpec;
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 @@ -193,7 +199,7 @@ private List<JavaHome> getAvailableJavaVersions() {

private Stream<InstallationLocation> getAvailableJavaInstallationLocationSteam() {
return Stream.concat(
javaInstallationRegistry.listInstallations().stream(),
javaInstallationRegistry.toolchains().stream().map(metadata -> metadata.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,6 +54,7 @@
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.scala.ScalaDoc;
import org.gradle.api.tasks.testing.Test;
import org.gradle.api.tasks.ScalaSourceDirectorySet;

import static org.gradle.api.plugins.JavaBasePlugin.DOCUMENTATION_GROUP;
import static org.gradle.api.plugins.JavaBasePlugin.VERIFICATION_GROUP;
Expand Down Expand Up @@ -291,19 +292,18 @@ 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 @@ -316,9 +316,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 @@ -341,9 +340,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 Expand Up @@ -381,7 +379,7 @@ private static SourceSet createVariantSourceSet(SparkVariant sparkVariant, Sourc
SourceDirectorySet resourcesSourceSet = sourceSet.getResources();
resourcesSourceSet.setSrcDirs(Collections.singletonList("src/" + sourceSetName + "/resources"));

SourceDirectorySet scalaSourceSet = getScalaSourceSet(sourceSet).getScala();
ScalaSourceDirectorySet scalaSourceSet = getScalaSourceSet(sourceSet);
scalaSourceSet.setSrcDirs(Arrays.asList(
"src/" + sourceSetName + "/scala",
"src/" + sourceSetName + "/" + sparkVariant.getName()
Expand All @@ -401,9 +399,8 @@ private static void configureAdditionalSourceSetClasspaths(Project project, Conf
additionalSourceSet.setRuntimeClasspath(project.files(additionalSourceSet.getOutput(), mainSourceSet.getOutput(), additionalRuntimeClasspath));
}

private static DefaultScalaSourceSet getScalaSourceSet(SourceSet sourceSet) {
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
return (DefaultScalaSourceSet) sourceSetConvention.getPlugins().get("scala");
private static ScalaSourceDirectorySet getScalaSourceSet(SourceSet sourceSet) {
return sourceSet.getExtensions().getByType(ScalaSourceDirectorySet.class);
}

private static void registerMainVariant(JavaPluginExtension java, SparkVariant sparkVariant, SourceSet main, Object version) {
Expand Down Expand Up @@ -456,7 +453,7 @@ private static void registerVariantScaladoc(Project project, TaskContainer tasks
scaladocClasspath.from(main.getCompileClasspath());

scalaDoc.setClasspath(scaladocClasspath);
scalaDoc.setSource(getScalaSourceSet(main).getScala());
scalaDoc.setSource(getScalaSourceSet(main));
});
}

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

description = "Elasticsearch for Apache Hadoop"
project.archivesBaseName = 'elasticsearch-hadoop'

base {
archivesName = 'elasticsearch-hadoop'
}

def sparkVariantIncluded = 'spark20scala211'

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=a62c5f99585dd9e1f95dab7b9415a0e698fa9dd1e6c38537faa81ac078f4d23e
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionSha256Sum=38f66cd6eef217b4c35855bb11ea4e9fbc53594ccccb5fb82dfd317ef8c2c5a3
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pluginManagement {
plugins {
id 'com.github.johnrengelman.shadow' version "8.1.0"
id 'com.github.johnrengelman.shadow' version "8.1.1"
}
}

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 @@ -33,8 +33,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

0 comments on commit 9e39023

Please sign in to comment.