I'm trying to transition from lein to the clojure tools because I like Practicalli's repl setup. I got everything working (I think) except building the uberjar via Github actions. Here's my deps.edn
{:paths ["src" "resources"]
:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/core.cache {:mvn/version "1.0.225"}
com.brunobonacci/mulog {:mvn/version "0.9.0"}
metosin/malli {:mvn/version "0.16.2"}
io.github.cljfx/dev {:mvn/version "1.0.39"}
cljfx/cljfx {:mvn/version "1.9.3"}
clojure-csv/clojure-csv {:mvn/version "2.0.1"}}
:aliases
{;; Run with clj -T:build function-in-build
:run {:main-opts ["-m" "megastrike.core"]}
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.10.5" :git/sha "2a21b7a"}}
:ns-default build
:jvm-opts ["-Dcljfx.skip-javafx-initialization=true"]}}}Here's build.clj
(ns build
(:require [clojure.tools.build.api :as b]))
(def class-dir "target/classes")
(def uber-file (format "target/megastrike.jar"))
;; delay to defer side effects (artifact downloads)
(def basis (delay (b/create-basis {:project "deps.edn"})))
(defn clean [_]
(b/delete {:path "target"}))
(defn uber [_]
(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis @basis
:ns-compile '[megastrike.core]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis @basis
:main 'megastrike.core}))I got this error on github:
Execution error (UnsupportedOperationException) at com.sun.glass.ui.gtk.GtkApplication/lambda$new$5 (GtkApplication.java:164).
Unable to open DISPLAY
I think that the skip-javafx-initialization=true setting didn't get set. Am I passing it wrong?Can you share the whole stack trace?
https://github.com/jonathanabennett/megastrike/actions/runs/11591612603/job/32271717545#step:5:235
That doesn't have the whole stack trace either unfortunately
I think there is a special jvm property that can be set to print the whole stack trace to output instead of writing it to file
-Dclojure.main.report=stderr
Ok, running it again with that option
The only differences I see between my deps.edn build and my project.clj build has to do with aot. But I can't figure out how to do that in the documentation
https://github.com/jonathanabennett/megastrike/actions/runs/11592507515/job/32274529630#step:5:287
Specifically: I have the kv-pair :main ^:skip-aot megastrike.core in my project.clj file and don't know how to add that to deps.edn and the uberjar profile has the kv-pair :aot :all , which I also don't know how to replicate.
damn, that error doesn’t say much, and only hides the real error
it seems that compile-clj launches another jvm to compile your code
and that jvm isn't getting the skip-initialization option
yeah
https://github.com/jonathanabennett/megastrike/blob/dev/build.clj#L20C6-L20C17
you probably want to add :java-opts here that makes cljfx skip javafx initialization
Same error: https://github.com/jonathanabennett/megastrike/actions/runs/11592957801/job/32275969877#step:5:287
Please re-read what I suggested
I got a new error?https://github.com/jonathanabennett/megastrike/actions/runs/11593057519/job/32276277763#step:5:226
Ok, I found it. I'm not quite sure what the underlying cause is, but setting in-development? to false fixes it.
I suspect it's some interaction between the headless nature of Github action runners and what cljfx/dev expects to see. But it's irrelevant because I shouldn't be shipping in development anyway.