Skip to content

Commit

Permalink
Prepare for build and publication using Compose Multiplatform CI (#25)
Browse files Browse the repository at this point in the history
* Prepare for build and publication using Compose Multiplatform CI

* remove redundant indentation changes

* Add a smokebuild.yaml workflow

* override storytale version from libs.versions.toml if there is a gradle property `storytale.deploy.version`

* Add ComposeRepo maven repository

* Set modules version in one place for all modules

* Ensure all public API have a package org.jetbrains.compose.storytale and have the corresponding folder hierarchy
  • Loading branch information
eymar authored Dec 13, 2024
1 parent d3fa13b commit 9d0400e
Show file tree
Hide file tree
Showing 73 changed files with 156 additions and 88 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/smokebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Smoke build

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"

jobs:
build:
name: Publish to MavenLocal and Build Examples
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Checkout code
uses: actions/checkout@v3

- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal

- name: Build Stories for Wasm target
run: |
cd examples
../gradlew wasmJsBrowserStoriesProductionExecutableDistribution
- name: Build Stories for Desktop target
run: |
cd examples
../gradlew desktopStorytaleGenerate
24 changes: 24 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,28 @@ plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.compose.compiler) apply false
}

subprojects {
version = findProperty("storytale.deploy.version")
?: error("'storytale.deploy.version' was not set")

plugins.withId("maven-publish") {
configureIfExists<PublishingExtension> {
repositories {
maven {
name = "ComposeRepo"
setUrl(System.getenv("COMPOSE_REPO_URL"))
credentials {
username = System.getenv("COMPOSE_REPO_USERNAME")
password = System.getenv("COMPOSE_REPO_KEY")
}
}
}
}
}
}

inline fun <reified T> Project.configureIfExists(fn: T.() -> Unit) {
extensions.findByType(T::class.java)?.fn()
}
8 changes: 4 additions & 4 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
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
11 changes: 9 additions & 2 deletions examples/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
rootProject.name = "StorytaleUsageExamples"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

val storytaleVersion =
providers.gradleProperty("storytale.deploy.version").orNull?.takeIf(String::isNotBlank)

pluginManagement {
repositories {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
google {
mavenContent {
includeGroupAndSubgroups("androidx")
Expand All @@ -26,8 +28,13 @@ dependencyResolutionManagement {
includeGroupAndSubgroups("com.google")
}
}
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
mavenCentral()
mavenLocal()
}

if (storytaleVersion != null) {
versionCatalogs.register("libs") {
version("storytale", storytaleVersion)
}
}
}
2 changes: 1 addition & 1 deletion examples/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<activity
android:exported="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
android:name=".MainActivity">
android:name="org.jetbrains.storytale.example.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ agp = "8.7.1"
android-compileSdk = "35"
android-minSdk = "26"
android-targetSdk = "35"
storytale = "1.1"
storytale = "0.0.1"

androidx-activityCompose = "1.9.3"
androidx-appcompat = "1.7.0"
Expand Down
7 changes: 3 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,7 @@ sourceSets {
}
}

group = "org.jetbrains.compose"
version = libs.versions.storytale.get()
group = "org.jetbrains.compose.storytale"

val emptyJavadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
Expand All @@ -27,7 +26,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
3 changes: 1 addition & 2 deletions modules/gallery/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ kotlin {
}

group = "org.jetbrains.compose.storytale"
version = libs.versions.storytale.get()

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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.jetbrains.compose.storytale.gallery.story.parameters.StringParameterF
import org.jetbrains.compose.storytale.gallery.ui.component.CenterRow
import org.jetbrains.compose.storytale.gallery.ui.component.Gap
import org.jetbrains.compose.storytale.gallery.ui.theme.currentColorScheme
import utils.cast
import org.jetbrains.compose.storytale.gallery.utils.cast

@Composable
fun StoryParameter(
Expand Down 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jetbrains.compose.storytale.gallery.utils

@Throws(ClassCastException::class)
internal inline fun <reified T> Any?.cast(): T = this as T

internal inline fun <reified T> Any?.castOrNull(): T? = this as? T
6 changes: 0 additions & 6 deletions modules/gallery/src/commonMain/kotlin/utils/cast.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.jetbrains.compose.storytale.gallery

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jetbrains.compose.storytale.gallery.platform

import DesktopCodeBlock
import org.jetbrains.compose.storytale.gallery.DesktopCodeBlock
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection.Companion.Start
import androidx.compose.animation.core.animateDpAsState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.jetbrains.compose.storytale.gallery

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.HorizontalDivider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.jetbrains.compose.storytale.gallery

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection.Companion.Down
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection.Companion.Up
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jetbrains.compose.storytale.gallery.platform

import MobileGallery
import org.jetbrains.compose.storytale.gallery.MobileGallery
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection.Companion.End
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection.Companion.Start
import androidx.compose.animation.core.tween
Expand Down
11 changes: 5 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,7 @@ dependencies {
implementation(libs.kotlin.poet)
}

group = "org.jetbrains.compose"
version = libs.versions.storytale.get()
group = "org.jetbrains.compose.storytale"

val emptyJavadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
Expand All @@ -34,7 +33,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 +48,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
Loading

0 comments on commit 9d0400e

Please sign in to comment.