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

Upgrade forbiddenapis to 2.6 #33809

Merged
merged 5 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ dependencies {
compile 'org.apache.rat:apache-rat:0.11'
compile "org.elasticsearch:jna:4.5.1"
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
compile 'de.thetaphi:forbiddenapis:2.6'
testCompile "junit:junit:${props.getProperty('junit')}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
package org.elasticsearch.gradle.precommit

import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.JavaBasePlugin
Expand All @@ -33,7 +36,7 @@ class PrecommitTasks {
public static Task create(Project project, boolean includeDependencyLicenses) {
project.configurations.create("forbiddenApisCliJar")
project.dependencies {
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.5')
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.6')
}

List<Task> precommitTasks = [
Expand Down Expand Up @@ -109,47 +112,43 @@ class PrecommitTasks {
}

private static Task configureForbiddenApisCli(Project project) {
Task forbiddenApisCli = project.tasks.create('forbiddenApis')
project.sourceSets.all { sourceSet ->
forbiddenApisCli.dependsOn(
project.tasks.create(sourceSet.getTaskName('forbiddenApis', null), ForbiddenApisCliTask) {
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
dependsOn(buildResources)
it.sourceSet = sourceSet
javaHome = project.runtimeJavaHome
targetCompatibility = project.compilerJavaVersion
bundledSignatures = [
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
]
signaturesFiles = project.files(
buildResources.copy("forbidden/jdk-signatures.txt"),
buildResources.copy("forbidden/es-all-signatures.txt")
)
suppressAnnotations = ['**.SuppressForbidden']
if (sourceSet.name == 'test') {
signaturesFiles += project.files(
buildResources.copy("forbidden/es-test-signatures.txt"),
buildResources.copy("forbidden/http-signatures.txt")
)
} else {
signaturesFiles += project.files(buildResources.copy("forbidden/es-server-signatures.txt"))
}
dependsOn sourceSet.classesTaskName
classesDirs = sourceSet.output.classesDirs
ext.replaceSignatureFiles = { String... names ->
signaturesFiles = project.files(
names.collect { buildResources.copy("forbidden/${it}.txt") }
)
}
ext.addSignatureFiles = { String... names ->
signaturesFiles += project.files(
names.collect { buildResources.copy("forbidden/${it}.txt") }
)
}
}
project.pluginManager.apply(ForbiddenApisPlugin)
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
project.tasks.withType(CheckForbiddenApis) {
dependsOn(buildResources)
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
project.runtimeJavaVersion.getMajorVersion() :
project.runtimeJavaVersion
bundledSignatures = [
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
]
signaturesFiles = project.files(
buildResources.copy("forbidden/jdk-signatures.txt"),
buildResources.copy("forbidden/es-all-signatures.txt")
)
suppressAnnotations = ['**.SuppressForbidden']
if (name.endsWith('Test')) {
signaturesFiles += project.files(
buildResources.copy("forbidden/es-test-signatures.txt"),
buildResources.copy("forbidden/http-signatures.txt")
)
} else {
signaturesFiles += project.files(buildResources.copy("forbidden/es-server-signatures.txt"))
}
ext.replaceSignatureFiles = { String... names ->
signaturesFiles = project.files(
names.collect { buildResources.copy("forbidden/${it}.txt") }
)
}
ext.addSignatureFiles = { String... names ->
signaturesFiles += project.files(
names.collect { buildResources.copy("forbidden/${it}.txt") }
)
}
}
return forbiddenApisCli
Task forbiddenApis = project.tasks.getByName("forbiddenApis")
forbiddenApis.group = ""
return forbiddenApis
}

private static Task configureCheckstyle(Project project) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class ThirdPartyAuditTask extends DefaultTask {

private static final Pattern MISSING_CLASS_PATTERN = Pattern.compile(
"WARNING: The referenced class '(.*)' cannot be loaded\\. Please fix the classpath!"
"WARNING: Class '(.*)' cannot be loaded \\(.*\\)\\. Please fix the classpath!"
Copy link
Contributor

@uschindler uschindler Sep 18, 2018

Choose a reason for hiding this comment

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

Nice catch. Yes this message was changed due to the cleanup of missing class reporting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... a much appreciated change. Thanks for that !

);

private static final Pattern VIOLATION_PATTERN = Pattern.compile(
Expand Down
4 changes: 2 additions & 2 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

/*
* Licensed to Elasticsearch under one or more contributor
Expand Down Expand Up @@ -52,7 +52,7 @@ dependencies {
testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}"
}

tasks.withType(ForbiddenApisCliTask) {
tasks.withType(CheckForbiddenApis) {
//client does not depend on server, so only jdk and http signatures should be checked
replaceSignatureFiles ('jdk-signatures', 'http-signatures')
}
Expand Down
7 changes: 2 additions & 5 deletions distribution/tools/launchers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/



import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

apply plugin: 'elasticsearch.build'

Expand All @@ -32,7 +29,7 @@ dependencies {

archivesBaseName = 'elasticsearch-launchers'

tasks.withType(ForbiddenApisCliTask) {
tasks.withType(CheckForbiddenApis) {
replaceSignatureFiles 'jdk-signatures'
}

Expand Down
3 changes: 1 addition & 2 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ if (!isEclipse && !isIdea) {

forbiddenApisJava9 {
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
targetCompatibility = JavaVersion.VERSION_1_9
javaHome = project.java9Home
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
}
replaceSignatureFiles 'jdk-signatures'
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/analysis-icu/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

/*
* Licensed to Elasticsearch under one or more contributor
Expand All @@ -25,7 +25,7 @@ esplugin {
hasClientJar = true
}

tasks.withType(ForbiddenApisCliTask) {
tasks.withType(CheckForbiddenApis) {
signatures += [
"com.ibm.icu.text.Collator#getInstance() @ Don't use default locale, use getInstance(ULocale) instead"
]
Expand Down
3 changes: 1 addition & 2 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ if (!isEclipse && !isIdea) {

forbiddenApisJava9 {
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
targetCompatibility = JavaVersion.VERSION_1_9
javaHome = project.java9Home
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
}
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/security/cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

apply plugin: 'elasticsearch.build'

Expand Down Expand Up @@ -26,7 +26,7 @@ if (project.inFipsJvm) {
test.enabled = false
// Forbiden APIs non-portable checks fail because bouncy castle classes being used from the FIPS JDK since those are
// not part of the Java specification - all of this is as designed, so we have to relax this check for FIPS.
tasks.withType(ForbiddenApisCliTask) {
tasks.withType(CheckForbiddenApis) {
bundledSignatures -= "jdk-non-portable"
}
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/sql/sql-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

/*
* This project is named sql-cli because it is in the "org.elasticsearch.plugin"
Expand Down Expand Up @@ -75,7 +75,7 @@ artifacts {
}


tasks.withType(ForbiddenApisCliTask) {
tasks.withType(CheckForbiddenApis) {
signaturesFiles += files('src/forbidden/cli-signatures.txt')
}

Expand Down