Skip to content

Commit

Permalink
feat: add normal compose desktop setup support and check project for it
Browse files Browse the repository at this point in the history
Signed-off-by: Art Shendrik <[email protected]>
  • Loading branch information
amal committed Apr 22, 2024
1 parent 8270225 commit a2473c3
Show file tree
Hide file tree
Showing 50 changed files with 893 additions and 128 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ jobs:
env:
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: 'Run check-compose-desktop'
working-directory: checks/compose-desktop
run: ./gradlew build assemble check packageReleaseDistributionForCurrentOS --continue --stacktrace --scan
env:
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: 'Run self check'
timeout-minutes: 4
working-directory: self
Expand Down
33 changes: 33 additions & 0 deletions .run/check-compose-desktop.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="check-compose-desktop" type="GradleRunConfiguration" factoryName="Gradle" folderName="check">
<ExternalSystemSettings>
<option name="env">
<map>
<entry key="CI" value="true" />
<entry key="RELEASE" value="true" />
</map>
</option>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/checks/compose-desktop" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--stacktrace --continue" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="build" />
<option value="assemble" />
<option value="check" />
<option value="packageReleaseDistributionForCurrentOS" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/dependencyGuardBaseline (compose-desktop).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dependencyGuardBaseline (compose-desktop)" type="GradleRunConfiguration" factoryName="Gradle" folderName="preparations">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/checks/compose-desktop" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--stacktrace" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="dependencyGuardBaseline" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dependencyGuardBaseline (check-main)" type="GradleRunConfiguration" factoryName="Gradle" folderName="preparations">
<configuration default="false" name="dependencyGuardBaseline (kmp)" type="GradleRunConfiguration" factoryName="Gradle" folderName="preparations">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/checks/kmp" />
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _You need to replace `setup*` calls to `fkcSetup*` ones like this: <br>
`setupMultiplatform` => `fkcSetupMultiplatform`._

### Added
- add Compose Desktop setup support and a test project for it.
- bundle toml version catalog with the plugin as a resolving fallback.
- add logging on auto changed yarn dependenciew for Kotlin/JS.
- enable `androidResources.generateLocaleConfig` in android apps by default.
Expand Down
1 change: 0 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* https://github.com/arrow-kt/arrow-gradle-config/blob/cba09cc/arrow-gradle-config-publish/src/main/kotlin/internal/PublishMppRootModuleInPlatform.kt#L13
* Security setup
* Setup for securing API keys in `BuildConfigs` (generated code in general) and in the usual code.
* Support JVM application with `application` plugin.
* GIT hooks
* Spotless
* Detekt
Expand Down
64 changes: 64 additions & 0 deletions checks/compose-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import java.util.Calendar
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.jetbrains.compose)
id("io.github.fluxo-kt.fluxo-kmp-conf")
}

// https://github.com/JetBrains/compose-multiplatform/blob/e1aff75/tutorials/Native_distributions_and_local_execution/README.md#specifying-package-version
val appVersion = libs.versions.version.get()
.substringBefore("-")
.let {
val (a, b) = it.split(".", limit = 3)
if (a == "0") "1.0.$b" else it
}

version = appVersion
group = "io.github.fluxo-kt"

val mainClassName = "MainKt"
tasks.named<Jar>("jar") {
manifest.attributes["Main-Class"] = mainClassName
}

// See JB template and docs:
// https://github.com/JetBrains/compose-multiplatform-desktop-template
// https://github.com/JetBrains/compose-multiplatform/blob/e1aff75/tutorials/Native_distributions_and_local_execution/README.md

fkcSetupKotlinApp {
replaceOutgoingJar = true
shrink { fullMode = true }
shrinkWithProGuard()
}

dependencies {
// `currentOs` should be used in launcher-sourceSet and in testMain only.
// For a library, use compose.desktop.common.
// With compose.desktop.common you will also lose @Preview functionality.
implementation(compose.desktop.currentOs)

testImplementation(compose.desktop.uiTestJUnit4)
}

