1 /* <lambda>null2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.build.stableaidl 18 19 import androidx.build.BUILD_ON_SERVER_TASK 20 import androidx.build.getSupportRootFolder 21 import androidx.stableaidl.withStableAidlPlugin 22 import java.io.File 23 import org.gradle.api.Project 24 25 fun Project.setupWithStableAidlPlugin() = 26 this.withStableAidlPlugin { ext -> 27 ext.checkAction.apply { 28 before(project.tasks.named("check")) 29 before(project.tasks.named(BUILD_ON_SERVER_TASK)) 30 before( 31 project.tasks.register("checkAidlApi") { task -> 32 task.group = "API" 33 task.description = 34 "Checks that the API surface generated Stable AIDL sources " + 35 "matches the checked in API surface" 36 } 37 ) 38 } 39 40 ext.updateAction.apply { 41 before(project.tasks.named("updateApi")) 42 before( 43 project.tasks.register("updateAidlApi") { task -> 44 task.group = "API" 45 task.description = 46 "Updates the checked in API surface based on Stable AIDL sources" 47 } 48 ) 49 } 50 51 // Don't show tasks added by the Stable AIDL plugin. 52 ext.taskGroup = null 53 54 // The framework supports Stable AIDL definitions starting in SDK 36. Prior to that, we'll 55 // need to use manually-defined stubs. 56 ext.shadowFrameworkDir.set( 57 File(project.getSupportRootFolder(), "buildSrc/stableAidlImports") 58 ) 59 } 60