From 1192f66487c3b11931f52e434690c0c099ae4033 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Wed, 2 May 2018 16:10:40 +0100 Subject: [PATCH] Use Animal Sniffer to check Java 6 API compatibility. --- .gitlab-ci.yml | 9 +-------- bramble-api/build.gradle | 8 +++----- bramble-core/build.gradle | 8 +++----- briar-api/build.gradle | 8 +++----- briar-core/build.gradle | 8 +++----- build.gradle | 25 +------------------------ 6 files changed, 14 insertions(+), 52 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb1109f6d..977820456 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,17 +10,10 @@ before_script: - export GRADLE_USER_HOME=$PWD/.gradle # Accept the license for the Android build tools - echo y | /opt/android-sdk/tools/bin/sdkmanager "build-tools;26.0.2" - # Download OpenJDK 6 so we can compile against its standard library - - JDK_FILE=openjdk-6-jre-headless_6b38-1.13.10-1~deb7u1_amd64.deb - - if [ ! -d openjdk ] - - then - - wget -q http://ftp.uk.debian.org/debian/pool/main/o/openjdk-6/$JDK_FILE - - dpkg-deb -x $JDK_FILE openjdk - - fi - - export JAVA_6_HOME=$PWD/openjdk/usr/lib/jvm/java-6-openjdk-amd64 test: script: + - ./gradlew animalSnifferMain animalSnifferTest - ./gradlew test after_script: diff --git a/bramble-api/build.gradle b/bramble-api/build.gradle index 76bc23409..68f66e997 100644 --- a/bramble-api/build.gradle +++ b/bramble-api/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'java-library' sourceCompatibility = 1.8 targetCompatibility = 1.8 +apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'witness' dependencies { @@ -14,6 +15,8 @@ dependencies { testImplementation "org.jmock:jmock-legacy:2.8.2" testImplementation "org.hamcrest:hamcrest-library:1.3" testImplementation "org.hamcrest:hamcrest-core:1.3" + + signature 'org.codehaus.mojo.signature:java16:1.1@signature' } dependencyVerification { @@ -48,8 +51,3 @@ task jarTest(type: Jar, dependsOn: testClasses) { artifacts { testOutput jarTest } - -// If a Java 6 JRE is available, check we're not using any Java 7 or 8 APIs -tasks.withType(JavaCompile) { - useJava6StandardLibrary(it) -} diff --git a/bramble-core/build.gradle b/bramble-core/build.gradle index 9b0eb82f4..64b9b38b2 100644 --- a/bramble-core/build.gradle +++ b/bramble-core/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'java-library' sourceCompatibility = 1.8 targetCompatibility = 1.8 +apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'net.ltgt.apt' apply plugin: 'idea' apply plugin: 'witness' @@ -26,6 +27,8 @@ dependencies { testImplementation "org.hamcrest:hamcrest-core:1.3" testApt 'com.google.dagger:dagger-compiler:2.0.2' + + signature 'org.codehaus.mojo.signature:java16:1.1@signature' } dependencyVerification { @@ -68,8 +71,3 @@ task jarTest(type: Jar, dependsOn: testClasses) { artifacts { testOutput jarTest } - -// If a Java 6 JRE is available, check we're not using any Java 7 or 8 APIs -tasks.withType(JavaCompile) { - useJava6StandardLibrary(it) -} diff --git a/briar-api/build.gradle b/briar-api/build.gradle index f55eccbbc..888644132 100644 --- a/briar-api/build.gradle +++ b/briar-api/build.gradle @@ -2,18 +2,16 @@ apply plugin: 'java-library' sourceCompatibility = 1.8 targetCompatibility = 1.8 +apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'witness' dependencies { implementation project(path: ':bramble-api', configuration: 'default') + + signature 'org.codehaus.mojo.signature:java16:1.1@signature' } dependencyVerification { verify = [ ] } - -// If a Java 6 JRE is available, check we're not using any Java 7 or 8 APIs -tasks.withType(JavaCompile) { - useJava6StandardLibrary(it) -} diff --git a/briar-core/build.gradle b/briar-core/build.gradle index 38226c1a8..ee8069de5 100644 --- a/briar-core/build.gradle +++ b/briar-core/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'java-library' sourceCompatibility = 1.8 targetCompatibility = 1.8 +apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'net.ltgt.apt' apply plugin: 'idea' apply plugin: 'witness' @@ -27,6 +28,8 @@ dependencies { testImplementation "org.hamcrest:hamcrest-core:1.3" testApt 'com.google.dagger:dagger-compiler:2.0.2' + + signature 'org.codehaus.mojo.signature:java16:1.1@signature' } dependencyVerification { @@ -59,8 +62,3 @@ dependencyVerification { 'org.slf4j:slf4j-api:1.7.16:slf4j-api-1.7.16.jar:e56288031f5e60652c06e7bb6e9fa410a61231ab54890f7b708fc6adc4107c5b', ] } - -// If a Java 6 JRE is available, check we're not using any Java 7 or 8 APIs -tasks.withType(JavaCompile) { - useJava6StandardLibrary(it) -} diff --git a/build.gradle b/build.gradle index 560a5fb4a..afb2c2081 100644 --- a/build.gradle +++ b/build.gradle @@ -22,30 +22,7 @@ buildscript { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'net.ltgt.gradle:gradle-apt-plugin:0.9' classpath 'de.undercouch:gradle-download-task:3.2.0' + classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.3' classpath files('libs/gradle-witness.jar') } } - -// If a Java 6 JRE is available, check we're not using any Java 7 or 8 APIs -ext.useJava6StandardLibrary = { task -> - def home = System.env.JAVA_6_HOME; - if (home != null && !home.isEmpty()) { - println "Setting Java 6 bootstrap classpath for ${task.name}" - task.dependsOn createJavaLangInvokeJar - task.options.bootstrapClasspath = files( - "${project.rootDir}/build/invoke.jar", - "${home}/jre/lib/rt.jar", - "${home}/jre/lib/jsse.jar" - ) - } -} - -// Create a jar containing the java.lang.invoke classes for the Java 6 bootstrap classpath -task createJavaLangInvokeJar(type: Zip) { - archiveName 'invoke.jar' - destinationDir file("${project.rootDir}/build") - from zipTree("${System.getProperty('java.home')}/lib/rt.jar").matching { - include 'java/lang/invoke/*' - } - include '**/*' -}