Skip to content

Commit

Permalink
Get Android sample apps building on JDK 11 (#531)
Browse files Browse the repository at this point in the history
Update to AGP 7, so now the full NullAway build runs on JDK 11.  The sample apps no longer build on JDK 8.
  • Loading branch information
msridhar authored Feb 4, 2022
1 parent 2c5152e commit f5ac706
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Build and test using Gradle and Java 11
uses: eskatos/gradle-command-action@v1
with:
arguments: build -x :sample-app:build
arguments: build
if: matrix.java == '11'
- name: Build and test using Gradle and Java 17
uses: eskatos/gradle-command-action@v1
Expand Down
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
// This restriction is needed due to our mix of Android and Java modules;
// without it, the build fails with a weird error.
// See https://stackoverflow.com/questions/70217853/how-to-include-android-project-in-a-gradle-multi-project-build
classpath('org.ow2.asm:asm') {
version {
strictly '9.2'
}
}
}
}
plugins {
id "com.github.sherter.google-java-format" version "0.9"
id "net.ltgt.errorprone" version "2.0.1" apply false
id "com.github.johnrengelman.shadow" version "6.1.0" apply false
id "com.github.kt3k.coveralls" version "2.12.0" apply false
id "com.android.application" version "3.5.0" apply false
id "me.champeau.jmh" version "0.6.6" apply false
}

Expand Down
1 change: 0 additions & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def build = [
commonscli : "commons-cli:commons-cli:${versions.commonscli}",

// android stuff
buildToolsVersion: "30.0.3",
compileSdkVersion: 30,
ci: "true" == System.getenv("CI"),
minSdkVersion: 16,
Expand Down
4 changes: 3 additions & 1 deletion jar-infer/jar-infer-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dependencies {
exclude group: "junit", module: "junit"
}
testImplementation project(":jar-infer:test-java-lib-jarinfer")
testImplementation project(path: ":jar-infer:test-android-lib-jarinfer", configuration: "default")
testImplementation files("${System.properties['java.home']}/../lib/tools.jar") // is there a better way?
testRuntimeOnly deps.build.errorProneCheckApi
}
Expand All @@ -65,6 +64,9 @@ test {
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
dependsOn ':jar-infer:test-android-lib-jarinfer:bundleReleaseAar'
}
}

apply plugin: 'com.vanniktech.maven.publish'
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ public void toyJARAnnotatingClasses() throws Exception {

@Test
public void toyAARAnnotatingClasses() throws Exception {
if (System.getProperty("java.version").startsWith("1.8")) {
// We only build the sample Android apps on JDK 11+
return;
}
testAnnotationInAarTemplate(
"toyAARAnnotatingClasses",
"com.uber.nullaway.jarinfer.toys.unannotated",
Expand Down
1 change: 0 additions & 1 deletion jar-infer/test-android-lib-jarinfer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ sourceCompatibility = 1.8

android {
compileSdkVersion deps.build.compileSdkVersion
buildToolsVersion deps.build.buildToolsVersion

defaultConfig {
minSdkVersion deps.build.minSdkVersion
Expand Down
5 changes: 2 additions & 3 deletions sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ plugins {

android {
compileSdkVersion deps.build.compileSdkVersion
buildToolsVersion deps.build.buildToolsVersion

defaultConfig {
applicationId "com.uber.myapplication"
Expand All @@ -33,8 +32,8 @@ android {
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

lintOptions {
Expand Down
14 changes: 3 additions & 11 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ pluginManagement {
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "com.android") {
useModule("com.android.tools.build:gradle:${requested.version}")
}
}
}
}

include ':nullaway'
include ':sample-library-model'
include ':sample'
include ':sample-app'
include ':test-java-lib'
include ':test-java-lib-lombok'
include ':test-library-models'
Expand All @@ -29,12 +21,12 @@ include ':jar-infer:jar-infer-lib'
include ':jar-infer:jar-infer-cli'
include ':jar-infer:test-java-lib-jarinfer'
include ':jar-infer:nullaway-integration-test'
include ':jar-infer:test-android-lib-jarinfer'
include ':jmh'
include ':jdk17-unit-tests'

// On Java 8, the code-coverage-report module fails during Gradle configuration. So, exclude it
// on pre-JDK-11 JVMs
// The following modules require JDK 11 and fail during Gradle configuration on JDK 8
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
include ':code-coverage-report'
include ':sample-app'
include ':jar-infer:test-android-lib-jarinfer'
}

0 comments on commit f5ac706

Please sign in to comment.