Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packageAndroid* variants to the package group #2285

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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