1/* 2 * Copyright 2025 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 18import androidx.build.PlatformIdentifier 19import androidx.build.SoftwareType 20import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 21 22plugins { 23 id("AndroidXPlugin") 24 id("com.android.library") 25 id("com.squareup.wire") 26} 27 28androidXMultiplatform { 29 jvm() 30 androidTarget() 31 defaultPlatform(PlatformIdentifier.ANDROID) 32 33 sourceSets { 34 commonMain { 35 dependencies { 36 api(project(":tracing:tracing-driver")) 37 implementation(libs.wireRuntime) 38 implementation(libs.okio) 39 } 40 } 41 commonTest { 42 dependencies { 43 implementation(libs.kotlinTestAnnotationsCommon) 44 implementation(libs.kotlinTest) 45 implementation(libs.kotlinCoroutinesCore) 46 implementation(libs.kotlinCoroutinesTest) 47 } 48 } 49 jvmTest { 50 dependsOn(commonTest) 51 dependencies { 52 implementation(libs.kotlinTestJunit) 53 implementation(libs.truth) 54 } 55 } 56 jvmMain { 57 dependsOn(commonMain) 58 } 59 androidMain { 60 dependsOn(commonMain) 61 } 62 androidInstrumentedTest { 63 // Declaring this source set even though we don't really have any instrumentation tests. 64 // This is because commonTest is implicitly treated as something that can be used for 65 // instrumentation tests. Therefore we need to include the test runner; otherwise the 66 // harness fails with an Exception. b/394958372. 67 dependsOn(commonTest) 68 dependencies { 69 implementation(libs.junit) 70 implementation(libs.testExtJunit) 71 implementation(libs.testCore) 72 implementation(libs.testRunner) 73 implementation(libs.testRules) 74 } 75 } 76 } 77} 78 79// Workarounds for Wire's plugin not setting code generation directory as task output correctly 80// See https://github.com/square/wire/issues/3199 81tasks.named("multiplatformSourceJar").configure { 82 dependsOn(tasks.named("generateCommonMainProtos")) 83} 84 85wire { 86 kotlin { 87 mutableTypes = true 88 } 89 sourcePath { 90 srcDir("src/commonMain/proto") 91 } 92} 93 94tasks.withType(KotlinCompile).configureEach { 95 kotlinOptions { 96 // Make sure to opt-in to expect-actual classes. 97 // https://youtrack.jetbrains.com/issue/KT-61573 98 freeCompilerArgs += [ 99 "-Xexpect-actual-classes", 100 ] 101 } 102} 103 104androidx { 105 name = "Tracing Driver Wire" 106 type = SoftwareType.SNAPSHOT_ONLY_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS 107 inceptionYear = "2024" 108 description = "AndroidX Tracing Driver Wire" 109 metalavaK2UastEnabled = false 110} 111 112android { 113 namespace = "androidx.tracing.driver.wire" 114} 115