-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Build: Forbiddenapis is not running for Java9 SourceSet #29292
Comments
The bug was fixed in forbiddenapis. Should come with version 2.6. Before releasing that version, I'd like to put some more effort in silencing the warnings when parsing signatures where the classes are not on classpath. |
Pinging @elastic/es-core-infra |
Hi @jasontedor,
I did this locally like this: diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 5256968..f6d5fc6 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -94,7 +94,7 @@ dependencies {
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
- compile 'de.thetaphi:forbiddenapis:2.5'
+ compile 'de.thetaphi:forbiddenapis:2.6-SNAPSHOT'
compile 'org.apache.rat:apache-rat:0.11'
compile "org.elasticsearch:jna:4.5.1"
}
diff --git a/server/build.gradle b/server/build.gradle
index 7b30f57..3eea0cf 100644
--- a/server/build.gradle
+++ b/server/build.gradle
@@ -43,13 +43,22 @@ if (!isEclipse && !isIdea) {
java {
srcDirs = ['src/main/java9']
}
+ compileClasspath += sourceSets.main.compileClasspath
}
}
+
+ dependencies {
+ java9Compile sourceSets.main.output
+ }
compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
}
+
+ forbiddenApisJava9 {
+ targetCompatibility = 9
+ }
jar {
into('META-INF/versions/9') { This makes the build work - as said before the extra dependency to main's output is optional, but may be required soon:
As you see, it also scans the Java 9 classes with correct bundled signatures. |
I improved the Java9 config a bit more. Now its expressed without hacks using configurations and inheritance: // we want to keep the JDKs in our IDEs set to JDK 8 until minimum JDK is bumped to 9 so we do not include this source set in our IDEs
if (!isEclipse && !isIdea) {
sourceSets {
java9 {
java {
srcDirs = ['src/main/java9']
}
}
}
configurations {
java9Compile.extendsFrom(compile)
}
dependencies {
java9Compile sourceSets.main.output
}
compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
}
forbiddenApisJava9 {
targetCompatibility = 9
}
jar {
metaInf {
into 'versions/9'
from sourceSets.java9.output
}
manifest.attributes('Multi-Release': 'true')
}
} This changes:
I think this can already applied to the Java 9 build, just the |
Hi: Here is the diff of my whole work for correctly setting up the Java9 source sets. It also fixes the issues with the delayed project evaluation that @jasontedor tried to fix after the builds failed. This now uses projects.tasks.withType() to fix this completely and does not rely on task names. master...uschindler:issues/29292 I can create a PR that does not yet contain the forbiddenapis update if you want to apply it for fixing the bugs in the Java 9 setup. |
Please do @uschindler. |
…nd 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 (see elastic#29292)
Here is the PR: #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
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
Fixed by #29312 |
Hi, thanks @rjernst! I had unfortunately no time to release a new forbiddenapis version, but once this is done, I will send another PR - including adding the commented out config option. |
Due to a bug in forbiddenapis the forbidden tasks are not enabled for the sourceSet named "java9" in the server module.
The corresponding bug is: policeman-tools/forbidden-apis#138
See also discussion on #29289
I fixed the bug locally and it was working now, the only problem is setup of signatures files for the "java9" sourceSet: We do not have any dependencies, so parsing the default signatures fails:
This has to be fixed once forbiddenApis is updated:
targetCompatibility
(like done for the compile task). Maybe there is a more generic solution in the build plugin.The text was updated successfully, but these errors were encountered: