Build: add animalsniffer to detect usage of java8 apis in client and client-sniffer

This commit is contained in:
javanna 2016-06-10 09:51:47 +02:00 committed by Luca Cavanna
parent 2856ab07de
commit 0af9d2c767
3 changed files with 15 additions and 2 deletions

View File

@ -87,6 +87,7 @@ dependencies {
compile 'de.thetaphi:forbiddenapis:2.1'
compile 'com.bmuschko:gradle-nexus-plugin:2.3.1'
compile 'org.apache.rat:apache-rat:0.11'
compile 'ru.vyarus:gradle-animalsniffer-plugin:1.0.1'
}

View File

@ -21,6 +21,7 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.JavaVersion
apply plugin: 'elasticsearch.build'
apply plugin: 'ru.vyarus.animalsniffer'
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_7
@ -40,9 +41,9 @@ dependencies {
testCompile "org.apache.lucene:lucene-core:${versions.lucene}"
testCompile "org.apache.lucene:lucene-codecs:${versions.lucene}"
testCompile "org.elasticsearch:securemock:${versions.securemock}"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
//TODO compiling from 1.8 with target 1.7 and source 1.7 is best effort, not enough to ensure we are java 7 compatible
compileJava.options.compilerArgs << '-target' << '1.7' << '-source' << '1.7' << '-Xlint:all,-path,-serial,-options'
compileTestJava.options.compilerArgs << '-target' << '1.7' << '-source' << '1.7'
@ -56,6 +57,11 @@ forbiddenApisTest {
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
}
animalsnifferTest {
//animalsniffer doesn't like sun classes usages (e.g. com.sun.net.httpserver.HttpServer)
exclude('org/elasticsearch/client/sniff/HostsSnifferTests.class')
}
//JarHell is part of es core, which we don't want to pull in
jarHell.enabled=false
//NamingConventionCheck is part of test-framework, which we don't want to pull in as it depends on es core

View File

@ -21,6 +21,7 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.JavaVersion
apply plugin: 'elasticsearch.build'
apply plugin: 'ru.vyarus.animalsniffer'
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_7
@ -38,9 +39,9 @@ dependencies {
testCompile "org.apache.lucene:lucene-core:${versions.lucene}"
testCompile "org.apache.lucene:lucene-codecs:${versions.lucene}"
testCompile "org.elasticsearch:securemock:${versions.securemock}"
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
//TODO compiling from 1.8 with target 1.7 and source 1.7 is best effort, not enough to ensure we are java 7 compatible
compileJava.options.compilerArgs << '-target' << '1.7' << '-source' << '1.7' << '-Xlint:all,-path,-serial,-options'
compileTestJava.options.compilerArgs << '-target' << '1.7' << '-source' << '1.7'
@ -54,6 +55,11 @@ forbiddenApisTest {
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
}
animalsnifferTest {
//animalsniffer doesn't like sun classes usages (e.g. com.sun.net.httpserver.HttpServer)
exclude('org/elasticsearch/client/RestClientIntegTests.class')
}
//JarHell is part of es core, which we don't want to pull in
jarHell.enabled=false
//NamingConventionCheck is part of test-framework, which we don't want to pull in as it depends on es core