blob: 00c8979a5f9cdae484d8ca9884f124499feb6aca [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
import androidx.build.RunApiTasks
plugins {
id("AndroidXPlugin")
id("java-library")
id("com.google.protobuf")
id("com.github.johnrengelman.shadow")
}
configurations {
shadowed
compileOnly.extendsFrom(shadowed)
testCompile.extendsFrom(shadowed)
}
dependencies {
implementation("androidx.annotation:annotation:1.1.0")
shadowed(libs.protobufLite)
}
// HACK: Move standard JAR to have another suffix and build a shadowJar with
// no classifier (so it's picked up as the primary artifact).
jar {
archiveClassifier = 'before-shadow'
}
shadowJar {
archiveClassifier = ''
configurations = [project.configurations.shadowed]
relocate "com.google.protobuf", "androidx.wear.protolayout.protobuf"
exclude("**/*.proto")
}
configurations {
apiElements.outgoing.artifacts.clear()
apiElements.outgoing.artifact(shadowJar) {
builtBy shadowJar
}
runtimeElements.outgoing.artifacts.clear()
runtimeElements.outgoing.artifact(shadowJar) {
builtBy shadowJar
}
}
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
}
generateProtoTasks {
ofSourceSet("main").each { task ->
sourceSets.main.java.srcDir(task)
}
all().each { task ->
task.builtins {
java {
option 'lite'
}
}
}
}
}
afterEvaluate {
lint {
lintOptions {
// protobuf generates unannotated and synthetic accessor methods
disable("UnknownNullness", "SyntheticAccessor")
}
}
}
androidx {
name = "Wear ProtoLayout Proto"
type = LibraryType.PUBLISHED_LIBRARY
inceptionYear = "2022"
description = "Jarjar the generated proto and proto-lite dependency for use by wear-protolayout"
runApiTasks = new RunApiTasks.No("Metalava doesn't properly parse the proto sources " +
"(b/180579063)")
}