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

Prepare for build and publication using Compose Multiplatform CI #25

Merged
merged 7 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
alias(libs.plugins.compose.compiler)
alias(libs.plugins.storytale)
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsCompose)
id("org.jetbrains.compose.storytale")
eymar marked this conversation as resolved.
Show resolved Hide resolved
}

kotlin {
Expand Down Expand Up @@ -73,15 +73,15 @@ kotlin {
}

android {
namespace = "org.jetbrains.storytale.example"
namespace = "org.jetbrains.compose.storytale.example"
compileSdk = libs.versions.android.compileSdk.get().toInt()

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")

defaultConfig {
applicationId = "org.jetbrains.storytale.example"
applicationId = "org.jetbrains.compose.storytale.example"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
Expand Down Expand Up @@ -111,7 +111,7 @@ android {

compose.resources {
publicResClass = true
packageOfResClass = "org.jetbrains.storytale.example"
packageOfResClass = "org.jetbrains.compose.storytale.example"
}

compose.desktop {
Expand All @@ -120,7 +120,7 @@ compose.desktop {

nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "org.jetbrains.storytale"
packageName = "org.jetbrains.compose.storytale"
packageVersion = "1.0.0"
}
}
Expand Down
6 changes: 4 additions & 2 deletions examples/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

pluginManagement {
repositories {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
google {
mavenContent {
includeGroupAndSubgroups("androidx")
Expand All @@ -15,6 +14,10 @@ pluginManagement {
gradlePluginPortal()
mavenLocal()
}

plugins {
id("org.jetbrains.compose.storytale").version(extra["storytale.deploy.version"] as String)
}
}

dependencyResolutionManagement {
Expand All @@ -26,7 +29,6 @@ dependencyResolutionManagement {
includeGroupAndSubgroups("com.google")
}
}
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
mavenCentral()
mavenLocal()
}
Expand Down
4 changes: 2 additions & 2 deletions examples/src/commonMain/kotlin/ComposeLogo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.storytale.example.Res
import org.jetbrains.storytale.example.compose_multiplatform
import org.jetbrains.compose.storytale.example.Res
import org.jetbrains.compose.storytale.example.compose_multiplatform

@Composable
fun ComposeLogo(size: LogoSize = LogoSize.MEDIUM) {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ android.nonTransitiveRClass=true
android.useAndroidX=true

#Compose
org.jetbrains.compose.experimental.wasm.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true

#MPP
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.enableCInteropCommonization=true

kotlin.jvm.target.validation.mode=ignore

#Publication
storytale.deploy.version=0.0.1-SNAPSHOT
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ agp = "8.7.1"
android-compileSdk = "35"
android-minSdk = "26"
android-targetSdk = "35"
storytale = "1.1"

androidx-activityCompose = "1.9.3"
androidx-appcompat = "1.7.0"
Expand Down Expand Up @@ -53,5 +52,4 @@ kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref =
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
buildTimeConfig = { id = "dev.limebeck.build-time-config", version.ref = "build-time-config" }
storytale = { id = "org.jetbrains.compose.storytale", version.ref = "storytale" }
kotlinDsl = { id = "kotlin-dsl" }
8 changes: 4 additions & 4 deletions modules/compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.0")
implementation(kotlin("compiler-embeddable"))
}

sourceSets {
Expand All @@ -17,8 +17,8 @@ sourceSets {
}
}

group = "org.jetbrains.compose"
version = libs.versions.storytale.get()
group = "org.jetbrains.compose.storytale"
version = project.properties["storytale.deploy.version"] as String

val emptyJavadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
Expand All @@ -27,7 +27,7 @@ val emptyJavadocJar by tasks.registering(Jar::class) {
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "storytale-compiler-plugin"
artifactId = "compiler-plugin"
from(components["kotlin"])
}
withType<MavenPublication> {
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ kotlin {
}

group = "org.jetbrains.compose.storytale"
version = libs.versions.storytale.get()
version = project.properties["storytale.deploy.version"] as String

publishing {}

android {
namespace = "org.jetbrains.storytale.gallery"
namespace = "org.jetbrains.compose.storytale.gallery"
compileSdk = libs.versions.android.compileSdk.get().toInt()
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/src/commonMain/kotlin/story/StoryParameter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ fun StoryParameter(

@Composable
private fun StoryParameterContent(
parameters: List<StoryParameter<*>>,
modifier: Modifier = Modifier
parameters: List<StoryParameter<*>>,
modifier: Modifier = Modifier
) = when (parameters.isEmpty()) {
true -> Box(
modifier = modifier.fillMaxSize(),
Expand Down
12 changes: 6 additions & 6 deletions modules/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gradlePlugin {
plugins {
create("storytale") {
id = "org.jetbrains.compose.storytale"
implementationClass = "org.jetbrains.compose.plugin.storytale.StorytaleGradlePlugin"
implementationClass = "org.jetbrains.compose.storytale.plugin.StorytaleGradlePlugin"
}
}
}
Expand All @@ -24,8 +24,8 @@ dependencies {
implementation(libs.kotlin.poet)
}

group = "org.jetbrains.compose"
version = libs.versions.storytale.get()
group = "org.jetbrains.compose.storytale"
version = project.properties["storytale.deploy.version"] as String

val emptyJavadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
Expand All @@ -34,7 +34,7 @@ val emptyJavadocJar by tasks.registering(Jar::class) {
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "storytale"
artifactId = "gradle-plugin"
from(components["kotlin"])
}
withType<MavenPublication> {
Expand All @@ -49,12 +49,12 @@ tasks.withType<KotlinJvmCompile>().configureEach {

buildTimeConfig {
config {
packageName.set("org.jetbrains.compose.plugin.storytale")
packageName.set("org.jetbrains.compose.storytale.plugin")
objectName.set("BuildTimeConfig")
destination.set(project.layout.buildDirectory.get().asFile)

configProperties {
val PROJECT_VERSION: String by string(libs.versions.storytale.get())
val PROJECT_VERSION: String by string(version as String)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import com.android.build.gradle.AppExtension
import com.android.build.gradle.api.ApplicationVariant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import com.squareup.kotlinpoet.*
import org.gradle.api.DefaultTask
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package org.jetbrains.compose.plugin.storytale
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package org.jetbrains.compose.storytale.plugin

import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
Expand Down Expand Up @@ -75,7 +75,7 @@ open class JsSourceGeneratorTask : DefaultTask() {
| <meta charset="UTF-8">
| <title>Gallery</title>
| <script type="application/javascript" src="skiko.js"></script>
| <script type="application/javascript" src="${SCRIPT_FILE_NAME}"></script>
| <script type="application/javascript" src="$SCRIPT_FILE_NAME"></script>
| </head>
| <body style="height: 100vh; width: 100vw;">
| </body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import org.gradle.api.Project
import org.gradle.api.file.FileCollection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import com.squareup.kotlinpoet.FileSpec
import org.gradle.api.DefaultTask
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jetbrains.compose.plugin.storytale
package org.jetbrains.compose.storytale.plugin

import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.jetbrains.compose.plugin.storytale
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package org.jetbrains.compose.storytale.plugin

import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.task
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
Expand All @@ -27,9 +26,9 @@ fun Project.processNativeCompilation(extension: StorytaleExtension, target: Kotl
}

private fun Project.createNativeStorytaleCompileTask(
extension: StorytaleExtension,
target: KotlinNativeTarget,
generatorTask: NativeSourceGeneratorTask
extension: StorytaleExtension,
target: KotlinNativeTarget,
generatorTask: NativeSourceGeneratorTask
): KotlinNativeCompilation {
val storytaleBuildDir = extension.getBuildDirectory(target)
val mainCompilation = target.compilations.named(KotlinCompilation.MAIN_COMPILATION_NAME).get()
Expand Down Expand Up @@ -70,8 +69,8 @@ private fun Project.createNativeStorytaleCompileTask(
}

private fun Project.createNativeStorytaleGenerateSourceTask(
extension: StorytaleExtension,
target: KotlinNativeTarget
extension: StorytaleExtension,
target: KotlinNativeTarget
): NativeSourceGeneratorTask {
val storytaleBuildDir = extension.getBuildDirectory(target)
return task<NativeSourceGeneratorTask>("${target.name}${StorytaleGradlePlugin.STORYTALE_GENERATE_SUFFIX}") {
Expand All @@ -84,9 +83,9 @@ private fun Project.createNativeStorytaleGenerateSourceTask(
}

private fun Project.createNativeStorytaleExecTask(
compilation: KotlinNativeCompilation,
extension: StorytaleExtension,
target: KotlinNativeTarget
compilation: KotlinNativeCompilation,
extension: StorytaleExtension,
target: KotlinNativeTarget
): Task? {
if (!target.name.contains("Simulator")) return null

Expand Down Expand Up @@ -119,7 +118,7 @@ private fun Project.createNativeStorytaleExecTask(
"simctl",
"launch",
deviceId.get(),
StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_PATH
StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_PATH
)
}
exec {
Expand Down Expand Up @@ -194,11 +193,11 @@ private fun Project.findAvailableIOsRuntime(): String {
}

private fun Project.createBuildTask(
targetSuffix: String,
deviceId: Property<String>,
unzipResourceTask: UnzipResourceTask,
simulatorRegistrationTask: Task,
linkTask: KotlinNativeLink
targetSuffix: String,
deviceId: Property<String>,
unzipResourceTask: UnzipResourceTask,
simulatorRegistrationTask: Task,
linkTask: KotlinNativeLink
): Task {
return task("${StorytaleGradlePlugin.STORYTALE_TASK_GROUP}Build$targetSuffix") {
group = StorytaleGradlePlugin.STORYTALE_TASK_GROUP
Expand All @@ -223,11 +222,11 @@ private fun Project.createBuildTask(
"-project",
"${StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_NAME}/${StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_NAME}.xcodeproj",
"-scheme",
StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_NAME,
StorytaleGradlePlugin.STORYTALE_NATIVE_PROJECT_NAME,
"-destination",
"id=${deviceId.get()}",
"-derivedDataPath",
StorytaleGradlePlugin.DERIVED_DATA_DIRECTORY_NAME,
StorytaleGradlePlugin.DERIVED_DATA_DIRECTORY_NAME,
"FRAMEWORK_SEARCH_PATHS=$frameworkPath"
)
}
Expand All @@ -236,12 +235,12 @@ private fun Project.createBuildTask(
}

private fun Project.createCopyNativeResourcesTask(
platform: String,
target: KotlinNativeTarget,
targetSuffix: String,
compilation: KotlinNativeCompilation,
unzipResourceTask: UnzipResourceTask,
buildTask: Task
platform: String,
target: KotlinNativeTarget,
targetSuffix: String,
compilation: KotlinNativeCompilation,
unzipResourceTask: UnzipResourceTask,
buildTask: Task
): NativeCopyResourcesTask {
val frameworkResources = files().apply {
compilation.allKotlinSourceSets.forAll { from(it.resources.sourceDirectories) }
Expand All @@ -267,12 +266,12 @@ private fun Project.createCopyNativeResourcesTask(
}

private fun Project.createInstallApplicationToSimulatorTask(
deviceId: Property<String>,
targetSuffix: String,
platform: String,
unzipResourceTask: UnzipResourceTask,
buildTask: Task,
copyResourcesTask: Task
deviceId: Property<String>,
targetSuffix: String,
platform: String,
unzipResourceTask: UnzipResourceTask,
buildTask: Task,
copyResourcesTask: Task
): Task {
return task("${StorytaleGradlePlugin.STORYTALE_TASK_GROUP}InstallApp$targetSuffix") {
group = StorytaleGradlePlugin.STORYTALE_TASK_GROUP
Expand Down
Loading