compose.desktop.application {
mainClass = mainClassName

nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageVersion = appVersion
packageName = "MyApp"
description = "MyDescription"
vendor = "MyCompany"

val year = Calendar.getInstance().get(Calendar.YEAR)
copyright = "© $year $packageName. All rights reserved."

windows {
shortcut = true
menuGroup = packageName
upgradeUuid = "3d4241d1-0400-401f-bd1f-000fdc8ae989"
}
}
}
60 changes: 60 additions & 0 deletions checks/compose-desktop/dependencies/classpath.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:plugin
com.diffplug.durian:durian-collect:1.2.0
com.diffplug.durian:durian-core:1.2.0
com.diffplug.durian:durian-io:1.2.0
com.diffplug.durian:durian-swt.os:4.2.2
com.diffplug.spotless:spotless-lib-extra:2.45.0
com.diffplug.spotless:spotless-lib:2.45.0
com.diffplug.spotless:spotless-plugin-gradle:6.25.0
com.dropbox.dependency-guard:com.dropbox.dependency-guard.gradle.plugin:0.5.0
com.dropbox.dependency-guard:dependency-guard:0.5.0
com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.51.0
com.github.ben-manes:gradle-versions-plugin:0.51.0
com.googlecode.concurrent-trees:concurrent-trees:2.6.1
com.googlecode.javaewah:JavaEWAH:1.2.3
com.squareup.moshi:moshi-kotlin:1.12.0
com.squareup.moshi:moshi:1.12.0
com.squareup.okhttp3:okhttp-bom:4.12.0
com.squareup.okhttp3:okhttp:4.12.0
com.squareup.okio:okio-jvm:3.6.0
com.squareup.okio:okio:3.6.0
commons-codec:commons-codec:1.16.0
dev.equo.ide:solstice:1.7.5
io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6
org.antlr:antlr4-runtime:4.11.1
org.checkerframework:checker-qual:3.21.2
org.eclipse.jgit:org.eclipse.jgit:6.7.0.202309050840-r
org.eclipse.platform:org.eclipse.osgi:3.18.300
org.jetbrains.compose:compose-gradle-plugin:1.6.2
org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:1.6.2
org.jetbrains.intellij.deps:trove4j:1.0.20200330
org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.23
org.jetbrains.kotlin:kotlin-android-extensions:1.9.23
org.jetbrains.kotlin:kotlin-build-tools-api:1.9.23
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.23
org.jetbrains.kotlin:kotlin-compiler-runner:1.9.23
org.jetbrains.kotlin:kotlin-daemon-client:1.9.23
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23
org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.23
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.23
org.jetbrains.kotlin:kotlin-native-utils:1.9.23
org.jetbrains.kotlin:kotlin-project-model:1.9.23
org.jetbrains.kotlin:kotlin-reflect:1.9.22
org.jetbrains.kotlin:kotlin-scripting-common:1.9.23
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.23
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.23
org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.23
org.jetbrains.kotlin:kotlin-tooling-core:1.9.23
org.jetbrains.kotlin:kotlin-util-io:1.9.23
org.jetbrains.kotlin:kotlin-util-klib:1.9.23
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0
org.ow2.asm:asm:9.7
org.slf4j:slf4j-api:1.7.36
org.tomlj:tomlj:1.1.1
org.tukaani:xz:1.9
1 change: 1 addition & 0 deletions checks/compose-desktop/detekt.yml
1 change: 1 addition & 0 deletions checks/compose-desktop/gradle
4 changes: 4 additions & 0 deletions checks/compose-desktop/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx3G -Dfile.encoding=UTF-8 -XX:+UseParallelGC
kotlin.daemon.jvmargs=-Xmx2G -XX:+UseParallelGC
kotlin.daemon.useFallbackStrategy=false
MAX_DEBUG=true
1 change: 1 addition & 0 deletions checks/compose-desktop/gradlew
1 change: 1 addition & 0 deletions checks/compose-desktop/gradlew.bat
1 change: 1 addition & 0 deletions checks/compose-desktop/pg/assumenosideeffects.pro
1 change: 1 addition & 0 deletions checks/compose-desktop/pg/assumptions.pro
55 changes: 55 additions & 0 deletions checks/compose-desktop/pg/compose-desktop-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Compose Desktop ProGuard/R8 rules
# https://github.com/JetBrains/compose-multiplatform/blob/382ad5b/gradle-plugins/compose/src/main/resources/default-compose-desktop-rules.pro

#-keep class kotlin.** { *; }
-keep,allowoptimization class org.jetbrains.skia.** { *; }
-keep,allowoptimization class org.jetbrains.skiko.** { *; }

