What is an elegant way to set up a leiningen project that requires different dependencies based on the build platform?

Posted by Savanni D'Gerinel on Stack Overflow See other posts from Stack Overflow or by Savanni D'Gerinel
Published on 2011-01-14T05:52:13Z Indexed on 2011/01/14 5:53 UTC
Read the original article Hit count: 264

Filed under:
|
|

In order to do some multi-platform GUI development, I have just switched from GTK + Clojure (because it looks like the Java bindings for GTK never got ported to Windows) to SWT + Clojure. So far, so good in that I have gotten an uberjar built for Linux.

The catch, though, is that I want to build an uberjar for Windows and I am trying to figure out a clean way to manage the project.clj file.

At first, I thought I would set the classpath to point to the SWT libraries and then build the uberjar. This would require that I set a classpath to the SWT libraries before running the jar, but I would likely need a launcher script, anyway. However, leiningen seems to ignore the classpath in this instance because it always reports that

Currently, project.clj looks like this for me:

(defproject alyra.mana-punk/character "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [org.eclipse/swt-gtk-linux-x86 "3.5.2"]]
  :main alyra.mana-punk.character.core)

The relevant line is the org.eclipse/swt-gtk-linux-x86 line. If I want to make an uberjar for Windows, I have to depend on org.eclipse/swt-win32-win32-x86, and another one for x86-64, and so on and so forth.

My current solution is to simply create a separate branch for each build environment with a different project.clj. This seems kinda like using a semi to deliver a single gallon of milk, but I am using bazaar for version control, so branching and repeated integrations are easy. Maybe the better way is to have a project.linux.clj, project.win32.clj, etc, but I do not see any way to tell leiningen which project descriptor to use.

What are other (preferably more elegant) ways to set up such an environment?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about cross-platform