Browse Source

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
```
pull/5206/head
Igor Demin 11 months ago committed by GitHub
parent
commit
4f2f3e0405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      ci/templates/maven-test-project/.gitignore
  2. 5
      ci/templates/maven-test-project/README.md
  3. 189
      ci/templates/maven-test-project/pom.xml
  4. 30
      ci/templates/maven-test-project/src/main/kotlin/Main.kt
  5. 3
      tools/replaceVersion.sh

16
ci/templates/maven-test-project/.gitignore vendored

@ -0,0 +1,16 @@ @@ -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
ci/templates/maven-test-project/README.md

@ -0,0 +1,5 @@ @@ -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
ci/templates/maven-test-project/pom.xml

@ -0,0 +1,189 @@ @@ -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
ci/templates/maven-test-project/src/main/kotlin/Main.kt

@ -0,0 +1,30 @@ @@ -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
tools/replaceVersion.sh

@ -47,11 +47,13 @@ replaceVersion() { @@ -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
@ -65,5 +67,6 @@ replaceVersionInFolder() { @@ -65,5 +67,6 @@ replaceVersionInFolder() {
for folder in "${folders[@]}"
do
replaceVersionInFolder $folder "**gradle.properties"
replaceVersionInFolder $folder "**pom.xml"
replaceVersionInFolder $folder "**README.md"
done

Loading…
Cancel
Save