|
| 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