blob: 69a11cbcb38824c9ce6c9679a8dbfcbd1cc9faad [file] [log] [blame]
/*
* 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.LibraryGroups
import me.champeau.gradle.japicmp.JapicmpTask
import static androidx.build.dependencies.DependenciesKt.*
import androidx.build.Publish
import androidx.build.RunApiTasks
buildscript {
dependencies {
classpath(libs.japicmpPluginz)
classpath(libs.atomicFuPluginz)
}
}
plugins {
id("AndroidXPlugin")
id("java") // https://github.com/gradle/gradle/issues/18622
id("org.jetbrains.kotlin.multiplatform")
id("me.champeau.gradle.japicmp")
}
// This should be true when building from GitHub, and false when building
// from AOSP. Use this to block out any features or code that we're not
// ready to build yet in AOSP
def githubBuild = project.properties['androidx.github.build'] ?: false
def enableMac = project.properties['androidx.kmp.mac.enabled'] ?: githubBuild
kotlin {
jvm {
withJava()
}
if (enableMac) {
macosX64 {
binaries {
framework {
baseName = "CollectionKMP"
}
}
}
}
if (githubBuild) {
js {
nodejs()
}
linuxX64()
mingwX64()
iosX64()
iosArm64()
iosArm32()
}
sourceSets {
all {
languageSettings {
progressiveMode = true
optIn("kotlin.ExperimentalStdlibApi") // STOPSHIP
}
}
commonMain {
dependencies {
api(libs.kotlinStdlibCommon)
}
}
commonTest {
dependencies {
implementation(libs.kotlinTestCommon)
implementation(libs.kotlinTestAnnotationsCommon)
}
}
if (githubBuild || enableMac) {
nonJvmMain {
// Used for JS and all native targets.
dependencies {
api(libs.atomicFu)
}
}
}
if (enableMac) {
configure([macosX64Main]) {
dependsOn nonJvmMain
}
}
if (githubBuild) {
configure([linuxX64Main, mingwX64Main, iosX64Main, iosArm32Main, iosArm64Main]) {
dependsOn nonJvmMain
}
}
if (githubBuild || enableMac) {
nativeTest // Used for all native targets.
}
if (enableMac) {
configure([macosX64Test]) {
dependsOn nativeTest
}
}
if (githubBuild) {
configure([linuxX64Test, mingwX64Test, iosX64Test, iosArm32Test, iosArm64Test]) {
dependsOn nativeTest
}
}
if (githubBuild) {
jsMain {
dependsOn nonJvmMain
dependencies {
api(libs.kotlinStdlibJs)
}
}
jsTest {
dependencies {
implementation(libs.kotlinTestJs)
}
}
}
jvmMain {
dependencies {
api(libs.kotlinStdlib)
api("androidx.annotation:annotation:1.1.0")
}
}
jvmTest {
dependencies {
implementation(libs.kotlinTestJunit)
implementation(libs.truth)
}
}
}
}
if (githubBuild || enableMac) {
// Workaround for https://youtrack.jetbrains.com/issue/KT-31603
sourceSets.test.java.srcDir('../../collection/collection/src/test/java')
}
androidx {
name = "Android Support Library collections"
publish = Publish.SNAPSHOT_AND_RELEASE
mavenGroup = LibraryGroups.COLLECTION2
inceptionYear = "2020"
description = "Standalone efficient collections."
legacyDisableKotlinStrictApiMode = true // TODO: Re-enable this!
runApiTasks = new RunApiTasks.No("metalava issues prevent api checks on kmp: b/188171162")
multiplatform = true
}
repositories {
mavenCentral()
}
configurations {
jvmApiBaseline
}
dependencies {
jvmApiBaseline('androidx.collection:collection:1.1.0') {
transitive = false
}
}
def japicmpProvider = tasks.register("japicmp", JapicmpTask) { task ->
def jvmJar = tasks.getByName("jvmJar")
dependsOn(jvmJar)
task.oldClasspath = configurations.jvmApiBaseline
task.newClasspath = files(jvmJar.archivePath)
task.onlyBinaryIncompatibleModified = true
task.failOnModification = true
task.ignoreMissingClasses = true
task.includeSynthetic = true
task.txtOutputFile = file("$buildDir/reports/japi.txt")
}
// TODO(b/190741472): runErrorProne is currently broken.
runErrorProne.enabled = false