无法从 Immutant 创建 WAR 文件

Failing to create WAR file from Immutant

当我尝试通过命令

创建 war 文件时
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

我的项目文件如下

(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"}]])

prod profile 是这样布局的

(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:

(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 配置文件中的源路径需要在向量中,而不仅仅是字符串。

: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}}

而不是

: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}}