Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cross builds via construo plugin #289

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
13 changes: 13 additions & 0 deletions DISTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Creating a self-contained application

You can package the standalone sample with the following gradle tasks:

- Linux `samples:standalone:packageLinuxX64`
- macOS `samples:standalone:packageMacOsAarch64`
- Windows `samples:standalone:packageWinX64`

The packaged application zip will be in the `build/construo/dist` folder.

## Signing and notarization on MacOS

Signing of the final application must be done **after** creating a self-contained application, using the standard Apple tools, see the [official documentation](https://developer.apple.com/documentation/security/customizing-the-notarization-workflow).
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
commonmark = "0.24.0"
composeDesktop = "1.7.1"
construo = "1.6.0"
detekt = "1.23.6"
dokka = "1.9.20"
idea = "243.21155.17"
Expand All @@ -15,7 +16,7 @@ kotlinxSerialization = "1.7.3"
kotlinxBinaryCompat = "0.16.3"
ktfmtGradlePlugin = "0.20.1"
poko = "0.17.1"

shadow = "8.3.5"
[libraries]
commonmark-core = { module = "org.commonmark:commonmark", version.ref = "commonmark" }
commonmark-ext-autolink = { module = "org.commonmark:commonmark-ext-autolink", version.ref = "commonmark" }
Expand Down Expand Up @@ -44,6 +45,7 @@ poko-gradlePlugin = { module = "dev.drewhamilton.poko:poko-gradle-plugin", versi
[plugins]
composeDesktop = { id = "org.jetbrains.compose", version.ref = "composeDesktop" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
construo = { id = "io.github.fourlastor.construo", version.ref = "construo"}
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
ideaPlugin = { id = "org.jetbrains.intellij.platform", version.ref = "ideaPlugin" }
Expand All @@ -55,3 +57,4 @@ kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", vers
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinterGradlePlugin" }
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmtGradlePlugin" }
poko = { id = "dev.drewhamilton.poko", version.ref = "poko" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow"}
45 changes: 44 additions & 1 deletion samples/standalone/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@file:Suppress("UnstableApiUsage")

import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import io.github.fourlastor.construo.Target

plugins {
jewel
alias(libs.plugins.composeDesktop)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.construo)
alias(libs.plugins.shadow)
rock3r marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
Expand Down Expand Up @@ -62,4 +65,44 @@ tasks {
setExecutable(javaLauncher.map { it.executablePath.asFile.absolutePath }.get())
}
}
}
}

construo {
// name of the executable
name.set("jewel")
// human readable name, used for example in the `.app` name for MacOS
humanName.set("Jewel Standalone")
// version, required if not specified in project
version.set("1.0.0")
// main class, it wouldn't be required if compose used the application plugin
mainClass.set("org.jetbrains.jewel.samples.standalone.MainKt")
roast {
runOnFirstThread.set(false)
// required to get around compose using context class loader
useMainAsContextClassLoader.set(true)
}
jlink {
// required as it's used via string by compose, so it's not picked up by jlink automatically
modules.addAll("jdk.zipfs")
}
targets {
// Linux X64
create<Target.Linux>("linuxX64") {
jdkUrl.set("https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.12-linux-x64-b1207.37.tar.gz")
architecture.set(Target.Architecture.X86_64)
}
// macOS M1
create<Target.MacOs>("macOsAarch64") {
jdkUrl.set("https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.12-osx-aarch64-b1207.37.tar.gz")
architecture.set(Target.Architecture.AARCH64)
identifier.set("org.jetbrains.jewel.sample.standalone")
macIcon.set(file("icons/jewel.icns"))
}
// Windows x64
create<Target.Windows>("winX64") {
jdkUrl.set("https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.12-windows-x64-b1207.37.tar.gz")
useGpuHint.set(false)
architecture.set(Target.Architecture.X86_64)
}
}
}