关于clojure:无法从Immutant创建WAR文件

Failing to create WAR file from Immutant

当我尝试通过命令

创建战争文件时

1
lein with-profile prod immutant war

我收到一条错误消息:

Error encountered performing task 'immutant' with profile(s): 'prod'
Uberjar aborting because jar failed: No implementation of method:
:as-file of protocol: #'clojure.java.io/Coercions found for class:
java.lang.Character

我的项目文件如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(defproject company/project-name"0.0.2-SNAPSHOT"
  :description"project description"
  :url"http://www.comapny-url.com"
  :license {:name"company name license"
            :url"http://www.company-url.com"}
  :min-lein-version"2.4.3"
  :java-opts ["-Xmx5g""-server""-XX:-OmitStackTraceInFastThrow"]
  :exclusions [org.clojure/clojure]
  :dependencies [[company/lib-name1"1.2.9" :exclusions [com.taoensso/encore]]
                 [company/lib-name2"1.1.1"]
                 [org.clojure/clojure"1.6.0"]
                 [org.clojure/data.zip"0.1.1"]
                 [org.clojure/tools.nrepl"0.2.10"]
                 [com.palletops/leaven"0.3.1"]
                 [com.github.kyleburton/clj-xpath"1.4.5"]
                 [metrics-clojure"2.5.1"]]
  :java-source-paths ["java/src"]
  :javac-options ["-target""1.7"
                 "-source""1.7""-Xlint:-options"
                 "-cp""resources/jars/jms-lib.jar:resources/jars/clojure-1.6.0.jar:resources/jars/log4j-1.2.17.jar"
                 "-d""resources/classes"]
  :profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace"0.2.11"]]
                   :plugins [[lein-package"2.1.1"]
                             [lein-marginalia"0.7.1"]]}
             :prod {:source-paths"prod"
                    :main prod}}
  :prep-tasks ["javac""compile"]
  :resource-paths ["resources/classes"]
  :plugins [[lein-package"2.1.1"]
            [lein-immutant"2.0.1"]]
  :immutant {:war {:resource-paths ["war-resources"]}
             :nrepl {:port 8183
                     :host"0.0.0.0"
                     :interface"0.0.0.0"
                     :start? true}}
  :hooks [leiningen.package.hooks.deploy leiningen.package.hooks.install]
  :package {:skipjar true
            :autobuild true
            :reuse false
            :artifacts [{:build"with-profile prod immutant war --name=%p%v%t" :extension"war"}]}
  :uberjar-exclusions [#"(?i)^META-INF/[^/]*\\.SF$"] ;; Eliminate the signing code from the uberjar
  :repositories ^:replace [["nexus" {:url"comapny.respository.net"}]])

产品配置文件的布局如下

1
2
3
4
5
6
7
8
9
10
11
(ns prod
      (:require  
        [company.lib-name3
         [debug :as debug]
         [system :refer (go)]])
  (:gen-class))

(defn -main
 "Initialize and start the app as a war"
  []
  (go))

如果我使用如下所示的开发配置文件,则可以建立一个uberjar:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(ns user
   "Tools for interactive development with the REPL. This file should
    not be included in a production build of the application."
    (:require  [clojure.java.io :as io]
        [clojure.java.javadoc :refer  (javadoc)]
        [clojure.pprint :refer  (pprint)]
        [clojure.reflect :refer  (reflect)]
        [clojure.repl :refer  (apropos dir doc find-doc pst source)]
        [clojure.set :as set]
        [clojure.string :as str]
        [clojure.test :as test]
        [clojure.tools.namespace.repl :refer  (refresh refresh-all)]
        [company.lib-name3
         [debug :as debug]
         [system :refer (go)]]))

(defn -main
  []
  (go))


project.clj文件的prod概要文件中的源路径需要在一个向量中,而不仅仅是一个字符串。

1
2
3
4
5
6
:profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace"0.2.11"]]
                   :plugins [[lein-package"2.1.1"]
                             [lein-marginalia"0.7.1"]]}
             :prod {:source-paths ["prod"]
                    :main prod}}

而不是

1
2
3
4
5
6
:profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace"0.2.11"]]
                   :plugins [[lein-package"2.1.1"]
                             [lein-marginalia"0.7.1"]]}
             :prod {:source-paths"prod"
                    :main prod}}