Double question here.
So I built a simple GUI app with Clojure (using seesaw) in just a few minutes and that was really fun! But now I don't know how to actually release it. I would like it to run as a stand alone app. How should I "compile" and distribute Clojure GUI apps?
I'm also interested in Vala and would like to know how different is the release process for both languages. From the release / distribution point of view, what are the advantages and disadvantages for each side?
The best way to release a Clojure project as an application is to use lein uberjar
to create a standalone jar containing all of your dependencies. Any user with a compatible jvm can run java -jar your-uberjar.jar
in order to run your application.
There are some complications that come up if your application was written in a way that it expects the contents of the project directory to exist at runtime. clojure.java.io/resource
allows resources to be used whether they are present in the current directory tree, or packaged into an uberjar containing your app.
Set up your project to run as a standalone Java application by specifying the core name space (i.e app.core) to be the main class invoked for the jar file by specifying it with :main. In addition, add a uberjar profile for AOT compilation.
project.clj:
(defproject app "1.0.0-SNAPSHOT"
:description "app Example."
:dependencies
[[org.clojure/clojure "1.8.0"]]
:profiles {:uberjar {:aot :all}}
:main app.core)
Ensure you have :gen-class specified in the name-space of your program. Also define a -main function to act as the main entry point.
src/app/core.clj:
(ns app.core
(:gen-class))
(defn -main [& args]
(dostuff ""))
Then use Packr (https://github.com/libgdx/packr), a small application for packaging up a JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X.
Create a Packr configuration file.
config.json
{
"platform": "mac",
"jdk": "/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/",
"executable": "My App",
"classpath": [
"target/app-1.0.0-SNAPSHOT-standalone.jar"
],
"mainclass": "app.core",
"icon": "resources/icon.icns",
"minimizejre": "soft",
"output": "myapp.app"
}
then run
$ lein uberjar
$ java -jar packr.jar config.json
You will now have a package that can be distributed as native app. This process works well for GUI apps. Sorry i know nothing about Vala.
Vala projects are typically distributed by the project as source tarballs. Most Vala projects use autotools as their build system; once you have autotools set up, you just type make dist
to and one will be built for you.
If there is demand for your software, that tarball is then packaged for various distributions by their packagers, so that people can install it through whatever package manager that distribution uses (i.e., apt-get install yourpkg
on Debian/Ubuntu, yum install yourpkg
on Fedora, Red Hat, OpenSUSE, etc.) or a GUI such as GNOME Software.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With