| plugins { |
| id "maven-publish" |
| id "com.android.library" |
| } |
| |
| description = 'gRPC BinderChannel' |
| |
| android { |
| namespace = 'io.grpc.binder' |
| compileSdkVersion 34 |
| compileOptions { |
| sourceCompatibility 1.8 |
| targetCompatibility 1.8 |
| } |
| defaultConfig { |
| minSdkVersion 23 |
| targetSdkVersion 33 |
| versionCode 1 |
| versionName "1.0" |
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| } |
| lintOptions { abortOnError = false } |
| buildTypes { |
| debug { |
| testCoverageEnabled true // For robolectric unit tests. |
| enableUnitTestCoverage true // For tests that run on an emulator. |
| } |
| } |
| |
| publishing { |
| singleVariant('release') { |
| withSourcesJar() |
| withJavadocJar() |
| } |
| } |
| testFixtures { enable = true } |
| } |
| |
| repositories { |
| google() |
| } |
| |
| dependencies { |
| api project(':grpc-api') |
| |
| implementation project(':grpc-core') |
| implementation libraries.androidx.annotation |
| implementation libraries.androidx.core |
| implementation libraries.androidx.lifecycle.common |
| implementation libraries.guava |
| testImplementation libraries.androidx.core |
| testImplementation libraries.androidx.test.core |
| testImplementation libraries.androidx.lifecycle.common |
| testImplementation libraries.androidx.lifecycle.service |
| testImplementation libraries.junit |
| testImplementation libraries.mockito.core |
| testImplementation libraries.robolectric |
| testImplementation libraries.guava.testlib |
| testImplementation libraries.truth |
| testImplementation project(':grpc-protobuf-lite') |
| testImplementation project(':grpc-testing') |
| testImplementation project(':grpc-inprocess') |
| testImplementation testFixtures(project(':grpc-core')) |
| testImplementation testFixtures(project(':grpc-api')) |
| |
| androidTestAnnotationProcessor libraries.auto.value |
| androidTestImplementation project(':grpc-testing') |
| androidTestImplementation project(':grpc-protobuf-lite') |
| androidTestImplementation libraries.auto.value.annotations |
| androidTestImplementation libraries.junit |
| androidTestImplementation libraries.androidx.core |
| androidTestImplementation libraries.androidx.test.core |
| androidTestImplementation libraries.androidx.test.rules |
| androidTestImplementation libraries.androidx.test.ext.junit |
| androidTestImplementation libraries.truth |
| androidTestImplementation libraries.mockito.android |
| androidTestImplementation libraries.androidx.lifecycle.service |
| androidTestImplementation libraries.guava.testlib |
| androidTestImplementation testFixtures(project(':grpc-core')) |
| |
| testFixturesImplementation libraries.guava.testlib |
| testFixturesImplementation testFixtures(project(':grpc-core')) |
| } |
| |
| import net.ltgt.gradle.errorprone.CheckSeverity |
| |
| tasks.withType(JavaCompile).configureEach { |
| options.compilerArgs += [ |
| "-Xlint:-cast", |
| // For junit-1.15-api & org.robolectric/shadows-framework/4.11.1 |
| "-Xlint:-classfile", |
| // Unclaimed annotations. TODO(jdcormie): Fix? |
| "-Xlint:-processing", |
| ] |
| appendToProperty(it.options.errorprone.excludedPaths, ".*/R.java", "|") |
| } |
| |
| tasks.register("javadocs", Javadoc) { |
| source = android.sourceSets.main.java.srcDirs |
| exclude 'io/grpc/binder/internal/**' |
| exclude 'io/grpc/binder/Internal*' |
| classpath += files(android.getBootClasspath()) |
| classpath += files({ |
| android.libraryVariants.collect { variant -> |
| variant.javaCompileProvider.get().classpath |
| } |
| }) |
| options { |
| // Disable JavaDoc doclint on Java 8. |
| if (JavaVersion.current().isJava8Compatible()) { |
| addStringOption('Xdoclint:none', '-quiet') |
| } |
| } |
| // This is to enable moving to Java 11. An existing problem with javadoc |
| // produces a warning under Java 8, but with Java 11 it fails the build. |
| failOnError false |
| } |
| |
| tasks.register("javadocJar", Jar) { |
| dependsOn javadocs |
| archiveClassifier = 'javadoc' |
| from javadocs.destinationDir |
| } |
| |
| tasks.register("sourcesJar", Jar) { |
| archiveClassifier = 'sources' |
| from android.sourceSets.main.java.srcDirs |
| } |
| |
| publishing { |
| publications { |
| maven { |
| afterEvaluate { |
| from components.release |
| } |
| } |
| } |
| } |
| |
| afterEvaluate { |
| components.release.withVariantsFromConfiguration(configurations.releaseTestFixturesVariantReleaseApiPublication) { skip() } |
| components.release.withVariantsFromConfiguration(configurations.releaseTestFixturesVariantReleaseRuntimePublication) { skip() } |
| } |
| |
| tasks.withType(Test) { |
| // Robolectric modifies classes in memory at runtime, so they lack a java.security.CodeSource |
| // URL to their on-disk location. By default, JaCoCo ignores classes without this property. |
| // Overriding this allows Robolectric tests to be instrumented. |
| jacoco.includeNoLocationClasses = true |
| // Don't instrument certain JDK internals protected from modification by JEP 403's "strong |
| // encapsulation." Avoids IllegalAccessError, InvalidClassException and similar at runtime. |
| jacoco.excludes = ["jdk.internal.**"] |
| } |
| |
| // Android projects don't automatically get a coverage report task. We must |
| // register one manually here and wire it up to AGP's test tasks. |
| tasks.register("jacocoTestReport", JacocoReport) { |
| dependsOn "testDebugUnitTest" |
| |
| reports { |
| // For codecov.io and coveralls. |
| xml.required = true |
| // Use the same output location as the other subprojects. |
| html.outputLocation = layout.buildDirectory.dir("reports/jacoco/test/html") |
| } |
| |
| sourceDirectories.from = android.sourceSets.main.java.srcDirs |
| classDirectories.from = fileTree(dir: layout.buildDirectory.dir("intermediates/javac/debug/classes"), |
| excludes: ['**/R.class', '**/R$*.class', '**/BuildConfig.class', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']) |
| executionData.from = tasks.named("testDebugUnitTest").map { it.jacoco.destinationFile } |
| } |