From 4f2f3e0405a0335cb5e4ca81682b8dca83c04293 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Mon, 20 Jan 2025 18:01:42 +0100 Subject: [PATCH] Project for checking compatibility with Maven and JPS on CI (#5201) Will be added [on CI](https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Task4ValidateTemplatesTutorials/4947977?buildTab=log&focusLine=1209&logView=flowAware) JPS (build tool for IntelliJ) uses POM files for dependency management. Occasianally, there are errors in POM files, which leads to inability to use Compose in IntelliJ. To avoid this, better to run CI checks. This fails: ``` mvn install exec:java -Dexec.mainClass="MainKt" -Dkotlin.version=2.0.21 -Dcompose.version=1.8.0-alpha01 ``` (https://youtrack.jetbrains.com/issue/CMP-7406/CMP-1.8.0-alpha01-doesnt-work-with-JPS-and-Maven) This don't: ``` mvn install exec:java -Dexec.mainClass="MainKt" -Dkotlin.version=2.0.21 -Dcompose.version=1.8.0+dev2001 ``` --- ci/templates/maven-test-project/.gitignore | 16 ++ ci/templates/maven-test-project/README.md | 5 + ci/templates/maven-test-project/pom.xml | 189 ++++++++++++++++++ .../src/main/kotlin/Main.kt | 30 +++ tools/replaceVersion.sh | 3 + 5 files changed, 243 insertions(+) create mode 100644 ci/templates/maven-test-project/.gitignore create mode 100644 ci/templates/maven-test-project/README.md create mode 100644 ci/templates/maven-test-project/pom.xml create mode 100644 ci/templates/maven-test-project/src/main/kotlin/Main.kt diff --git a/ci/templates/maven-test-project/.gitignore b/ci/templates/maven-test-project/.gitignore new file mode 100644 index 00000000000..69651f95018 --- /dev/null +++ b/ci/templates/maven-test-project/.gitignore @@ -0,0 +1,16 @@ +*.iml +.gradle +/local.properties +/.idea +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +build/ +target/ +/captures +.externalNativeBuild +.cxx diff --git a/ci/templates/maven-test-project/README.md b/ci/templates/maven-test-project/README.md new file mode 100644 index 00000000000..8de7396e727 --- /dev/null +++ b/ci/templates/maven-test-project/README.md @@ -0,0 +1,5 @@ +The purpose of this test project is to check if Compose Multiplatform is resolvable via pom files, which are used by JPS, which is used by IntelliJ + +``` +mvn install exec:java -Dexec.mainClass="MainKt" -Dkotlin.version=2.1.0 -Dcompose.version=1.8.0-alpha02 +``` diff --git a/ci/templates/maven-test-project/pom.xml b/ci/templates/maven-test-project/pom.xml new file mode 100644 index 00000000000..9fa3a6142d8 --- /dev/null +++ b/ci/templates/maven-test-project/pom.xml @@ -0,0 +1,189 @@ + + + 4.0.0 + + org.example + maven-test-project + 1.0-SNAPSHOT + + + UTF-8 + official + 1.8 + 2.1.0 + 1.8.0-alpha02 + + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + gMaven + https://maven.google.com/ + + + composeDev + https://maven.pkg.jetbrains.space/public/p/compose/dev + + + + + src/main/kotlin + src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable + -Xplugin=${user.home}/.m2/repository/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/${kotlin.version}/kotlin-compose-compiler-plugin-${kotlin.version}.jar + + + + + maven-surefire-plugin + 2.22.2 + + + maven-failsafe-plugin + 2.22.2 + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + MainKt + + + + + + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin.version} + test + + + org.junit.jupiter + junit-jupiter + 5.10.0 + test + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.compose.material3 + material3-desktop + ${compose.version} + + + + org.jetbrains.compose.desktop + desktop-jvm-windows-x64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + org.jetbrains.compose.desktop + desktop-jvm-windows-arm64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + + org.jetbrains.compose.desktop + desktop-jvm-linux-x64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + org.jetbrains.compose.desktop + desktop-jvm-linux-arm64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + + org.jetbrains.compose.desktop + desktop-jvm-macos-x64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + org.jetbrains.compose.desktop + desktop-jvm-macos-arm64 + ${compose.version} + pom + + + org.jetbrains.compose.desktop + desktop + + + + + + org.jetbrains.kotlin + kotlin-compose-compiler-plugin + ${kotlin.version} + + + + \ No newline at end of file diff --git a/ci/templates/maven-test-project/src/main/kotlin/Main.kt b/ci/templates/maven-test-project/src/main/kotlin/Main.kt new file mode 100644 index 00000000000..be692772c7f --- /dev/null +++ b/ci/templates/maven-test-project/src/main/kotlin/Main.kt @@ -0,0 +1,30 @@ +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import kotlinx.coroutines.delay + +fun main() = application { + Window(onCloseRequest = ::exitApplication) { + LaunchedEffect(Unit) { + delay(1000) + exitApplication() + } + + var text by remember { mutableStateOf("Hello, World!") } + + MaterialTheme { + Button(onClick = { + text = "Hello, Desktop!" + }) { + Text(text) + } + } + } +} \ No newline at end of file diff --git a/tools/replaceVersion.sh b/tools/replaceVersion.sh index d4722b2bfe8..380cb45e31f 100755 --- a/tools/replaceVersion.sh +++ b/tools/replaceVersion.sh @@ -47,11 +47,13 @@ replaceVersion() { replaceVersionInFile() { echo "Replace in $1" replaceVersion '^compose.version=.*' 'compose.version='"$COMPOSE_VERSION"'' $1 + replaceVersion '.*<\/compose.version>' ''"$COMPOSE_VERSION"'<\/compose.version>' $1 replaceVersion '^COMPOSE_CORE_VERSION=.*' 'COMPOSE_CORE_VERSION='"$COMPOSE_VERSION"'' $1 replaceVersion '^COMPOSE_WEB_VERSION=.*' 'COMPOSE_WEB_VERSION='"$COMPOSE_VERSION"'' $1 replaceVersion 'id("org.jetbrains.compose") version ".*"' 'id("org.jetbrains.compose") version "'"$COMPOSE_VERSION"'"' $1 replaceVersion '"org.jetbrains.compose:compose-gradle-plugin:.*"' '"org.jetbrains.compose:compose-gradle-plugin:'"$COMPOSE_VERSION"'"' $1 replaceVersion '^kotlin.version=.*' 'kotlin.version='"$KOTLIN_VERSION"'' $1 + replaceVersion '.*<\/kotlin.version>' ''"$KOTLIN_VERSION"'<\/kotlin.version>' $1 replaceVersion '^compose.tests.compiler.compatible.kotlin.version=.*' 'compose.tests.compiler.compatible.kotlin.version='"$KOTLIN_VERSION"'' $1 replaceVersion '^compose.tests.js.compiler.compatible.kotlin.version=.*' 'compose.tests.js.compiler.compatible.kotlin.version='"$KOTLIN_VERSION"'' $1 replaceVersion 'kotlin("multiplatform") version ".*"' 'kotlin("multiplatform") version "'"$KOTLIN_VERSION"'"' $1 @@ -65,5 +67,6 @@ replaceVersionInFolder() { for folder in "${folders[@]}" do replaceVersionInFolder $folder "**gradle.properties" + replaceVersionInFolder $folder "**pom.xml" replaceVersionInFolder $folder "**README.md" done