-assumenosideeffects public class androidx.compose.runtime.ComposerKt {
void sourceInformation(androidx.compose.runtime.Composer,java.lang.String);
void sourceInformationMarkerStart(androidx.compose.runtime.Composer,int,java.lang.String);
void sourceInformationMarkerEnd(androidx.compose.runtime.Composer);
boolean isTraceInProgress();
void traceEventStart(int, java.lang.String);
void traceEventEnd();
}


# Kotlinx Coroutines Rules
# https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro

#-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
#-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
#-keepclassmembers class kotlinx.coroutines.** {
# volatile <fields>;
#}
#-keepclassmembers class kotlin.coroutines.SafeContinuation {
# volatile <fields>;
#}
#-dontwarn java.lang.instrument.ClassFileTransformer
#-dontwarn sun.misc.SignalHandler
#-dontwarn java.lang.instrument.Instrumentation
#-dontwarn sun.misc.Signal
#-dontwarn java.lang.ClassValue
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement


# https://github.com/Kotlin/kotlinx.coroutines/issues/2046
-dontwarn android.annotation.SuppressLint

# https://github.com/JetBrains/compose-jb/issues/2393
-dontnote kotlin.coroutines.jvm.internal.**
-dontnote kotlin.internal.**
-dontnote kotlin.jvm.internal.**
-dontnote kotlin.reflect.**
-dontnote kotlinx.coroutines.debug.internal.**
-dontnote kotlinx.coroutines.internal.**
-keep,allowoptimization,allowobfuscation class kotlin.coroutines.Continuation
-keep,allowoptimization,allowobfuscation class kotlin.coroutines.CoroutineContext
-keep,allowoptimization,allowobfuscation class kotlinx.coroutines.CancellableContinuation
-keep,allowoptimization,allowobfuscation class kotlinx.coroutines.CoroutineDispatcher
-keep,allowoptimization,allowobfuscation class kotlinx.coroutines.CoroutineScope
-keep,allowoptimization,allowobfuscation class kotlinx.coroutines.channels.Channel

# this is a weird one, but breaks build on some combinations of OS and JDK (reproduced on Windows 10 + Corretto 16)
-dontwarn org.graalvm.compiler.core.aarch64.AArch64NodeMatchRules_MatchStatementSet*
12 changes: 12 additions & 0 deletions checks/compose-desktop/pg/keep.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# See `fluxo.shrink.ShrinkerKeepRulesBySeedsTest` for tests on what's supported by R8 and ProGuard.

# The weakest rule that will keep annotations and attributes is
# https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode
# -keep[classmembers],allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification class-specification

-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}

-dontwarn androidx.annotation.**
10 changes: 10 additions & 0 deletions checks/compose-desktop/pg/proguard.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

-include rules.pro

# ProGuard-only configuration.
# Dangerous, can increase size of the artifact!
# https://www.guardsquare.com/manual/configuration/optimizations#aggressive-optimization
-optimizeaggressively

# ProGuard-only configuration.
#-skipnonpubliclibraryclasses
29 changes: 29 additions & 0 deletions checks/compose-desktop/pg/rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###
# ProGuard/R8 rules
###

-optimizationpasses 8
-repackageclasses

-overloadaggressively
-allowaccessmodification

# Horizontal class merging increases size of the artifact.
#-optimizations !class/merging/horizontal

-adaptclassstrings
-adaptresourcefilenames **.properties,**.gif,**.jpg,**.png,**.webp,**.svg,**.ttf,**.otf,**.txt,**.xml
-adaptresourcefilecontents **.properties,**.MF

# For problems reporting.
-renamesourcefileattribute P
-keepattributes SourceFile,LineNumberTable

-include keep.pro
-include compose-desktop-rules.pro

# Note: -assumenosideeffects should not be used with constructors!
# It leads to bugs like https://sourceforge.net/p/proguard/bugs/702/
# Using -assumenoexternalsideeffects is fine though and should be used for that purpose.
-include assumptions.pro
-include assumenosideeffects.pro
20 changes: 20 additions & 0 deletions checks/compose-desktop/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pluginManagement {
repositories {
// For Gradle plugins only. Last because proxies to mavenCentral.
gradlePluginPortal()
}
includeBuild("../../")
}

plugins {
id("com.gradle.enterprise") version "3.16.2"
}

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}

rootProject.name = "check-compose-desktop"
Loading

0 comments on commit a2473c3

Please sign in to comment.