;;================================================================================ ;;這是一個包含註釋的project.clj文件。 ;;包含了全部選項。能夠視爲一個配置樣本。 ;;包含了比」lein幫助教程」更詳細的註釋 ;;================================================================================ ;; 這是一個項目名叫 "sameple" ;; 組名(或者公司網站名之類的,group-id)叫 "org.example" ;; 版本(version)爲"1.0.0-SNAPSHOT"的項目(project) (defproject org.example/sample "1.0.0-SNAPSHOT" ;;除了這一點,你可能前面加上反引號(unquote),或~,對它求值(eval)。(這個註釋不是我也不是很明白) ;; 這個描述文本有助於倉庫搜索(好比clojars倉庫) :description "A sample project" :url "http://example.org/sample-clojure-project" ;;郵件列表。沒啥好說的 :mailing-list {:name "sample mailing list" :archive "http://example.org/sample-mailing-list-archives" :other-archives ["http://example.org/sample-list-archive2" "http://example.org/sample-list-archive3"] :post "list@example.org" :subscribe "list-subscribe@example.org" :unsubscribe "list-unsubscribe@example.org"} ;;license這個也沒啥好說的 :license {:name "Eclipse Public License - v 1.0" :url "http://www.eclipse.org/legal/epl-v10.html" :distribution :repo :comments "same as Clojure"} ;;依賴的格式相似:[group-id/project-name version] ;; classifier :它表示在相同版本下針對不一樣的環境或者jdk使用的jar,若是配置了這個元素,則會將這個元素名在加在最後來查找相應的jar ;; exclusions : 用來排除相應的重複依賴。好比log4j下包含了a.jar。spring.jar也包含了a.jar,可是兩個版本不一樣,則須要排除掉一個,避免衝突。 :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"] [org.jclouds/jclouds "1.0-RC6" :classifier "jdk15"] [log4j "1.2.15" :exclusions [javax.mail/mail javax.jms/jms com.sun.jdmk/jmxtools com.sun.jmx/jmxri]]] ;; 只用於開發階段的依賴。打包部署將不包含這些依賴。 :dev-dependencies [[org.clojure/swank-clojure "1.2.1"]] ;; 全局的一個依賴排除。 :exclusions [org.apache.poi/poi org.apache.poi/poi-ooxml] ;;在project.clj改變或者庫文件目錄(:library-path directory)爲空時,從新獲取依賴。 :checksum-deps true ;;若是版本低於這個就警告 :min-lein-version "1.3.0" ;; 若是這個選項爲false,那麼獲取依賴的時候,lib目錄將被清空。 ;; 若是要lib目錄不被清空,請將它設爲true :disable-deps-clean false ;; 禁用隱式的clean :disable-implicit-clean true ;; Delete .class files that do not have a corresponding package in ;; the src/ directory. Workaround for Clojure bug CLJ-322. Causes problems ;; with protocols in upstream libraries; false by default. Set to ;; true to delete all non-project classes or set to a seq of regexes ;; to only delete class files that match one of the regexes. (這個翻譯我覺的可能有問題,故保留) ;; 不存在src/目錄,刪除全部.class文件 ;; 爲了解決Clojure bug CLJ-322, 能夠將其設置爲true,或者定義一個正則序列,僅刪除不匹配的class文件。 :clean-non-project-classes true ;; 若是 :clean-non-project-classes 設置爲true ;; 你能夠設置這個正則,用來保留匹配的class文件。 :class-file-whitelist #"^(org/example|clojure)" ;; 在clean階段其餘文件將被刪除(除了:compile-path 和 jars/uberjars)。 ;; %s這個符號將被替換成當前項目的版本號 :extra-files-to-clean ["tmp" "sample-%s.tar"] ;; 若是你不能精確匹配到你要刪除的文件名 ;; 你可使用正則表達(從項目根目錄對文件名進行匹配) ;; 默認爲 #"^$NAME-.*\.jar$". :regex-to-clean #"hs_err_pid.*" ;; 項目的checkout路徑 :checkout-deps-shares [:source-path :test-path ~(fn [p] (str (:root p) "/lib/dev/*"))] ;; 在啓動時加載hooks中的namespaces ;; Hooks通常來自插件,但也可能包含在你的項目source中 :hooks [leiningen.hooks.difftest] ;; Predicates to determine whether to run a test or not. See tutorial. ;; 決定是否運行測試。請參考tutorial :test-selectors {:default (fn [t] (not (or (:integration v) (:regression v)))) :integration :integration :regression :regression} ;; 若是設置這個爲true。將加載全部和leiningen.hooks.*匹配的namespaces。 ;; 警告!!!:很明顯的將致使加載依賴過多,啓動起來比蝸牛還慢 :implicit-hooks false ;; (提示:ahead-of-time (AOT) compiler 是一個實現時間提早編譯的編譯器) ;; gen-class和java互操做所需的將被提早編譯。:namespaces 在這裏是個別名 ;; 設置一個正則將編譯因此匹配的 :aot [org.example.sample] ;; 打包成jar文件的入口函數 ;; 設置 :skip-aot 元數據用來作其餘事情。例如運行shell或者task。 :main org.example.sample ;; 在repl啓動的時候自動加載這個namespace :repl-init sample.repl-helper ;;和:repl-init同樣,不過已是過期的東西了,因此請使用:repl-init。 :repl-init-script "src/main/clojure/init.clj" ;; 這些將傳遞給 clojure.main/repl; 查看他們的細節 :repl-options [:prompt (fn [] (print "your command, master? ") (flush))] ;; 自定義repl的監聽端口 :repl-port 4001 :repl-host "0.0.0.0" ;; A form to prepend to every form that is evaluated inside your project. ;; Allows working around the Gilardi Scenario: http://technomancy.us/143 :project-init (require 'clojure.pprint) ;; 超時重連。默認爲100 :repl-retry-limit 1000 ;; 對全部的反射調用進行警告 :warn-on-reflection true ;; 倉庫配置。即便沒配置,maven的中央倉庫也依然會被查找。 :omit-default-repositories true :repositories {"java.net" "http://download.java.net/maven/2" "sonatype" {:url "http://oss.sonatype.org/content/repositories/releases" ;; If a repository contains releases only; setting :snapshots ;; to false will speed up dependency checking. :snapshots false ;; You can also set the policies for how to handle :checksum ;; failures to :fail, :warn, or :ignore. In :releases, :daily, ;; :always, and :never are supported. :releases {:checksum :fail :update :always}} ;; Repositories named "snapshots" and "releases" automatically ;; have their :snapshots and :releases disabled as appropriate. "snapshots" {:url "http://blueant.com/archiva/snapshots" ;; Also supports :private-key and :passphrase. :username "milgrim" :password "locative.1"} "releases" {:url "http://blueant.com/archiva/internal" :username "milgrim" :password "locative.1"}} ;; 開發依賴的倉庫 :deploy-repositories {"releases" {:url "http://blueant.com/archiva/internal/releases" :username "milgrim" :password "locative.1"} "snapshots" "http://blueant.com/archiva/internal/snapshots"} ;; 源文件路徑 :source-path "src/main/clojure" ;; 編譯後的文件路徑 :compile-path "target/classes" ; for .class files ;; 打包所需jar文件路徑 :library-path "target/dependency" ; for .jar files ;; 單元測試源文件路徑 :test-path "src/test/clojure" ;; 配置文件路徑 :resources-path "src/main/resource" ; non-code files included in classpath/jar ;; 測試配置文件路徑 :dev-resources-path "src/test/resource" ; added to dev classpath but not jar ;; 本地依賴查找路徑 :native-path "src/native" ; where to look for native dependencies ;; 目標路徑 :target-dir "target/ " ; where to place the project's jar file ;; 額外的類路徑 :extra-classpath-dirs ["script"] ; more classpath entries not included in jar ;; jar包名 :jar-name "sample.jar" ; name of the jar produced by 'lein jar' ;; 同樣的,jar包名。uberjar是可執行的jar包 :uberjar-name "sample-standalone.jar" ; as above for uberjar ;; 從~/.m2自定義classpath,而不是拷貝到:library-path. :local-repo-classpath true ;; java文件的編譯目錄 :javac-options {:destdir "classes/"} :java-source-path "src/main/java" ; location of Java source ;; Leave the contents of :source-path out of jars (for AOT projects) :omit-source true ;; 匹配的jar包將被排除 :jar-exclusions [#"(?:^|/).svn/"] ;; 同樣的東東,只針對於uberjar :uberjar-exclusions [#"META-INF/DUMMY.SF"] ;; 對jar's manifest設置任意的鍵值對。 :manifest {"Project-awesome-level" "super-great"} ;; 設置jvm選項 :jvm-opts ["-Xmx1g"] ;; 若是你的項目是一個Leiningen插件,設置這個跳過subprocess步驟 :eval-in-leiningen false ;; 解決Clojure's agent的線程池問題。 ;; If you see RejectedExecutionException using ;; futures or agents, you may be working with a plugin that doesn't ;; take this workaround into account yet--see the "Threads" section ;; of doc/PLUGINS.md. This key will disable Leiningen's workaround. ;; It may cause some other plugins to fail to exit when they finish. :skip-shutdown-agents true ;; 設置一個多模塊的maven項目的父項目。 :parent [org.example/parent "0.0.1" :relative-path "../parent/pom.xml"]) ;; You can use Robert Hooke to modify behaviour of any task function, ;; but the prepend-tasks function is shorthand that is more convenient ;; on tasks that take a single project argument. ;; 你可使用Robert Hooke去修改任何task函數的行爲。 (use '[leiningen.core :only [prepend-tasks]] '[leiningen.deps :only [deps]] '[leiningen.clean :only [clean]] '[leiningen.pom :only [pom]]) ;; 縮略名字參數調用 (prepend-tasks #'deps clean pom)