blob: 72a6b56a7afe661983e19f12391dc2f0d9333d42 [file] [log] [blame]
/*
* Copyright (C) 2022 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.LibraryType
plugins {
id("AndroidXPlugin")
id("com.android.library")
id("com.github.johnrengelman.shadow")
id("com.google.protobuf")
}
configurations {
shadowed
compileOnly.extendsFrom(shadowed)
testCompile.extendsFrom(shadowed)
shadowJar // configuration containing Jar built by shadow plugin
protoJar // configuration containing compiled proto and source
}
dependencies {
shadowed(libs.protobufLite)
implementation("androidx.annotation:annotation:1.1.0")
}
task protoLiteJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
archiveClassifier = 'proto-lite-jar'
dependsOn(":appactions:interaction:interaction-proto:syncReleaseLibJars")
from("${buildDir}/intermediates/aar_main_jar/release")
}
assemble.dependsOn(protoLiteJar)
task shadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
archiveClassifier = 'shadow-jar'
configurations = [project.configurations.shadowed]
dependsOn(protoLiteJar)
from(protoLiteJar.archiveFile)
relocate "com.google.protobuf", "androidx.appactions.interaction.protobuf"
exclude("**/*.proto")
}
assemble.dependsOn(shadowJar)
artifacts {
// Specifies the output files for the shadowJar and protoJar configurations
shadowJar shadowJar.archiveFile
protoJar protoLiteJar.archiveFile
}
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
android {
namespace "androidx.appactions.interaction.proto"
defaultConfig {
minSdkVersion 19
}
libraryVariants.all { variant ->
// Replace the default jar with the shadow jar in the AAR.
def packageLib = variant.getPackageLibraryProvider().get()
packageLib.exclude('classes.jar')
packageLib.into('') {
from(project.tasks.getByName("shadowJar").outputs)
rename { "classes.jar" }
}
}
lintOptions {
// protobuf generates unannotated methods
disable("UnknownNullness")
}
}
androidx {
name = "androidx.appactions.interaction:interaction-proto"
type = LibraryType.PUBLISHED_LIBRARY
inceptionYear = "2022"
description = "Protos for use with App Action interaction libraries."
metalavaK2UastEnabled = true
doNotDocumentReason = "No public API"
}