| /* |
| * 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("java-library") |
| id("com.github.johnrengelman.shadow") |
| id("com.google.protobuf") |
| } |
| |
| configurations { |
| shadowed |
| compileOnly.extendsFrom(shadowed) |
| testCompile.extendsFrom(shadowed) |
| |
| // Make sure that only the shadowJar is included in the outgoing artifacts. |
| apiElements.outgoing.artifacts.clear() |
| apiElements.outgoing.artifact(shadowJar) { |
| builtBy shadowJar |
| } |
| runtimeElements.outgoing.artifacts.clear() |
| runtimeElements.outgoing.artifact(shadowJar) { |
| builtBy shadowJar |
| } |
| } |
| |
| dependencies { |
| shadowed(libs.protobufLite) |
| |
| implementation("androidx.annotation:annotation:1.1.0") |
| } |
| |
| // Move standard JAR to have another suffix. We will then build a shadowJar with |
| // no classifier (where archiveClassifier = '') so it's picked up as the primary artifact. |
| jar { |
| archiveClassifier = 'before-shadow' |
| } |
| |
| // Classifier differentiates between different artifacts built from the same project. |
| // The default is an empty string when using the Java plugin. Building shadowJar with an empty |
| // classifier causes the shadow Jar file to be picked up as the primary artifact. |
| shadowJar { |
| archiveClassifier = '' |
| configurations = [project.configurations.shadowed] |
| relocate "com.google.protobuf", "androidx.appactions.interaction.protobuf" |
| exclude("**/*.proto") |
| } |
| |
| assemble.dependsOn(shadowJar) |
| |
| protobuf { |
| protoc { |
| artifact = libs.protobufCompiler.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 -> |
| 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") |
| } |
| } |
| // Explicitly declares generateProto as a dependency for generateApi so |
| // API task can run normally. |
| project.tasks.getByName("generateApi") { |
| dependsOn(":appactions:interaction:interaction-proto:generateProto") |
| } |
| // Explicitly declares generateTestProto as a dependency for some of the lint tasks |
| // run on regular AndroidX libraries. |
| project.tasks.getByName("generateTestProto") { |
| mustRunAfter(":appactions:interaction:interaction-proto:lintReport") |
| mustRunAfter(":appactions:interaction:interaction-proto:lintAnalyze") |
| } |
| } |
| |
| androidx { |
| name = "androidx.appactions.interaction:interaction-proto" |
| type = LibraryType.PUBLISHED_LIBRARY |
| inceptionYear = "2022" |
| description = "Protos for use with App Action interaction libraries." |
| } |