1

I'm looking for a way to get a list of all the current namespaces in the current project, i.e. excluding namespaces in imported jars, libraries etc.

Currently I have found bultitude which seems pretty close to what I need and can do:

(bultitude.core/namespaces-on-classpath)

However this returns all the namespaces on the classpath, including "clojure.core" etc. rather than just the ones in the current project.

Is there an easy and reliable way to solve this?

4

2 回答 2

2

tools.namespace库呢?有api:

find-namespaces-in-dir
find-namespaces-in-jarfile
find-namespaces-on-classpath
于 2012-12-11T00:47:58.557 回答
1

这得看情况。

bultitude 背后的想法是在类路径上提供命名空间列表。将考虑该类路径上的任何 .clj 文件。

但是,您只能查找以某个前缀开头的名称空间。通常项目也在其命名空间中以某个前缀开头。那行得通吗?自述文件中的示例:

user=> (b/namespaces-on-classpath :prefix "bultitude")
(bultitude.core-test bultitude.core)

如果这还不够好,您可以尝试给它一个只有您的文件所在的类路径,但这可能效果不佳。

user=> (b/namespaces-on-classpath :prefix "bultitude" :classpath "src:test")
(bultitude.core bultitude.core-test)
于 2012-12-11T04:03:18.293 回答