Build: Fix Java9 MR build (#29312)
Correctly setup classpath/dependencies and fix checkstyle task that was partly broken because delayed setup of Java9 sourcesets. This also cleans packaging of META-INF. It also prepares forbiddenapis 2.6 upgrade relates #29292
This commit is contained in:
parent
4db6fc9a08
commit
7c6d5cbf1f
|
@ -551,7 +551,7 @@ class BuildPlugin implements Plugin<Project> {
|
|||
if (project.licenseFile == null || project.noticeFile == null) {
|
||||
throw new GradleException("Must specify license and notice file for project ${project.path}")
|
||||
}
|
||||
jarTask.into('META-INF') {
|
||||
jarTask.metaInf {
|
||||
from(project.licenseFile.parent) {
|
||||
include project.licenseFile.name
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.gradle.precommit
|
||||
|
||||
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
|
||||
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
|
@ -83,17 +84,14 @@ class PrecommitTasks {
|
|||
getClass().getResource('/forbidden/es-all-signatures.txt')]
|
||||
suppressAnnotations = ['**.SuppressForbidden']
|
||||
}
|
||||
Task mainForbidden = project.tasks.findByName('forbiddenApisMain')
|
||||
if (mainForbidden != null) {
|
||||
mainForbidden.configure {
|
||||
signaturesURLs += getClass().getResource('/forbidden/es-server-signatures.txt')
|
||||
}
|
||||
}
|
||||
Task testForbidden = project.tasks.findByName('forbiddenApisTest')
|
||||
if (testForbidden != null) {
|
||||
testForbidden.configure {
|
||||
signaturesURLs += getClass().getResource('/forbidden/es-test-signatures.txt')
|
||||
signaturesURLs += getClass().getResource('/forbidden/http-signatures.txt')
|
||||
project.tasks.withType(CheckForbiddenApis) {
|
||||
// we do not use the += operator to add signatures, as conventionMappings of Gradle do not work when it's configured using withType:
|
||||
if (name.endsWith('Test')) {
|
||||
signaturesURLs = project.forbiddenApis.signaturesURLs +
|
||||
[ getClass().getResource('/forbidden/es-test-signatures.txt'), getClass().getResource('/forbidden/http-signatures.txt') ]
|
||||
} else {
|
||||
signaturesURLs = project.forbiddenApis.signaturesURLs +
|
||||
[ getClass().getResource('/forbidden/es-server-signatures.txt') ]
|
||||
}
|
||||
}
|
||||
Task forbiddenApis = project.tasks.findByName('forbiddenApis')
|
||||
|
@ -144,10 +142,9 @@ class PrecommitTasks {
|
|||
]
|
||||
toolVersion = 7.5
|
||||
}
|
||||
for (String taskName : ['checkstyleMain', 'checkstyleJava9', 'checkstyleTest']) {
|
||||
Task task = project.tasks.findByName(taskName)
|
||||
if (task != null) {
|
||||
project.tasks['check'].dependsOn.remove(task)
|
||||
|
||||
project.tasks.withType(Checkstyle) { task ->
|
||||
project.tasks[JavaBasePlugin.CHECK_TASK_NAME].dependsOn.remove(task)
|
||||
checkstyleTask.dependsOn(task)
|
||||
task.dependsOn(copyCheckstyleConf)
|
||||
task.inputs.file(checkstyleSuppressions)
|
||||
|
@ -155,11 +152,6 @@ class PrecommitTasks {
|
|||
html.enabled false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.tasks.withType(Checkstyle) {
|
||||
dependsOn(copyCheckstyleConf)
|
||||
}
|
||||
|
||||
return checkstyleTask
|
||||
}
|
||||
|
|
|
@ -46,13 +46,29 @@ if (!isEclipse && !isIdea) {
|
|||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
java9Compile.extendsFrom(compile)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
java9Compile sourceSets.main.output
|
||||
}
|
||||
|
||||
compileJava9Java {
|
||||
sourceCompatibility = 9
|
||||
targetCompatibility = 9
|
||||
}
|
||||
|
||||
/* Enable this when forbiddenapis was updated to 2.6.
|
||||
* See: https://github.com/elastic/elasticsearch/issues/29292
|
||||
forbiddenApisJava9 {
|
||||
targetCompatibility = 9
|
||||
}
|
||||
*/
|
||||
|
||||
jar {
|
||||
into('META-INF/versions/9') {
|
||||
metaInf {
|
||||
into 'versions/9'
|
||||
from sourceSets.java9.output
|
||||
}
|
||||
manifest.attributes('Multi-Release': 'true')
|
||||
|
|
Loading…
Reference in New Issue