| /* |
| * Copyright 2021 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") |
| id("com.github.johnrengelman.shadow") |
| } |
| configurations { |
| shadowed |
| compileOnly.extendsFrom(shadowed) |
| testCompile.extendsFrom(shadowed) |
| } |
| dependencies { |
| constraints { |
| implementation(project(":wear:protolayout:protolayout-proto")) |
| } |
| |
| implementation("androidx.annotation:annotation:1.1.0") |
| compileOnly(libs.protobufLite) |
| // Use a non-shadow configuration during compile to pick up the proto dependencies. |
| // But declare the proper shadowed dependency externally. |
| // For some reason not specifying the configuration causes undeclared changes to the inputs to |
| // extractIncludeProto task (making it out-dated without any source change). |
| compileOnly(project(path:":wear:protolayout:protolayout-proto", configuration:"archives")) |
| api(project(path:":wear:protolayout:protolayout-proto", configuration:"default")) |
| } |
| // 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") |
| } |
| assemble.dependsOn(shadowJar) |
| 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 -> |
| project.sourceSets.main.java.srcDir(task) |
| } |
| all().each { task -> |
| task.builtins { |
| java { |
| option 'lite' |
| } |
| } |
| } |
| } |
| } |
| afterEvaluate { |
| lint { |
| lintOptions { |
| // protobuf generates unannotated methods |
| disable("UnknownNullness") |
| } |
| } |
| } |
| androidx { |
| name = "Wear Tiles Proto" |
| publish = Publish.SNAPSHOT_AND_RELEASE |
| inceptionYear = "2020" |
| description = "Jarjar the generated proto and proto-lite dependency for use by " + |
| "wear-tiles." |
| runApiTasks = new RunApiTasks.No("Metalava doesn't properly parse the proto sources " + |
| "(b/180579063)") |
| } |