1
votes

I had decomposed a business solution into multiple smaller web applications and created those small web applications using Lein Compjure plugin.( This enabled for faster development ). I am now trying to merge these web applications into one web application ,lets call it unifiedapp ,by creating a new lein compojure project and adding the smaller web applications as dependencies. I will create the approprite app routes in the unifiedapp such that the correct handler from the smaller web apps will be invoked.

The problem I am facing is that the lein does not take war files as dependency and when I try to create a simple jar file for a lein compojure project( small web app, it fails.

Edit: project.clj ( this is generated by lein new compojure hello-world)

(defproject hello-world "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [compojure "1.5.1"]
                 [ring/ring-defaults "0.2.1"]]
  :plugins [[lein-ring "0.9.7"]]
  :ring {:handler hello-world.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.0"]]}})

When I run lein jar install , I get the following message:

Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method, or the namespace has not been AOT-compiled.

I do see a jar file in the target folder but for some reason, it does not copy over the jar file to .m2\repository . Therefore the parent web application that is trying to include this jar (routes of this web application) cannot see it.

1
why creating the jar file for your compojure app sounds like an important part of this question, could you include the output and as much of the project.clj files involved as you can (while respecting your confidentiality requirements)Arthur Ulfeldt
I would just merge the source code together in a new lein project. Is there some reason you don't want to do that?Alan Thompson
@ Alan Thompson , the small web application are very easy to maintain , develop , test and debug . I don't want to give up the flexibility.user193116

1 Answers

0
votes

Thanks to Alan's response, I changed my approach. I did not merge the source by I modified the main web application's project.cj file to include source and resources used the the child/sub-applications

(defproject mainwebapp "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [compojure "1.5.1"]
                 [ring/ring-defaults "0.2.1"]]

  :source-paths ["../app1/src" "../app2/src" "../app3/src"  "src"]    
 :resource-paths ["../app1/resources" "../app2/resources" "../app3/resources" ] 

  :plugins [[lein-ring "0.9.7"]]
  :ring {:handler mainwebapp.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.0"]]}})