Skip to content

Commit 4b7c28b

Browse files
author
Chao Zhang
authored
Fix build failures and bump to AGP 3.6 and Gradle 5.6.4 (#167)
The build failure was likely due to the legacy errorprone gradle plugin, which was more than 3 years ago. https://plugins.gradle.org/plugin/net.ltgt.errorprone/0.0.13 I upgraded errorprone gradle plugin to a recent version, and also bump the AGP 3.6 and Gradle 5.6.4 because the errorprone version requires a minimum Gradle 5.2. https://github.com/tbroyer/gradle-errorprone-plugin/releases/tag/v0.8 I also used the maven publish integration from AGP by using components.release https://developer.android.com/studio/build/maven-publish-plugin I currently disabled `failOnError` on javadoc, as the compilation configuration is not applied to javadoc's classpath. Gradle 6 introduced the concept of resolvable and consumable, so I would recommend we revisit it when we are on Gradle 6. I tested locally by mavenPublishToLocal using a standalone sample app with android instrumentation tests. The tests can compile successfully with proper dependency. There are some minor changes: - Prompted by IDE that Closure.DELEGATE_FIRST can be inlined - New lint warnings that are SoonBlockedPrivateAPI - Some attempts to fix javadoc errors - Removed errorprone in test modules
1 parent 2cd9fbb commit 4b7c28b

File tree

16 files changed

+121
-256
lines changed

16 files changed

+121
-256
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ local.properties
99
*.ipr
1010
*.iws
1111
*.svn
12+
.cxx/

build.gradle

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.2.1'
10-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
11-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
12-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.7.3"
9+
classpath 'com.android.tools.build:gradle:3.6.0'
10+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
11+
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
12+
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.15.1"
1313
}
1414
}
1515

@@ -45,5 +45,10 @@ artifactory {
4545
}
4646

4747
task distributeBuild(type: DistributeTask) {
48-
dependsOn ':artifactoryPublish', 'dexmaker:artifactoryPublish', 'dexmaker-mockito:artifactoryPublish', 'dexmaker-mockito-inline:artifactoryPublish', 'dexmaker-mockito-inline-extended:artifactoryPublish'
48+
dependsOn ':artifactoryPublish',
49+
'dexmaker:artifactoryPublish',
50+
'dexmaker-mockito:artifactoryPublish',
51+
'dexmaker-mockito-inline:artifactoryPublish',
52+
'dexmaker-mockito-inline-extended:artifactoryPublish'
4953
}
54+

dexmaker-mockito-inline-extended-tests/build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
10-
}
11-
12-
apply plugin: "net.ltgt.errorprone"
131
apply plugin: 'com.android.library'
142

