说我有一个类似
的vanilla project.clj(defproject myservice "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:mailing-list {:name "myservice@example.com" :post "myservice@climate.com"}
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[ring/ring-core "1.4.0"]
[ring/ring-jetty-adapter "1.4.0"]
[compojure "1.4.0"]
[ring/ring-defaults "0.1.5"]
[org.clojure/tools.logging "0.3.1"]
[clj-http "2.0.0"]]
:plugins [[lein-ring "0.9.7"]]
:ring {:handler myservice.core/standalone-app
:port 3000}
:profiles {
:uberjar {:ring {:handler myservice.core/app}}}
)
在lein repl
中,我可以从project.clj中查找值吗?怎么样?当然,我的盲目黑客没有工作?
user=> (:mailing-list project)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: project in this context, compiling:(/private/var/folders/1g/fnytl2x93sx6hp2f1rsf4h1r5xtqv_/T/form-init6671981825845237047.clj:1:1)
以下问题是我可以在project.clj中进一步使用项目地图中的内容吗?就像我想拉那个邮件列表一样:命名并将其替换为:deb:maintainer?
:deb
{:toDir "target"
:package "mysevice"
:maintainer {:name "Meeples", :email "myservice@example.com"}
...
}
我确定你可以告诉我,我对此很新,但是project.clj只是可执行的Clojure,不是吗?如果我知道项目地图的名称,我应该可以查询它,对吧?
答案 0 :(得分:1)
您可以像往常一样def
数据,并使用~
(def mailing-list {:name "myservice@example.com" :post "myservice@climate.com"})
(defproject myservice "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:mailing-list ~mailing-list
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[ring/ring-core "1.4.0"]
[ring/ring-jetty-adapter "1.4.0"]
[compojure "1.4.0"]
[ring/ring-defaults "0.1.5"]
[org.clojure/tools.logging "0.3.1"]
[clj-http "2.0.0"]]
:plugins [[lein-ring "0.9.7"]]
:ring {:handler myservice.core/standalone-app
:port 3000}
:profiles {
:uberjar {:ring {:handler myservice.core/app}}}
:deb {
:toDir "target"
:package "mysevice"
:maintainer {:name "Meeples", :email (:name ~mailing-list)}})
答案 1 :(得分:0)
这是leiningen的相关专栏:https://github.com/technomancy/leiningen/blob/b29b2ea41b6d177a8a57493b979164eab0931e4d/leiningen-core/src/leiningen/core/project.clj#L405
鉴于命名空间为leiningen.core.project
,地图应位于其下方。