HHH-8467 - Compiling should trigger animal-sniffer execution
This commit is contained in:
parent
46c962e9b0
commit
ffd950956c
28
build.gradle
28
build.gradle
|
@ -323,22 +323,34 @@ subprojects { subProject ->
|
||||||
// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
|
// eclipseClasspath will not add sources to classpath unless the dirs actually exist.
|
||||||
eclipseClasspath.dependsOn("generateSources")
|
eclipseClasspath.dependsOn("generateSources")
|
||||||
|
|
||||||
|
|
||||||
|
// Animal Sniffer ~~~~~~~~~~~~~~~~~~
|
||||||
|
// add animal sniffer Java API checking to the main compile tasks
|
||||||
|
|
||||||
|
// copy the resolved Animal Sniffer signature dependency artifact to a known location and name
|
||||||
task copyJavaApiSignature(type: Copy) {
|
task copyJavaApiSignature(type: Copy) {
|
||||||
from configurations.javaApiSignature
|
from configurations.javaApiSignature
|
||||||
into "$buildDir/javaApiSignature/"
|
into "$buildDir/javaApiSignature/"
|
||||||
rename '.*signature', 'javaApi.signature'
|
rename '.*signature', 'javaApi.signature'
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks that only types of the target Java version are used
|
// prepare the Animal Sniffer signature copy every time (before) we compile
|
||||||
task checkJavaApiSignature << {
|
compileJava.dependsOn copyJavaApiSignature
|
||||||
ant.taskdef(name: 'animalSniffer', classname: 'org.codehaus.mojo.animal_sniffer.ant.CheckSignatureTask', classpath: configurations.animalSniffer.asPath)
|
|
||||||
ant.animalSniffer(signature: "$buildDir/javaApiSignature/javaApi.signature", classpath: configurations.compile.asPath + System.properties.'path.separator' + configurations.provided.asPath) {
|
// and then after compilation, run the Animal Sniffer tool
|
||||||
path(path: "$buildDir/classes/main")
|
compileJava.doLast {
|
||||||
|
ant.taskdef(
|
||||||
|
name: 'animalSniffer',
|
||||||
|
classname: 'org.codehaus.mojo.animal_sniffer.ant.CheckSignatureTask',
|
||||||
|
classpath: configurations.animalSniffer.asPath
|
||||||
|
)
|
||||||
|
|
||||||
|
ant.animalSniffer(
|
||||||
|
signature: "$buildDir/javaApiSignature/javaApi.signature",
|
||||||
|
classpath: sourceSets.main.compileClasspath.asPath) {
|
||||||
|
path( path: sourceSets.main.output.classesDir )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkJavaApiSignature.dependsOn compileJava
|
|
||||||
checkJavaApiSignature.dependsOn copyJavaApiSignature
|
|
||||||
check.dependsOn checkJavaApiSignature
|
|
||||||
|
|
||||||
// specialized API/SPI checkstyle tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// specialized API/SPI checkstyle tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
task checkstylePublicSources(type: Checkstyle) {
|
task checkstylePublicSources(type: Checkstyle) {
|
||||||
|
|
Loading…
Reference in New Issue