153
android {

dexmaker-mockito-inline-extended/build.gradle

Lines changed: 9 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
1+
plugins {
2+
id("net.ltgt.errorprone") version "0.8"
103
}
11-
12-
apply plugin: "net.ltgt.errorprone"
134
apply plugin: 'com.android.library'
14-
apply plugin: 'maven-publish'
15-
apply plugin: 'ivy-publish'
16-
apply plugin: 'com.jfrog.artifactory'
5+
apply from: "$rootDir/gradle/publishing_aar.gradle"
176

187
version = VERSION_NAME
8+
description = 'Extension of the Mockito Inline API to allow mocking static methods on the Android Dalvik VM'
199

2010
android {
2111
compileSdkVersion 28
@@ -46,81 +36,13 @@ android {
4636
}
4737
}
4838

49-
tasks.withType(JavaCompile) {
50-
options.compilerArgs += ["-Xep:StringSplitter:OFF"]
51-
}
52-
53-
task sourcesJar(type: Jar) {
54-
classifier = 'sources'
55-
from android.sourceSets.main.java.srcDirs
56-
}
57-
58-
task javadoc(type: Javadoc) {
59-
source = android.sourceSets.main.java.srcDirs
60-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
61-
failOnError false
62-
}
63-
64-
task javadocJar(type: Jar, dependsOn: javadoc) {
65-
classifier = 'javadoc'
66-
from javadoc.destinationDir
67-
}
68-
69-
publishing {
70-
publications {
71-
ivyLib(IvyPublication) {
72-
from new org.gradle.api.internal.java.JavaLibrary(new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(project.getName(), 'aar', 'aar', null, new Date(), new File("$buildDir/outputs/aar/${project.getName()}-release.aar"), assemble), project.configurations.implementation.getAllDependencies())
73-
artifact sourcesJar
74-
artifact javadocJar
75-
}
76-
77-
lib(MavenPublication) {
78-
from new org.gradle.api.internal.java.JavaLibrary(new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(project.getName(), 'aar', 'aar', null, new Date(), new File("$buildDir/outputs/aar/${project.getName()}-release.aar"), assemble), project.configurations.implementation.getAllDependencies())
79-
80-
artifact sourcesJar
81-
artifact javadocJar
82-
83-
pom.withXml {
84-
asNode().children().last() + {
85-
resolveStrategy = Closure.DELEGATE_FIRST
86-
description = 'Extension of the Mockito Inline API to allow mocking static methods on the Android Dalvik VM'
87-
url 'https://github.com/linkedin/dexmaker'
88-
scm {
89-
url 'https://github.com/linkedin/dexmaker'
90-
connection 'scm:git:git://github.com/linkedin/dexmaker.git'
91-
developerConnection 'https://github.com/linkedin/dexmaker.git'
92-
}
93-
licenses {
94-
license {
95-
name 'The Apache Software License, Version 2.0'
96-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
97-
distribution 'repo'
98-
}
99-
}
100-
101-
developers {
102-
developer {
103-
id 'com.linkedin'
104-
name 'LinkedIn Corp'
105-
email ''
106-
}
107-
}
108-
}
109-
}
110-
111-
//Useful for inspecting maven artifacts in 'build/repo' after running './gradlew publish'
112-
repositories {
113-
maven {
114-
url = "$rootProject.buildDir/repo"
115-
}
116-
}
117-
}
118-
}
119-
}
120-
12139
repositories {
122-
jcenter()
12340
google()
41+
jcenter()
42+
}
43+
44+
tasks.withType(JavaCompile) {
45+
options.errorprone.errorproneArgs.add("-Xep:StringSplitter:OFF")
12446
}
12547

12648
dependencies {

dexmaker-mockito-inline-tests/build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
10-
}
11-
12-
apply plugin: "net.ltgt.errorprone"
131
apply plugin: 'com.android.library'
142

153
android {
Lines changed: 9 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
1+
plugins {
2+
id("net.ltgt.errorprone") version "0.8"
103
}
11-
12-
apply plugin: "net.ltgt.errorprone"
134
apply plugin: 'com.android.library'
14-
apply plugin: 'maven-publish'
15-
apply plugin: 'ivy-publish'
16-
apply plugin: 'com.jfrog.artifactory'
5+
apply from: "$rootDir/gradle/publishing_aar.gradle"
176

187
version = VERSION_NAME
8+
description = 'Implementation of the Mockito Inline API for use on the Android Dalvik VM'
199

2010
android {
2111
compileSdkVersion 28
@@ -41,85 +31,17 @@ android {
4131
}
4232
}
4333

44-
tasks.withType(JavaCompile) {
45-
options.compilerArgs += ["-Xep:StringSplitter:OFF"]
46-
}
47-
48-
task sourcesJar(type: Jar) {
49-
classifier = 'sources'
50-
from android.sourceSets.main.java.srcDirs
51-
}
52-
53-
task javadoc(type: Javadoc) {
54-
source = android.sourceSets.main.java.srcDirs
55-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
56-
}
57-
58-
task javadocJar(type: Jar, dependsOn: javadoc) {
59-
classifier = 'javadoc'
60-
from javadoc.destinationDir
61-
}
62-
63-
publishing {
64-
publications {
65-
ivyLib(IvyPublication) {
66-
from new org.gradle.api.internal.java.JavaLibrary(new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(project.getName(), 'aar', 'aar', null, new Date(), new File("$buildDir/outputs/aar/${project.getName()}-release.aar"), assemble), project.configurations.implementation.getAllDependencies())
67-
artifact sourcesJar
68-
artifact javadocJar
69-
}
70-
71-
lib(MavenPublication) {
72-
from new org.gradle.api.internal.java.JavaLibrary(new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(project.getName(), 'aar', 'aar', null, new Date(), new File("$buildDir/outputs/aar/${project.getName()}-release.aar"), assemble), project.configurations.implementation.getAllDependencies())
73-
74-
artifact sourcesJar
75-
artifact javadocJar
76-
77-
pom.withXml {
78-
asNode().children().last() + {
79-
resolveStrategy = Closure.DELEGATE_FIRST
80-
description = 'Implementation of the Mockito Inline API for use on the Android Dalvik VM'
81-
url 'https://github.com/linkedin/dexmaker'
82-
scm {
83-
url 'https://github.com/linkedin/dexmaker'
84-
connection 'scm:git:git://github.com/linkedin/dexmaker.git'
85-
developerConnection 'https://github.com/linkedin/dexmaker.git'
86-
}
87-
licenses {
88-
license {
89-
name 'The Apache Software License, Version 2.0'
90-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
91-
distribution 'repo'
92-
}
93-
}
94-
95-
developers {
96-
developer {
97-
id 'com.linkedin'
98-
name 'LinkedIn Corp'
99-
email ''
100-
}
101-
}
102-
}
103-
}
104-
105-
//Useful for inspecting maven artifacts in 'build/repo' after running './gradlew publish'
106-
repositories {
107-
maven {
108-
url = "$rootProject.buildDir/repo"
109-
}
110-
}
111-
}
112-
}
113-
}
114-
11534
repositories {
116-
jcenter()
11735
google()
36+
jcenter()
37+
}
38+
39+
tasks.withType(JavaCompile) {
40+
options.errorprone.errorproneArgs.add("-Xep:StringSplitter:OFF")
11841
}
11942

12043
dependencies {
12144
implementation project(':dexmaker')
12245

12346
implementation 'org.mockito:mockito-core:2.28.2', { exclude group: 'net.bytebuddy' }
12447
}
125-

dexmaker-mockito-tests/build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
10-
}
11-
12-
apply plugin: "net.ltgt.errorprone"
131
apply plugin: 'com.android.library'
142

153
android {

dexmaker-mockito-tests/src/main/java/com/android/dx/mockito/tests/BlacklistedApis.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void copyBlacklistedFields() throws Exception {
115115
parent.measure(100, 100);
116116
}
117117

118-
@SuppressLint({"PrivateApi", "CheckReturnValue"})
118+
@SuppressLint({"PrivateApi", "CheckReturnValue", "SoonBlockedPrivateApi"})
119119
@Test
120120
public void cannotCallBlackListedAfterSpying() {
121121
// Spying and mocking might change the View class's byte code
@@ -132,7 +132,7 @@ public void cannotCallBlackListedAfterSpying() {
132132
}
133133

134134
public static class CallBlackListedMethod {
135-
@SuppressLint("PrivateApi")
135+
@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi"})
136136
boolean callingBlacklistedMethodCausesException() {
137137
// Settings.Global#isValidZenMode is a blacklisted method. Resolving it should fail
138138
try {
@@ -151,7 +151,7 @@ public void spiesCannotBeUsedToCallHiddenMethods() {
151151
}
152152

153153
public static abstract class CallBlacklistedMethodAbstract {
154-
@SuppressLint("PrivateApi")
154+
@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi"})
155155
public boolean callingBlacklistedMethodCausesException() {
156156
// Settings.Global#isValidZenMode is a blacklisted method. Resolving it should fail
157157
try {

dexmaker-mockito/build.gradle

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
1+
plugins {
2+
id("net.ltgt.errorprone") version "0.8"
103
}
11-
12-
apply plugin: "net.ltgt.errorprone"
134
apply plugin: 'java'
145
apply from: "$rootDir/gradle/publishing.gradle"
156

@@ -23,6 +14,10 @@ repositories {
2314
jcenter()
2415
}
2516

17+
tasks.withType(JavaCompile) {
18+
options.errorprone.errorproneArgs.add("-Xep:StringSplitter:OFF")
19+
}
20+
2621
dependencies {
2722
implementation project(':dexmaker')
2823

dexmaker-tests/build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
buildscript {
2-
repositories {
3-
maven {
4-
url "https://plugins.gradle.org/m2/"
5-
}
6-
}
7-
dependencies {
8-
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
9-
}
10-
}
11-
12-
apply plugin: "net.ltgt.errorprone"
131
apply plugin: 'com.android.application'
142

153
android {

0 commit comments

Comments
 (0)