xref: /aosp_15_r20/external/grpc-grpc-java/binder/build.gradle (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1plugins {
2    id "maven-publish"
3    id "com.android.library"
4}
5
6description = 'gRPC BinderChannel'
7
8android {
9    namespace 'io.grpc.binder'
10    compileSdkVersion 33
11    compileOptions {
12        sourceCompatibility 1.8
13        targetCompatibility 1.8
14    }
15    defaultConfig {
16        minSdkVersion 19
17        targetSdkVersion 33
18        versionCode 1
19        versionName "1.0"
20        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21        multiDexEnabled true
22    }
23    lintOptions { abortOnError false }
24    publishing {
25        singleVariant('release') {
26            withSourcesJar()
27            withJavadocJar()
28        }
29    }
30}
31
32repositories {
33    google()
34    mavenCentral()
35}
36
37dependencies {
38    api project(':grpc-core')
39
40    implementation libraries.androidx.annotation
41    implementation libraries.androidx.core
42    implementation libraries.androidx.lifecycle.common
43    implementation libraries.guava
44    testImplementation libraries.androidx.core
45    testImplementation libraries.androidx.test.core
46    testImplementation libraries.androidx.lifecycle.common
47    testImplementation libraries.androidx.lifecycle.service
48    testImplementation libraries.junit
49    testImplementation libraries.mockito.core
50    testImplementation (libraries.robolectric) {
51        // Unreleased change: https://github.com/robolectric/robolectric/pull/5432
52        exclude group: 'com.google.auto.service', module: 'auto-service'
53    }
54    testImplementation (libraries.guava.testlib) {
55        exclude group: 'junit', module: 'junit'
56    }
57    testImplementation libraries.truth
58    testImplementation project(':grpc-testing')
59    testImplementation testFixtures(project(':grpc-core'))
60
61    androidTestAnnotationProcessor libraries.auto.value
62    androidTestImplementation project(':grpc-testing')
63    androidTestImplementation project(':grpc-protobuf-lite')
64    androidTestImplementation libraries.auto.value.annotations
65    androidTestImplementation libraries.junit
66    androidTestImplementation libraries.androidx.core
67    androidTestImplementation libraries.androidx.test.core
68    androidTestImplementation libraries.androidx.test.rules
69    androidTestImplementation libraries.androidx.test.ext.junit
70    androidTestImplementation libraries.truth
71    androidTestImplementation libraries.mockito.android
72    androidTestImplementation libraries.androidx.lifecycle.service
73    androidTestImplementation (libraries.guava.testlib) {
74        exclude group: 'junit', module: 'junit'
75    }
76    androidTestImplementation testFixtures(project(':grpc-core'))
77}
78
79import net.ltgt.gradle.errorprone.CheckSeverity
80
81tasks.withType(JavaCompile).configureEach {
82    options.compilerArgs += [
83            "-Xlint:-cast"
84    ]
85    appendToProperty(it.options.errorprone.excludedPaths, ".*/R.java", "|")
86}
87
88tasks.register("javadocs", Javadoc) {
89    source = android.sourceSets.main.java.srcDirs
90    exclude 'io/grpc/binder/internal/**'
91    exclude 'io/grpc/binder/Internal*'
92    classpath += files(android.getBootClasspath())
93    classpath += files({
94        android.libraryVariants.collect { variant ->
95            variant.javaCompileProvider.get().classpath
96        }
97    })
98    options {
99        // Disable JavaDoc doclint on Java 8.
100        if (JavaVersion.current().isJava8Compatible()) {
101            addStringOption('Xdoclint:none', '-quiet')
102        }
103    }
104    // This is to enable moving to Java 11. An existing problem with javadoc
105    // produces a warning under Java 8, but with Java 11 it fails the build.
106    failOnError false
107}
108
109tasks.register("javadocJar", Jar) {
110    dependsOn javadocs
111    archiveClassifier = 'javadoc'
112    from javadocs.destinationDir
113}
114
115tasks.register("sourcesJar", Jar) {
116    archiveClassifier = 'sources'
117    from android.sourceSets.main.java.srcDirs
118}
119
120publishing {
121    publications {
122        maven {
123            afterEvaluate {
124                from components.release
125            }
126        }
127    }
128}
129