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

前端 未结 1 455
孤独总比滥情好
孤独总比滥情好 2020-12-28 20:36

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

相关标签:
1条回答
  • 2020-12-28 21:16

    Here's a quite elegant solution using Java system properties:

    (let [properties (select-keys (into {} (System/getProperties))
                                  ["os.arch" "os.name"])
          platform (apply format "%s (%s)" (vals properties))
          swt (case platform
                "Windows XP (x86)" '[org.eclipse/swt-win32-win32-x86 "3.5.2"]
                "Linux (x86)"      '[org.eclipse/swt-gtk-linux-x86 "3.5.2"])]
      (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"]
                       ~swt]
        :main alyra.mana-punk.character.core))
    
    0 讨论(0)
提交回复
热议问题