Skip to content

Commit

Permalink
Add packageAndroid* variants to the package group (#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz authored Aug 27, 2024
1 parent 742ad32 commit 252b359
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import korlibs.korge.gradle.targets.jvm.*
import korlibs.korge.gradle.util.*
import org.gradle.api.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.compile.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.gradle.configurationcache.extensions.*
import java.io.*

fun Project.configureAndroidDirect(projectType: ProjectType, isKorge: Boolean) {
Expand Down Expand Up @@ -208,6 +207,15 @@ fun Project.configureAndroidDirect(projectType: ProjectType, isKorge: Boolean) {
val compileDebugJavaWithJavac = project.tasks.findByName("compileDebugJavaWithJavac") as? org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile?
compileDebugJavaWithJavac?.compilerOptions?.jvmTarget?.set(ANDROID_JVM_TARGET)

for (kind in listOf("debug", "release")) {
val kindCap = kind.capitalized()
tasks.create("packageAndroid$kindCap", Task::class.java) {
it.dependsOn("bundle$kindCap")
it.group = GROUP_KORGE_PACKAGE
it.description = "Creates an AAB $kind file in the `build/outputs/bundle/$kind` folder (replaces APK)"
}
}

//tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile::class.java).configureEach {
// it.compilerOptions.jvmTarget.set(ANDROID_JVM_TARGET)
// //it.jvmTargetValidationMode.set(org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.WARNING)
Expand Down
Binary file modified buildSrc/src/main/resources/banners/korge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ package com.soywiz.kproject
import org.gradle.api.*
import java.io.*

object AndroidConfig {
fun getAndroidManifestFile(
project: Project,
minSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_MIN_SDK,
targetSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_TARGET_SDK,
compileSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_COMPILE_SDK,
): File {
return File(project.buildDir, "AndroidManifest.xml").also {
if (!it.exists()) {
it.parentFile.mkdirs()
it.writeText(buildString {
appendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
appendLine("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">")
appendLine(" <uses-sdk android:minSdkVersion=\"${minSdk}\" android:targetSdkVersion=\"${targetSdk}\" />")
appendLine("</manifest>")
})
}
}
}
}
//object AndroidConfig {
// fun getAndroidManifestFile(
// project: Project,
// minSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_MIN_SDK,
// targetSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_TARGET_SDK,
// compileSdk: Int = korlibs.korge.gradle.targets.android.ANDROID_DEFAULT_COMPILE_SDK,
// ): File {
// return File(project.buildDir, "AndroidManifest.xml").also {
// if (!it.exists()) {
// it.parentFile.mkdirs()
// it.writeText(buildString {
// appendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
// appendLine("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">")
// //appendLine(" <uses-sdk android:minSdkVersion=\"${minSdk}\" android:targetSdkVersion=\"${targetSdk}\" />")
// appendLine("</manifest>")
// })
// }
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class KProjectPlugin : Plugin<Project> {
compilations.all {
it.kotlinOptions.jvmTarget = androidJvmVersion
}

}
project.afterEvaluate {
val compileDebugJavaWithJavac = project.tasks.findByName("compileDebugJavaWithJavac") as? org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile?
Expand All @@ -78,16 +77,20 @@ class KProjectPlugin : Plugin<Project> {
val compileSdk = ANDROID_DEFAULT_COMPILE_SDK
val targetSdk = ANDROID_DEFAULT_TARGET_SDK
val minSdk = ANDROID_DEFAULT_MIN_SDK
this.compileSdk = ANDROID_DEFAULT_COMPILE_SDK
this.compileSdk = compileSdk
this.defaultConfig {
this.minSdk = minSdk
this.targetSdk = targetSdk
}
namespace = ("${project.group}.${project.name}").replace("-", ".")
sourceSets.apply {
maybeCreate("main").apply {
manifest.srcFile(AndroidConfig.getAndroidManifestFile(
project,
minSdk = minSdk,
targetSdk = targetSdk,
compileSdk = compileSdk,
))
//manifest.srcFile(AndroidConfig.getAndroidManifestFile(
// project,
// minSdk = minSdk,
// targetSdk = targetSdk,
// compileSdk = compileSdk,
//))
}
}
}
Expand Down

0 comments on commit 252b359

Please sign in to comment.