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?

2 Answers 2

2

what about the tools.namespace lib? there are the api:

find-namespaces-in-dir
find-namespaces-in-jarfile
find-namespaces-on-classpath
2
  • Looks interesting but seems to be very similar to bultitude - i.e. doesn't seem to have a concept of the "current project". Or am I missing something obvious?
    – mikera
    Dec 11, 2012 at 0:53
  • Bultitude is essentially a less nuts and more open rewrite of tools.namespace. If it doesn't work, tools.namespace wont.
    – Rayne
    Dec 11, 2012 at 4:00
1

Well, it depends.

The idea behind bultitude is to provide a list of namespaces on the classpath. Any .clj files on that classpath will be accounted for.

You can, however, look up only namespaces beginning with a certain prefix. Usually projects also begin with a certain prefix in their namespaces. Would that work? Example from the readme:

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

If that isn't good enough, you can try to give it a classpath that only your files are on, but that may not work so well.

user=> (b/namespaces-on-classpath :prefix "bultitude" :classpath "src:test")
(bultitude.core bultitude.core-test)
2
  • Thanks and great to get an answer from the library author himself! I take it that using the :classpath option only works if you have the right file structure in place?
    – mikera
    Dec 11, 2012 at 4:28
  • @mikera As long as you don't have your own files mixed with files from other projects (which is pretty unlikely), it should work fine.
    – Rayne
    Dec 12, 2012 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.