blob: b2ab25efe13094bed767a53731bdf71e514162c5 [file] [log] [blame]
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import androidx.build.Publish
import androidx.build.RunApiTasks
plugins {
id("AndroidXPlugin")
id("java-library")
id("com.google.protobuf")
}
dependencies {
implementation(libs.grpcProtobufLite) {
// Ensure we only bundle grpc-protobuf-lite. Any of its dependencies should be added
// as `compileOnly` dependencies below.
exclude group: 'com.google.protobuf'
exclude group: 'com.google.guava'
exclude group: 'io.grpc'
exclude group: 'com.google.code.findbugs'
}
// We need to use the non-shadow configurations at compile time to pick up the protos at the
// original package location (before renaming) since that's what the compiled service protos
// expect. The final AAR (interaction-service) will have the renamed/shadowed configurations.
compileOnly(project(path:":appactions:interaction:interaction-proto", configuration:"protoJar"))
// These are the compile-time dependencies needed to build the interaction-service-proto
// with the grpc-protobuf-lite dependencies bundled. They need to be added as dependencies in
// any library that bundles interaction-service-proto.
compileOnly(libs.protobufLite)
compileOnly(libs.grpcStub)
compileOnly(libs.jsr250)
compileOnly("androidx.annotation:annotation:1.1.0")
}
jar {
exclude "**/*.proto"
}
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
}
// Configure the codegen plugins for GRPC.
plugins {
grpc {
artifact = libs.grpcProtobufCompiler.get()
}
}
// Generates the java proto-lite code for the protos in this project. See
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
generateProtoTasks {
// Add any additional directories specified in the "main" source set to the Java
// source directories of the main source set.
ofSourceSet("main").each { task ->
project.sourceSets.main.java.srcDir(task)
}
all().each { task ->
task.builtins {
java {
option "lite"
}
}
task.plugins {
grpc {
option 'lite'
}
}
}
}
}
afterEvaluate {
lint {
lintOptions {
// protobuf generates unannotated methods
disable("UnknownNullness")
abortOnError(false)
checkReleaseBuilds(false)
}
}
}
androidx {
name = "androidx.appactions.interaction:interaction-service-proto"
publish = Publish.NONE
inceptionYear = "2023"
description = "Internal protos for Interaction Service"
runApiTasks = new RunApiTasks.No("No public API required for internal use with app widgets.")
}