Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute Clojure GUI apps? How Clojure compares to Vala in this subject?

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?

like image 706
marcio Avatar asked Aug 10 '14 02:08

marcio


3 Answers

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.

like image 117
noisesmith Avatar answered Nov 15 '22 08:11

noisesmith


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.

like image 23
bensentropy Avatar answered Nov 15 '22 09:11

bensentropy


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.

like image 27
nemequ Avatar answered Nov 15 '22 09:11

nemequ