使用lein构建clojure项目时出错

时间:2012-05-20 12:07:58

标签: clojure leiningen

我对clojure一点都不熟悉,而且我有一个我正在尝试构建的项目的源代码。该项目有一个project.clj文件,谷歌说这意味着我应该使用lein构建工具。但是:

$ lein compile #lein jar does the same thing
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate testui/core__init.class oCompiling testui.core
r testui/core.clj on classpath

我怀疑project.clj可能会被破坏。 core.clj位于src / com / foodient / semanticanalysis / testui中,project.clj如下所示:

(defproject testui "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.apache.poi/poi "3.8-beta4"]
                 [gate-clj "1.0.0"]]
  :aot [testui.core]
  :main testui.core
  :run-aliases {:test testui.core/-main})

有什么想法吗?

3 个答案:

答案 0 :(得分:4)

如果你设置了一个lein项目并且名称中包含了Clojuristic破折号,比如bene-csv(我的一个),那么lein new bene-csv会创建几个目录并./bene-csv/project.clj。我的core.clj位于./bene-csv/src/bene_csv/core.clj。请注意,短划线将放在bene_csv中,以支持下划线。

关于你的问题,很可能core.clj不在lein预期的位置,应该是./testui/src/testui/core.clj。我希望这会有所帮助。

答案 1 :(得分:3)

我认为问题是core.clj不在正确的目录中。它应该在src / testui目录中。

答案 2 :(得分:3)

我的猜测是你应该从

更改对代码的引用
testui.core

com.foodient.semanticanalysis.testui.core

原因是最后一个点之前的命名空间部分对应于一个包名(该术语来自java和jvm)

您表示您的来源位于:

src/com/foodient/semanticanalysis/testui

因此包名称为com.foodient.semanticanalysis.testui

您可能还应该更新clojure源文件中的命名空间声明以符合此约定(或将源移动到src/testui)。

希望它有所帮助。

相关问题