Files
skiko/samples/SkiaAndroidSample/build.gradle.kts
Clément de La Bourdonnaye 6955c19e15 Make configureSignAndPublishDependencies use proper android task names (#1053)
"AndroidRelease" should be used instead of "Android" since using the
android plugin introduces release/debug variants.

Note: `./gradlew publish -Pskiko.android.enabled=true` would still fail
with the following, but this task is as I understand not used on CI and
"build repo" seem to be a local thing.
```
> Task :publishAndroidReleasePublicationToBuildRepoRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':publishAndroidReleasePublicationToBuildRepoRepository' (type 'PublishToMavenRepository').
  - Gradle detected a problem with the following location: '/Users/cdelabou/workspace/misc/skiko/skiko/build/libs/skiko-0.0.0-SNAPSHOT-javadoc.jar.asc'.
    
    Reason: Task ':publishAndroidReleasePublicationToBuildRepoRepository' uses this output of task ':signKotlinMultiplatformPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
```
2025-04-15 17:58:37 +02:00

109 lines
2.9 KiB
Kotlin

buildscript {
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
}
}
repositories {
mavenLocal()
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
plugins {
id("com.android.application") version "7.4.2"
kotlin("android") version "1.9.21"
}
val skikoNativeX64 by configurations.creating
val skikoNativeArm64 by configurations.creating
val jniDir = "${projectDir.absolutePath}/src/main/jniLibs"
// TODO: filter .so files only.
val unzipTaskX64 = tasks.register("unzipNativeX64", Copy::class) {
destinationDir = file("$jniDir/x86_64")
from(skikoNativeX64.map { zipTree(it) })
}
val unzipTaskArm64 = tasks.register("unzipNativeArm64", Copy::class) {
destinationDir = file("$jniDir/arm64-v8a")
from(skikoNativeArm64.map { zipTree(it) })
}
kotlin {
jvmToolchain(11)
}
android {
compileSdk = 31
namespace = "org.jetbrains.skiko.sample"
defaultConfig {
minSdk = 27
targetSdk = 31
versionCode = 1
versionName = "1.0"
applicationId = "org.jetbrains.skiko.sample"
ndk {
abiFilters += listOf("x86_64", "arm64-v8a")
}
}
buildTypes {
debug {
isDebuggable = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
var version = if (project.hasProperty("skiko.version")) {
project.properties["skiko.version"] as String
} else {
"0.0.0-SNAPSHOT"
}
// ./gradlew -Pskiko.android.enabled=true \
// publishSkikoJvmRuntimeAndroidX64PublicationToMavenLocal \
// publishSkikoJvmRuntimeAndroidArm64PublicationToMavenLocal \
// publishAndroidReleasePublicationToMavenLocal
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
implementation("org.jetbrains.skiko:skiko-android:$version")
skikoNativeX64("org.jetbrains.skiko:skiko-android-runtime-x64:$version")
skikoNativeArm64("org.jetbrains.skiko:skiko-android-runtime-arm64:$version")
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
dependsOn(unzipTaskX64)
dependsOn(unzipTaskArm64)
}
// SKIKO-934: we need to unpack these libraries before these are collected from android
// TODO the tasks we're actually targetting are mergeDebugJniLibFolders and mergeReleaseJniLibFolders,
// this adds unncessary dependencies
tasks.withType<com.android.build.gradle.tasks.MergeSourceSetFolders>()
.configureEach {
dependsOn(unzipTaskX64)
dependsOn(unzipTaskArm64)
}
tasks.withType<Copy> {
// This line needs to properly merge MANIFEST files from jars into dex
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}