Creating multi-module projects with dependencies between modules

837 views
Skip to first unread message

Dave Kincaid

unread,
Mar 17, 2014, 10:55:30 PM3/17/14
to clo...@googlegroups.com
I'm trying to create a project with multiple modules where there are some dependencies between modules. So far I've tried out lein-sub and lein-modules but neither one seems to handle inter-module dependencies (either that or I just can't figure out how to do it). What are people using for projects like this? Any open source examples I could look at?

Thanks,

Dave

Jim Crossley

unread,
Mar 17, 2014, 11:11:15 PM3/17/14
to clo...@googlegroups.com
Hi Dave,

Inter-module deps should be supported by lein-modules. I have plenty of them in the immutant source tree. The test-resources dir in the lein-modules source has some examples of parent/child/sibling deps, but they're pretty contrived. If you can describe the structure of your projects or point me to them if public, and tell me what you tried that didn't work, I can try to get you going.

Jim


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Kincaid

unread,
Mar 17, 2014, 11:19:37 PM3/17/14
to clo...@googlegroups.com, j...@crossleys.org
Thanks, I'll try to show you what I have pieced together from your example and the immutant project. Right now I'm just trying to make it work, so I just have a project with 2 modules. There is lambda-common and lambda-etl. lambda-etl should depend on lambda-common. When I run something like "lein modules deps" or "lein modules javac" I get the following output:

Could not find artifact lambda-common-module:lambda-common-module:jar:_ in central (http://repo1.maven.org/maven2/)
Could not find artifact lambda-common-module:lambda-common-module:jar:_ in clojars (https://clojars.org/repo/)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Error encountered performing task 'deps' with profile(s): 'inherited,default'
Could not resolve dependencies

Here are the relevant files:

project.clj in root of project:
(def version "0.1.0-SNAPSHOT")

(defproject lambda-clj version
  :description ""
  :packaging "pom"
  :profiles {:dev {:dependencies [[midje/midje _]]}}

  :modules {:inherited
            {:source-paths ["src/clj"]
             :java-source-paths ["src/java"]
             :test-paths ["test/clj" "test/java"]
             :dependencies [[org.clojure/clojure _]
                            [com.taoensso/timbre _]]}

            :versions {org.clojure/clojure "1.5.1"
                       midje/midje "1.6.3"
                       com.taoensso/timbre "3.1.6"
                       
                       :lambda-clj "0.1.0-SNAPSHOT"
                       
                       lambda-common-module :lambda-clj}}

  :codox {:sources ["lambda-common/src"
                    "lambda-etl/src"]})

lambda-common module project.clj:
(def lambda-version "0.1.0-SNAPSHOT")

(defproject lambda-common-module lambda-version
  :description ""
  :parent [lambda-clj _ :relative-path "../pom.xml"]
  :dependencies [[org.apache.thrift/libthrift "0.9.0"]]
  :thrift-source-path "build-support/thrift"
  :thrift-java-path "src/java"
  :thrift-opts "beans,hashcode")

lambda-etl module project.clj:
(def lambda-version "0.1.0-SNAPSHOT")

(defproject lambda-etl-module lambda-version
  :description ""
  :parent [lambda-clj _ :relative-path "../pom.xml"]
  :dependencies [[lambda-common-module _]])

Thanks for taking a look.

Shantanu Kumar

unread,
Mar 19, 2014, 2:51:37 AM3/19/14
to clo...@googlegroups.com


On Tuesday, 18 March 2014 08:25:30 UTC+5:30, Dave Kincaid wrote:
I'm trying to create a project with multiple modules where there are some dependencies between modules. So far I've tried out lein-sub and lein-modules but neither one seems to handle inter-module dependencies (either that or I just can't figure out how to do it). What are people using for projects like this? Any open source examples I could look at?

lein-sub supports an `-s` flag that can be used to work on one specific module at a time. I think you can combine this with lein-cascade (https://github.com/kumarshantanu/lein-cascade) to work with cascading module dependencies.

Shantanu

Jim Crossley

unread,
Mar 20, 2014, 11:12:03 PM3/20/14
to clo...@googlegroups.com, j...@crossleys.org
Hi again David,

I just released lein-modules 0.2.1 that hopefully addresses your concerns:

1) Dependency symbols in the :versions map are more lenient now. You can use either the group id or the artifact id by itself.
2) You exposed a bug where versions for dependencies specified in the :inherited profile (or directly on the project) weren't being resolved correctly. Fixed now.
3) I updated the README to emphasize the requirement that 'lein modules install' must be run before attempting any other task. I confirmed that Maven projects work the exact same way.

Thanks for the feedback,
Jim
Reply all
Reply to author
Forward
0 new messages