Skip to content

Commit

Permalink
Project for checking compatibility with Maven and JPS on CI (#5201)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
igordmn authored Jan 20, 2025
1 parent 2af2f00 commit 4f2f3e0
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ci/templates/maven-test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions ci/templates/maven-test-project/README.md
Original file line number Diff line number Diff line change
@@ -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
```
189 changes: 189 additions & 0 deletions ci/templates/maven-test-project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>maven-test-project</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<kotlin.version>2.1.0</kotlin.version>
<compose.version>1.8.0-alpha02</compose.version>
</properties>

<repositories>
<repository>
<id>mavenCentral</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>gMaven</id>
<url>https://maven.google.com/</url>
</repository>
<repository>
<id>composeDev</id>
<url>https://maven.pkg.jetbrains.space/public/p/compose/dev</url>
</repository>
</repositories>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>org.jetbrains.kotlin:kotlin-compose-compiler-plugin-embeddable
<arg>-Xplugin=${user.home}/.m2/repository/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/${kotlin.version}/kotlin-compose-compiler-plugin-${kotlin.version}.jar</arg>
</args>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>MainKt</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.compose.material3</groupId>
<artifactId>material3-desktop</artifactId>
<version>${compose.version}</version>
</dependency>

<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-windows-x64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-windows-arm64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-linux-x64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-linux-arm64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-macos-x64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop-jvm-macos-arm64</artifactId>
<version>${compose.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.jetbrains.compose.desktop</groupId>
<artifactId>desktop</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compose-compiler-plugin</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>

</project>
30 changes: 30 additions & 0 deletions ci/templates/maven-test-project/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
}
3 changes: 3 additions & 0 deletions tools/replaceVersion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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>'"$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>'"$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
Expand All @@ -65,5 +67,6 @@ replaceVersionInFolder() {
for folder in "${folders[@]}"
do
replaceVersionInFolder $folder "**gradle.properties"
replaceVersionInFolder $folder "**pom.xml"
replaceVersionInFolder $folder "**README.md"
done

0 comments on commit 4f2f3e0

Please sign in to comment.