Search code examples
jarclojureleiningenring

clojure/lein: Can I specify a project file for lein other than project.clj?


I have a couple of distinct jars I want to generate out of a single project. I figure I can make a project.clj file for each one, but I can't name them all project.clj. How do I tell lein to use another project file besides project.clj? Or is there another way to generate jars or start

> lein ring server 

for example, for many different project files in the same directory?

Thanks!


Solution

  • I would consider restructing your project so that there is a sub-project for each jar. There is a plugin called lein-sub that helps you to do that. For example, here is how ring is structured:

    /ring-core/project.clj
    /ring-devel/project.clj
    /ring-jetty-adapter/project.clj
    /ring-servlet/project.clj
    /project.clj
    

    Then in the "parent" project.clj, you can specifiy the sub-projects like so:

    (defproject example "0.1.0"
      :sub
        ["ring-core"
         "ring-devel"
         "ring-jetty-adapter"
         "ring-servlet"])
    

    Then you can run lein sub jar to generate jars for all your sub-projects. You can always just go into the sub-project directory and work on it as you would a normal lein project, too.