Skip to content

Commit

Permalink
Use jpackage to make Mac OS DMG file
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonBailey committed Jul 9, 2024
1 parent 0bf3424 commit 1ba20dc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions terra/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id("dev.jacksonbailey.wheel.shut-up-javadoc")
id("io.freefair.lombok") version "8.6"
id("io.spring.dependency-management") version "1.1.5"
id("org.panteleyev.jpackageplugin") version "1.6.0"
id("org.springframework.boot") version "3.3.0"
}

Expand Down Expand Up @@ -43,3 +44,37 @@ tasks.getByName<BootJar>("bootJar") {
// TODO Does this mess up publishing somehow?
this.archiveFileName.set("${archiveBaseName.get()}.${archiveExtension.get()}")
}

// TODO Is there a way to get the "into" of a copy task programmatically?
val jpackageInputDirectory = "${layout.buildDirectory.asFile.get().path}/jpackage/input"

val copyBootJar = task("copyBootJar", Copy::class) {
// TODO Is dependsOn needed when from is a task?
dependsOn(tasks.bootJar)
from(tasks.bootJar).into(jpackageInputDirectory)
}

/*
* This works! When the DMG is installed and ran, it works. It does not show any console and the
* icon on the taskbar just jumps non-stop, but this works! I will look into it more later.
*/
tasks.jpackage {
// Only *really* needs to depend on copyBootJar, but it feels odd to not build everything
dependsOn(copyBootJar, tasks.build)

input = jpackageInputDirectory
destination = "${layout.buildDirectory.asFile.get().path}/distributions"

mainJar = tasks.bootJar.get().archiveFileName.get()
// Remember, the *real* main class in the boot jar is the JarLauncher
mainClass = "org.springframework.boot.loader.launch.JarLauncher"

arguments = listOf("--spring.profiles.active=live")

mac {
// For Bundler Mac DMG Package, valid versions are one to three integers separated by dots.
// The first number in an app-version cannot be zero or negative. The default for this would
// be the project's version. Therefore, 0.1.0-SNAPSHOT will not work, so I just set it to 1.
appVersion = "1"
}
}
8 changes: 8 additions & 0 deletions terra/lessons-learned.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ public JDABuilder jdaBuilder(ObjectProvider<ListenerAdapter> listenerProvider) {
return builder;
}
```

## Semantic Line Breaks

I installed the Grazie Pro plugin. (Very confusingly named, it has a few features even without a
subscription.) It suggests "structural line breaks" and points to
[Semantic Line Breaks](https://sembr.org/). It's interesting. It suggests wrapping text lines in
things like Markdown at the end of sentences/clauses/thoughts. I'll consider it but will likely
pass.

0 comments on commit 1ba20dc

Please sign in to comment.