Skip to content

Commit 14b9b8c

Browse files
committed
Convert project to Gradle
This allows integrating an Android test project easily.
1 parent d5b8360 commit 14b9b8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+857
-2009
lines changed

Diff for: .buildscript/deploy_snapshot.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
2121
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
2222
else
2323
echo "Deploying snapshot..."
24-
mvn clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -Dmaven.test.skip=true
24+
./gradlew uploadArchives
2525
echo "Snapshot deployed!"
2626
fi

Diff for: .buildscript/settings.xml

-9
This file was deleted.

Diff for: .gitignore

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
# Eclipse
2-
.classpath
3-
.project
4-
.settings
5-
eclipsebin
6-
7-
bin
8-
gen
1+
# Gradle
2+
.gradle
93
build
10-
out
11-
lib
12-
13-
target
14-
pom.xml.*
15-
release.properties
4+
/reports
5+
local.properties
166

177
# Idea
188
.idea
199
*.iml
20-
classes
21-
22-
obj
23-
24-
#MacOS
25-
.DS_Store

Diff for: .travis.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ language: java
22

33
jdk:
44
- openjdk8
5+
- openjdk9
6+
- openjdk10
7+
- openjdk11
8+
- openjdk12
9+
- openjdk13
10+
- openjdk14
11+
- openjdk-ea
512

6-
# Ensure Javadoc and source jar generation is exercised.
7-
install: mvn install javadoc:jar source:jar -DskipTests=true -B -V
8-
script: mvn test -B
13+
install: ./gradlew assemble
14+
script: ./gradlew build
915

1016
after_success:
1117
- .buildscript/deploy_snapshot.sh
@@ -21,7 +27,3 @@ branches:
2127

2228
notifications:
2329
email: false
24-
25-
cache:
26-
directories:
27-
- $HOME/.m2

Diff for: build.gradle

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import net.ltgt.gradle.errorprone.CheckSeverity
2+
import org.gradle.internal.jvm.Jvm
3+
4+
buildscript {
5+
ext.versions = [
6+
'kotlin': '1.3.50',
7+
'okhttp': '3.14.7',
8+
'protobuf': '3.10.0',
9+
'jaxb': '2.3.1',
10+
]
11+
ext.deps = [
12+
'kotlinStdLib': "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
13+
'kotlinCoroutines': 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2',
14+
'okhttp': "com.squareup.okhttp3:okhttp:${versions.okhttp}",
15+
'mockwebserver': "com.squareup.okhttp3:mockwebserver:${versions.okhttp}",
16+
'junit': 'junit:junit:4.13',
17+
'assertj': 'org.assertj:assertj-core:3.13.2',
18+
'guava': 'com.google.guava:guava:28.1-jre',
19+
'robolectric': 'org.robolectric:robolectric:3.8',
20+
'android': 'com.google.android:android:4.1.1.4',
21+
'animalSnifferAnnotations': 'org.codehaus.mojo:animal-sniffer-annotations:1.18',
22+
'findBugsAnnotations': 'com.google.code.findbugs:jsr305:3.0.2',
23+
'androidxTestRunner': 'androidx.test:runner:1.1.0',
24+
'rxjava': 'io.reactivex:rxjava:1.3.8',
25+
'rxjava2': 'io.reactivex.rxjava2:rxjava:2.0.0',
26+
'reactiveStreams': 'org.reactivestreams:reactive-streams:1.0.3',
27+
'scalaLibrary': 'org.scala-lang:scala-library:2.13.1',
28+
'gson': 'com.google.code.gson:gson:2.8.5',
29+
'jacksonDatabind': 'com.fasterxml.jackson.core:jackson-databind:2.10.1',
30+
'jaxbApi': "javax.xml.bind:jaxb-api:${versions.jaxb}",
31+
'jaxbImpl': "org.glassfish.jaxb:jaxb-runtime:${versions.jaxb}",
32+
'moshi': 'com.squareup.moshi:moshi:1.8.0',
33+
'protobuf': "com.google.protobuf:protobuf-java:${versions.protobuf}",
34+
'simpleXml': 'org.simpleframework:simple-xml:2.7.1',
35+
'wireRuntime': 'com.squareup.wire:wire-runtime:2.2.0',
36+
'jsoup': 'org.jsoup:jsoup:1.12.1',
37+
]
38+
39+
dependencies {
40+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
41+
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.8.1'
42+
classpath 'com.android.tools.build:gradle:3.6.2'
43+
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.9.0'
44+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
45+
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.0'
46+
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8'
47+
}
48+
repositories {
49+
mavenCentral()
50+
google()
51+
jcenter()
52+
gradlePluginPortal()
53+
}
54+
}
55+
56+
subprojects {
57+
repositories {
58+
mavenCentral()
59+
google()
60+
jcenter()
61+
}
62+
63+
// Error-prone only works on JDK 11 or older currently.
64+
if (!Jvm.current().javaVersion.isJava12Compatible()) {
65+
apply plugin: 'net.ltgt.errorprone'
66+
67+
dependencies {
68+
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
69+
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
70+
}
71+
72+
tasks.withType(JavaCompile).configureEach { task ->
73+
task.options.encoding = 'UTF-8'
74+
task.sourceCompatibility = JavaVersion.VERSION_1_8
75+
task.targetCompatibility = JavaVersion.VERSION_1_8
76+
77+
task.options.errorprone {
78+
excludedPaths = '.*/build/generated/source/proto/.*'
79+
check('MissingFail', CheckSeverity.ERROR)
80+
check('MissingOverride', CheckSeverity.ERROR)
81+
check('UnusedException', CheckSeverity.ERROR)
82+
check('UnusedMethod', CheckSeverity.ERROR)
83+
check('UnusedNestedClass', CheckSeverity.ERROR)
84+
check('UnusedVariable', CheckSeverity.ERROR)
85+
}
86+
}
87+
}
88+
89+
plugins.withId('java-library') {
90+
// Animal Sniffer only works on JDK 11 or older currently.
91+
if (!Jvm.current().javaVersion.isJava12Compatible()) {
92+
project.apply plugin: 'ru.vyarus.animalsniffer'
93+
animalsniffer {
94+
sourceSets = [sourceSets.main] // Only check main sources, ignore test code.
95+
}
96+
dependencies {
97+
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
98+
99+
if (project.path != ':retrofit-converters:java8' &&
100+
project.path != ':retrofit-converters:jaxb' &&
101+
project.path != ':retrofit-adapters:java8') {
102+
signature 'net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature'
103+
}
104+
}
105+
}
106+
}
107+
108+
plugins.withType(com.android.build.gradle.BasePlugin).configureEach { plugin ->
109+
plugin.extension.compileOptions {
110+
sourceCompatibility = JavaVersion.VERSION_1_8
111+
targetCompatibility = JavaVersion.VERSION_1_8
112+
}
113+
}
114+
115+
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile).configureEach { task ->
116+
task.kotlinOptions {
117+
jvmTarget = '1.8'
118+
}
119+
}
120+
}

0 commit comments

Comments
 (0)