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

我的梦境 提交于 2019-11-30 03:44:21

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))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!