Fix gradle4.8 deprecation warnings (#31654)
* remove explicit wrapper task It's created by Gradle and triggers a deprecation warning Simplify configuration * Upgrade shadow plugin to get rid of Gradle deprecation * Move compile configuration to base plugin Solves Gradle deprecation warning from earlier Gradle versions * Enable stable publishing in the Gradle build * Replace usage of deprecated property * bump Gradle version in build compare
This commit is contained in:
parent
58cf95a06f
commit
200e1f45f2
18
build.gradle
18
build.gradle
|
@ -486,25 +486,17 @@ task run(type: Run) {
|
||||||
impliesSubProjects = true
|
impliesSubProjects = true
|
||||||
}
|
}
|
||||||
|
|
||||||
task wrapper(type: Wrapper)
|
wrapper {
|
||||||
|
distributionType = DistributionType.ALL
|
||||||
gradle.projectsEvaluated {
|
doLast {
|
||||||
|
|
||||||
allprojects {
|
|
||||||
tasks.withType(Wrapper) { Wrapper wrapper ->
|
|
||||||
wrapper.distributionType = DistributionType.ALL
|
|
||||||
|
|
||||||
wrapper.doLast {
|
|
||||||
final DistributionLocator locator = new DistributionLocator()
|
final DistributionLocator locator = new DistributionLocator()
|
||||||
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
|
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
|
||||||
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
|
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
|
||||||
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
|
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
|
||||||
final String sha256Sum = new String(sha256Uri.toURL().bytes)
|
final String sha256Sum = new String(sha256Uri.toURL().bytes)
|
||||||
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
|
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
|
||||||
}
|
println "Added checksum to wrapper properties"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void assertLinesInFile(final Path path, final List<String> expectedLines) {
|
static void assertLinesInFile(final Path path, final List<String> expectedLines) {
|
||||||
|
@ -591,7 +583,7 @@ if (System.properties.get("build.compare") != null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceBuild {
|
sourceBuild {
|
||||||
gradleVersion = "4.7" // does not default to gradle weapper of project dir, but current version
|
gradleVersion = "4.8.1" // does not default to gradle weapper of project dir, but current version
|
||||||
projectDir = referenceProject
|
projectDir = referenceProject
|
||||||
tasks = ["clean", "assemble"]
|
tasks = ["clean", "assemble"]
|
||||||
arguments = ["-Dbuild.compare_friendly=true"]
|
arguments = ["-Dbuild.compare_friendly=true"]
|
||||||
|
|
|
@ -471,6 +471,24 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
/**Configuration generation of maven poms. */
|
/**Configuration generation of maven poms. */
|
||||||
public static void configurePomGeneration(Project project) {
|
public static void configurePomGeneration(Project project) {
|
||||||
|
// Only works with `enableFeaturePreview('STABLE_PUBLISHING')`
|
||||||
|
// https://github.com/gradle/gradle/issues/5696#issuecomment-396965185
|
||||||
|
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
|
||||||
|
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
|
||||||
|
// just make a copy.
|
||||||
|
doLast {
|
||||||
|
project.copy {
|
||||||
|
from generatePOMTask.destination
|
||||||
|
into "${project.buildDir}/distributions"
|
||||||
|
rename { "${project.archivesBaseName}-${project.version}.pom" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// build poms with assemble (if the assemble task exists)
|
||||||
|
Task assemble = project.tasks.findByName('assemble')
|
||||||
|
if (assemble) {
|
||||||
|
assemble.dependsOn(generatePOMTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
project.plugins.withType(MavenPublishPlugin.class).whenPluginAdded {
|
project.plugins.withType(MavenPublishPlugin.class).whenPluginAdded {
|
||||||
project.publishing {
|
project.publishing {
|
||||||
publications {
|
publications {
|
||||||
|
@ -480,20 +498,6 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Work around Gradle 4.8 issue until we `enableFeaturePreview('STABLE_PUBLISHING')`
|
|
||||||
// https://github.com/gradle/gradle/issues/5696#issuecomment-396965185
|
|
||||||
project.getGradle().getTaskGraph().whenReady {
|
|
||||||
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom t ->
|
|
||||||
// place the pom next to the jar it is for
|
|
||||||
t.destination = new File(project.buildDir, "distributions/${project.archivesBaseName}-${project.version}.pom")
|
|
||||||
// build poms with assemble (if the assemble task exists)
|
|
||||||
Task assemble = project.tasks.findByName('assemble')
|
|
||||||
if (assemble) {
|
|
||||||
assemble.dependsOn(t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,16 +159,18 @@ public class PluginBuildPlugin extends BuildPlugin {
|
||||||
/** Adds a task to move jar and associated files to a "-client" name. */
|
/** Adds a task to move jar and associated files to a "-client" name. */
|
||||||
protected static void addClientJarTask(Project project) {
|
protected static void addClientJarTask(Project project) {
|
||||||
Task clientJar = project.tasks.create('clientJar')
|
Task clientJar = project.tasks.create('clientJar')
|
||||||
clientJar.dependsOn(project.jar, 'generatePomFileForClientJarPublication', project.javadocJar, project.sourcesJar)
|
clientJar.dependsOn(project.jar, project.tasks.generatePomFileForClientJarPublication, project.javadocJar, project.sourcesJar)
|
||||||
clientJar.doFirst {
|
clientJar.doFirst {
|
||||||
Path jarFile = project.jar.outputs.files.singleFile.toPath()
|
Path jarFile = project.jar.outputs.files.singleFile.toPath()
|
||||||
String clientFileName = jarFile.fileName.toString().replace(project.version, "client-${project.version}")
|
String clientFileName = jarFile.fileName.toString().replace(project.version, "client-${project.version}")
|
||||||
Files.copy(jarFile, jarFile.resolveSibling(clientFileName), StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(jarFile, jarFile.resolveSibling(clientFileName), StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
|
||||||
String pomFileName = jarFile.fileName.toString().replace('.jar', '.pom')
|
|
||||||
String clientPomFileName = clientFileName.replace('.jar', '.pom')
|
String clientPomFileName = clientFileName.replace('.jar', '.pom')
|
||||||
Files.copy(jarFile.resolveSibling(pomFileName), jarFile.resolveSibling(clientPomFileName),
|
Files.copy(
|
||||||
StandardCopyOption.REPLACE_EXISTING)
|
project.tasks.generatePomFileForClientJarPublication.outputs.files.singleFile.toPath(),
|
||||||
|
jarFile.resolveSibling(clientPomFileName),
|
||||||
|
StandardCopyOption.REPLACE_EXISTING
|
||||||
|
)
|
||||||
|
|
||||||
String sourcesFileName = jarFile.fileName.toString().replace('.jar', '-sources.jar')
|
String sourcesFileName = jarFile.fileName.toString().replace('.jar', '-sources.jar')
|
||||||
String clientSourcesFileName = clientFileName.replace('.jar', '-sources.jar')
|
String clientSourcesFileName = clientFileName.replace('.jar', '-sources.jar')
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.plugins.JavaBasePlugin
|
import org.gradle.api.plugins.JavaBasePlugin
|
||||||
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the build to compile tests against Elasticsearch's test framework
|
* Configures the build to compile tests against Elasticsearch's test framework
|
||||||
|
@ -61,5 +62,12 @@ public class StandaloneRestTestPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
PrecommitTasks.create(project, false)
|
PrecommitTasks.create(project, false)
|
||||||
project.check.dependsOn(project.precommit)
|
project.check.dependsOn(project.precommit)
|
||||||
|
|
||||||
|
project.tasks.withType(JavaCompile) {
|
||||||
|
// This will be the default in Gradle 5.0
|
||||||
|
if (options.compilerArgs.contains("-processor") == false) {
|
||||||
|
options.compilerArgs << '-proc:none'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,5 @@ public class StandaloneTestPlugin implements Plugin<Project> {
|
||||||
test.testClassesDirs = project.sourceSets.test.output.classesDirs
|
test.testClassesDirs = project.sourceSets.test.output.classesDirs
|
||||||
test.mustRunAfter(project.precommit)
|
test.mustRunAfter(project.precommit)
|
||||||
project.check.dependsOn(test)
|
project.check.dependsOn(test)
|
||||||
|
|
||||||
project.tasks.withType(JavaCompile) {
|
|
||||||
// This will be the default in Gradle 5.0
|
|
||||||
if (options.compilerArgs.contains("-processor") == false) {
|
|
||||||
options.compilerArgs << '-proc:none'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
|
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,3 +128,6 @@ if (extraProjects.exists()) {
|
||||||
addSubProjects('', extraProjectDir)
|
addSubProjects('', extraProjectDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enable in preparation for Gradle 5.0
|
||||||
|
enableFeaturePreview('STABLE_PUBLISHING')
|
||||||
|
|
|
@ -36,7 +36,7 @@ subprojects {
|
||||||
// default to main class files if such a source set exists
|
// default to main class files if such a source set exists
|
||||||
final List files = []
|
final List files = []
|
||||||
if (project.sourceSets.findByName("main")) {
|
if (project.sourceSets.findByName("main")) {
|
||||||
files.add(project.sourceSets.main.output.classesDir)
|
files.add(project.sourceSets.main.output.classesDirs)
|
||||||
dependsOn project.tasks.classes
|
dependsOn project.tasks.classes
|
||||||
}
|
}
|
||||||
// filter out non-existent classes directories from empty source sets
|
// filter out non-existent classes directories from empty source sets
|
||||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
|
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue