Clojure / Ring: How can I integrate a clojure application with a java build process that is out of control?

I have a unique build situation. I use lein uberwar to build a war from my call app and deploy to beanstalk. This all works great. Now this is due to the requirement that we need to translate the code into the svn repository, where they will manage the assembly that knows nothing about clojure (only java). This is a huge bureaucratic organization, and the process of assembling them is already in place, so installing their lein on their servers is currently out of the question. I know that the lane uses maven under the hood, so I know that this can work theoretically, but I still doubt the two steps of this process.

I went through the military construction process in lein-ring , and the main hangs that I see are that the servlet and listener classes are generated, along with web.xml. I feel that I can provide java files that perform this task, but it is not clear what these java files will contain and where they will ultimately live inside the project structure. Looking at the servlet.clj and listener.clj files that are generated during the final war, they seem very simple, maybe examples already exist for this?

Another big hurdle I see is that the war process calls clojure.core/compile in the project namespace, which generates all class files from the clojure source. Is there any way to call this compilation during build from maven? I almost imagine a java class that handles compilation before clojure.core / compile, but I'm not sure if you are calling clojure from java and not vice versa (normal flow direction) or how to insert this step into the maven base build process.

Any understanding of where to start on any of this would be very welcome! Thanks to everyone.

+6
source share
3 answers

Check out the Zi maven plugin . you specify it as a plugin in your pom.xml subproject, and then it fills the same cast as the javac plugin in the rest of the project. nobody except your project knows that Clojure exists.

Readme read more

  <build> <plugins> <plugin> <groupId>org.cloudhoist.plugin</groupId> <artifactId>zi</artifactId> <version>0.5.5</version> <executions> <execution> <id>default-compile</id> <goals> <goal>compile</goal> </goals> </execution> </executions> <configuration> <excludes> <exclude>**/test.clj</exclude> </excludes> </configuration> </plugin> </plugins> </build> 
+7
source

You might be interested in my library called ring-java-servlet.

What it provides is an already compiled generic servlet class, which can then be declared as a regular servlet in web.xml. To define the namespace names and var name of the handler, standard servlet initialization parameters are required, to which servlet service calls must be delegated.

https://github.com/laurentpetit/ring-java-servlet

+5
source

Or you can see the maven clojure plugin

+1
source

Source: https://habr.com/ru/post/925703/


All Articles