From 019ab7c1338156121fc724bca8b25f0ba38d3b0a Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 17 May 2024 12:42:01 +0200 Subject: [PATCH 01/11] Update --- .github/workflows/integration-test.yml | 46 +++ integration-test/androidApp/build.gradle.kts | 48 +++ .../androidApp/src/main/AndroidManifest.xml | 17 + .../sample/kmp/app/android/MainActivity.kt | 40 ++ .../kmp/app/android/MyApplicationTheme.kt | 55 +++ .../androidApp/src/main/res/values/styles.xml | 3 + integration-test/iosApp/Podfile | 5 + integration-test/iosApp/Podfile.lock | 16 + .../iosApp/iosApp.xcodeproj/project.pbxproj | 383 ++++++++++++++++++ .../contents.xcworkspacedata | 10 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 +++++ .../iosApp/Assets.xcassets/Contents.json | 6 + .../iosApp/iosApp/ContentView.swift | 16 + integration-test/iosApp/iosApp/Info.plist | 48 +++ .../Preview Assets.xcassets/Contents.json | 6 + integration-test/iosApp/iosApp/iOSApp.swift | 10 + integration-test/shared/build.gradle.kts | 55 +++ integration-test/shared/shared.podspec | 50 +++ .../kotlin/sample/kmp/app/Platform.android.kt | 7 + .../kotlin/sample/kmp/app/Greeting.kt | 9 + .../kotlin/sample/kmp/app/Platform.kt | 7 + .../kotlin/sample/kmp/app/Platform.ios.kt | 9 + 23 files changed, 955 insertions(+) create mode 100644 .github/workflows/integration-test.yml create mode 100644 integration-test/androidApp/build.gradle.kts create mode 100644 integration-test/androidApp/src/main/AndroidManifest.xml create mode 100644 integration-test/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt create mode 100644 integration-test/androidApp/src/main/java/sample/kmp/app/android/MyApplicationTheme.kt create mode 100644 integration-test/androidApp/src/main/res/values/styles.xml create mode 100644 integration-test/iosApp/Podfile create mode 100644 integration-test/iosApp/Podfile.lock create mode 100644 integration-test/iosApp/iosApp.xcodeproj/project.pbxproj create mode 100644 integration-test/iosApp/iosApp.xcworkspace/contents.xcworkspacedata create mode 100644 integration-test/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 integration-test/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 integration-test/iosApp/iosApp/Assets.xcassets/Contents.json create mode 100644 integration-test/iosApp/iosApp/ContentView.swift create mode 100644 integration-test/iosApp/iosApp/Info.plist create mode 100644 integration-test/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 integration-test/iosApp/iosApp/iOSApp.swift create mode 100644 integration-test/shared/build.gradle.kts create mode 100644 integration-test/shared/shared.podspec create mode 100644 integration-test/shared/src/androidMain/kotlin/sample/kmp/app/Platform.android.kt create mode 100644 integration-test/shared/src/commonMain/kotlin/sample/kmp/app/Greeting.kt create mode 100644 integration-test/shared/src/commonMain/kotlin/sample/kmp/app/Platform.kt create mode 100644 integration-test/shared/src/iosMain/kotlin/sample/kmp/app/Platform.ios.kt diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 00000000..b2afa08a --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,46 @@ +name: "Integration Test" +on: + push: + branches: + - main + - release/** + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: macos-latest-xlarge + + steps: + - uses: actions/checkout@v4 + + - name: JDK setup + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + + - name: Cached Konan + uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3 + with: + path: ~/.konan + key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-konan- + + - name: Cached Gradle + uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a + + - name: Update version + run: | + ./scripts/bump-version.sh 0 1.0.0-integration-test + + - name: Publish Maven Local + run: | + ./gradlew publishToMavenLocal + + - name: Build Integration Test + run: | + ./gradlew :integration-test:shared:assemble -PincludeIntegrationTest=true diff --git a/integration-test/androidApp/build.gradle.kts b/integration-test/androidApp/build.gradle.kts new file mode 100644 index 00000000..c9fdfdde --- /dev/null +++ b/integration-test/androidApp/build.gradle.kts @@ -0,0 +1,48 @@ +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.kotlinAndroid) +} + +android { + namespace = "sample.kmp.app.android" + compileSdk = 34 + defaultConfig { + applicationId = "sample.kmp.app.android" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + implementation(projects.shared) + implementation(libs.compose.ui) + implementation(libs.compose.ui.tooling.preview) + implementation(libs.compose.material3) + implementation(libs.androidx.activity.compose) + debugImplementation(libs.compose.ui.tooling) +} \ No newline at end of file diff --git a/integration-test/androidApp/src/main/AndroidManifest.xml b/integration-test/androidApp/src/main/AndroidManifest.xml new file mode 100644 index 00000000..22d1facc --- /dev/null +++ b/integration-test/androidApp/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/integration-test/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt b/integration-test/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt new file mode 100644 index 00000000..b13749e9 --- /dev/null +++ b/integration-test/androidApp/src/main/java/sample/kmp/app/android/MainActivity.kt @@ -0,0 +1,40 @@ +package sample.kmp.app.android + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import sample.kmp.app.Greeting + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + MyApplicationTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + GreetingView(Greeting().greet()) + } + } + } + } +} + +@Composable +fun GreetingView(text: String) { + Text(text = text) +} + +@Preview +@Composable +fun DefaultPreview() { + MyApplicationTheme { + GreetingView("Hello, Android!") + } +} diff --git a/integration-test/androidApp/src/main/java/sample/kmp/app/android/MyApplicationTheme.kt b/integration-test/androidApp/src/main/java/sample/kmp/app/android/MyApplicationTheme.kt new file mode 100644 index 00000000..1edd97ba --- /dev/null +++ b/integration-test/androidApp/src/main/java/sample/kmp/app/android/MyApplicationTheme.kt @@ -0,0 +1,55 @@ +package sample.kmp.app.android + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes +import androidx.compose.material3.Typography +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun MyApplicationTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colors = if (darkTheme) { + darkColorScheme( + primary = Color(0xFFBB86FC), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } else { + lightColorScheme( + primary = Color(0xFF6200EE), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } + val typography = Typography( + bodyMedium = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) + ) + val shapes = Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp) + ) + + MaterialTheme( + colorScheme = colors, + typography = typography, + shapes = shapes, + content = content + ) +} diff --git a/integration-test/androidApp/src/main/res/values/styles.xml b/integration-test/androidApp/src/main/res/values/styles.xml new file mode 100644 index 00000000..6b4fa3d0 --- /dev/null +++ b/integration-test/androidApp/src/main/res/values/styles.xml @@ -0,0 +1,3 @@ + +