diff --git a/DISTRIBUTING.md b/DISTRIBUTING.md new file mode 100644 index 000000000..717906d79 --- /dev/null +++ b/DISTRIBUTING.md @@ -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). diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8787ebe45..15c796c51 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" @@ -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" } @@ -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" } @@ -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"} diff --git a/samples/standalone/build.gradle.kts b/samples/standalone/build.gradle.kts index 64734a8c5..6fbdc58b4 100644 --- a/samples/standalone/build.gradle.kts +++ b/samples/standalone/build.gradle.kts @@ -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) } dependencies { @@ -62,4 +65,44 @@ tasks { setExecutable(javaLauncher.map { it.executablePath.asFile.absolutePath }.get()) } } -} \ No newline at end of file +} + +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("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("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("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) + } + } +}