Kotlin native linux works offline with verification
Also, fix importMaven to also download artifacts that are needed
by kmp targets and not visible to a jvm configuration.
Also also, start honoring command-line platform enablement
properties again.
Test: ./gradlew --offline --no-configuration-cache \
-Pandroidx.kmp.linux.enabled=true \
collection2:collection2:linuxX64Test
Bug: 218533875
Change-Id: Ib2b8771165f945b713d2338ef3f83f7af32df8ab
diff --git a/collection2/collection2/build.gradle b/collection2/collection2/build.gradle
index 844cb84..ab99a7f 100644
--- a/collection2/collection2/build.gradle
+++ b/collection2/collection2/build.gradle
@@ -39,13 +39,18 @@
// 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']?.toBoolean() ?: false
+def boolProperty(name) {
+ return project.providers.gradleProperty(name).getOrNull()?.toBoolean()
+}
-def enableMac = project.properties['androidx.kmp.mac.enabled']?.toBoolean() ?: githubBuild
+def platformEnabled(platformString) {
+ return boolProperty("androidx.kmp.${platformString}.enabled")
+}
-def enableJs = project.properties['androidx.kmp.js.enabled']?.toBoolean() ?: githubBuild
-
-def enableLinux = project.properties['androidx.kmp.linux.enabled']?.toBoolean() ?: githubBuild
+def githubBuild = boolProperty('androidx.github.build') ?: false
+def enableJs = platformEnabled('js') ?: githubBuild
+def enableLinux = platformEnabled('linux') ?: githubBuild
+def enableMac = platformEnabled('mac') ?: githubBuild
kotlin {
jvm {
@@ -136,7 +141,7 @@
}
}
- if (enableLinux) {
+ if (enableLinux) {
configure([linuxX64Test]) {
dependsOn nativeTest
}
@@ -205,6 +210,14 @@
}
}
+if (!githubBuild) {
+ tasks.withType(KotlinNativeCompile).configureEach {
+ kotlinOptions {
+ freeCompilerArgs += ["-Xoverride-konan-properties=dependenciesUrl=file:../../prebuilts/androidx/konan"]
+ }
+ }
+}
+
def japicmpProvider = tasks.register("japicmp", JapicmpTask) { task ->
def jvmJar = tasks.getByName("jvmJar")
dependsOn(jvmJar)
diff --git a/development/importMaven/build.gradle.kts b/development/importMaven/build.gradle.kts
index 7bd407d..97804c5 100644
--- a/development/importMaven/build.gradle.kts
+++ b/development/importMaven/build.gradle.kts
@@ -73,6 +73,11 @@
// add our requested dependency passed it through the gradle property -PartifactNames="foo:bar:1.0"
plugins {
java
+ alias(libs.plugins.kotlinMp)
+}
+
+kotlin {
+ linuxX64()
}
val metalavaBuildId: String? = findProperty("metalavaBuildId") as String?
@@ -155,6 +160,17 @@
extendsFrom(configurations.runtimeClasspath.get())
}
+/**
+ * Configuration used to fetch the requested dependency's Kotlin API dependencies.
+ * (klib, etc)
+ */
+val kotlinApiConfiguration: Configuration by configurations.creating {
+ attributes {
+ attribute(Usage.USAGE_ATTRIBUTE, objects.named("kotlin-api"))
+ }
+ extendsFrom(configurations.runtimeClasspath.get())
+}
+
dependencies {
// We reuse the runtimeClasspath configuration provided by the java gradle plugin by
// extending it in our directDependencyConfiguration and allDependenciesConfiguration,
@@ -497,6 +513,18 @@
copyArtifact(it, internal = isInternalArtifact(it))
numArtifactsFound++
}
+
+ // catch any artifacts that are needed to resolve this as a non-JVM
+ // Kotlin dependency
+ kotlinApiConfiguration.incoming.artifactView {
+ // We need to be lenient because we are requesting files that might not exist.
+ lenient(true)
+ }.artifacts.forEach {
+ if (copiedArtifacts.contains(it.file)) return@forEach
+ copyArtifact(it, internal = isInternalArtifact(it))
+ numArtifactsFound++
+ }
+
if (numArtifactsFound < 1) {
var message = "Artifact(s) ${artifactNames.joinToString { it }} not found!"
if (metalavaBuildId != null) {
diff --git a/development/importMaven/import_maven_artifacts.py b/development/importMaven/import_maven_artifacts.py
index 980ac1e..1b5b25f 100755
--- a/development/importMaven/import_maven_artifacts.py
+++ b/development/importMaven/import_maven_artifacts.py
@@ -50,7 +50,8 @@
required=False, action='store_true')
parse_result = parser.parse_args()
artifact_name = parse_result.name
- if ("kotlin-native-linux" in artifact_name): artifact_name = fix_kotlin_native(artifact_name)
+ if ("kotlin-native-linux" in artifact_name or "kotlin-native-prebuilt-linux" in artifact_name):
+ artifact_name = fix_kotlin_native(artifact_name)
# Add -Dorg.gradle.debug=true to debug or --stacktrace to see the stack trace
command = './gradlew --build-file build.gradle.kts --no-configuration-cache -PartifactNames=%s' % (
diff --git a/development/importMaven/settings.gradle.kts b/development/importMaven/settings.gradle.kts
index e69de29..eaf86e3 100644
--- a/development/importMaven/settings.gradle.kts
+++ b/development/importMaven/settings.gradle.kts
@@ -0,0 +1,7 @@
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../../gradle/libs.versions.toml"))
+ }
+ }
+}
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 04c0e34..9f35b0a 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -182,3 +182,4 @@
[plugins]
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
+kotlinMp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 346d3c7..7c13cc3 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -939,7 +939,22 @@
<sha256 value="4d91d6bad8c1aed65755fd532a0ae1ca75995829b17c96e67c53655c62eade7d" origin="Generated by Gradle"/>
</artifact>
</component>
- <!-- Unsigned -->
+ <!--
+ We actually have signatures for these atomicfu artifacts, but due to
+ b/218899529, gradle is not picking them up, so we are including
+ checksums for now.
+ -->
+ <component group="org.jetbrains.kotlinx" name="atomicfu-linuxx64" version="0.14.4">
+ <artifact name="atomicfu-cinterop-interop.klib">
+ <sha256 value="c2772742220cf688a8d7ae8b0d4a4892ae235c50c418a50a3cfa79905bf203d3" origin="Generated by Gradle"/>
+ </artifact>
+ <artifact name="atomicfu-linuxx64-0.14.4.module">
+ <sha256 value="21bdde2472cabc9a55a0a7f6cf672f2d1329245fb2c7caba82210a42e1c359c7" origin="Generated by Gradle"/>
+ </artifact>
+ <artifact name="atomicfu.klib">
+ <sha256 value="088a64bd3c3050e57d14cbb52a85792c93d985e838cd9cd42790b2f3ba2c294c" origin="Generated by Gradle"/>
+ </artifact>
+ </component>
<component group="org.jetbrains.skiko" name="skiko" version="0.5.2">
<artifact name="skiko-0.5.2.jar">
<sha256 value="ca02f8c97308fe2334295013e4180c5a6d9be6a06d5e05a797c1d0d8fd5861a0" origin="Generated by Gradle"/>