From ffd950956c4cd2f5a7e93a7423308e20caaf7814 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 6 Sep 2013 10:30:15 -0500 Subject: [PATCH] HHH-8467 - Compiling should trigger animal-sniffer execution --- build.gradle | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 07feb7ba53..5eac62c073 100644 --- a/build.gradle +++ b/build.gradle @@ -323,22 +323,34 @@ subprojects { subProject -> // eclipseClasspath will not add sources to classpath unless the dirs actually exist. 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) { from configurations.javaApiSignature into "$buildDir/javaApiSignature/" rename '.*signature', 'javaApi.signature' } - // checks that only types of the target Java version are used - task checkJavaApiSignature << { - 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) { - path(path: "$buildDir/classes/main") + // prepare the Animal Sniffer signature copy every time (before) we compile + compileJava.dependsOn copyJavaApiSignature + + // and then after compilation, run the Animal Sniffer tool + 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ task checkstylePublicSources(type: Checkstyle) {