Is Maven mandatory for Clojure on the JVM?

I am a little surprised by the huge number of articles / blogs / questions / answers about Clojure that mention Maven.

After about ten years, working as a Java developer, working with both desktop applications and webapps, I never used Maven once (usually - and this is a personal opinion, but I know that some people think the same way) projects that I saw using Maven, including the “kitchen sink”, while those that were built with a more “controlled” assembly process, where they are cleaner and produce smaller cans, speed up the assembly time, etc.).

Is Maven required when you want to create a Clojure app?

Is Maven mandatory if you want to use Leiningen? For example, is it possible to add external banks depending on the leiningen project “manually” without requiring Maven?

I think my question boils down to the following: can you leave the Clojure / JVM world without ever using Maven, just like you can create, test, package and ship both in Java and web applications and applications for Android without ever needed Maven?

+8
maven clojure leiningen
source share
4 answers

Short answer: No. Clojure is only a jar, and you can use it as "raw" as you like, like any other Java library.

Longer answer: Maven is not a requirement, but the tool around Clojure, especially Leiningen, is very aligned with Maven, so your life will be easier if you simply obey Maven. But, with a little work, it's not so difficult to do without Maven. At work, I use a combination of Leiningen and our existing Ant / Ivy build infrastructure. I use Ant to resolve dependencies (from our curated internal repo), and then use Leiningen :resource-paths hack to get it to pick up banks other than Maven. At some point, I will make a real plugin to do this, but it has worked for me so far.

In addition, if you are an Eclipse person and use CounterClockwise, you can treat your project like any other Java project in Eclipse by manually managing the class route. It just happens that you have Clojure code.

Of course, the disadvantage of both approaches is that if you want to capture something that is accessible either from the Maven central center or from Clojars, you will either have to configure a mirror for your infrastructure, or manually derive transitive dependencies and add them to your project .

+14
source share

You do not need to use maven or leiningen, for that matter. You can run clojure REPL with

  java -jar clojure-1.3.0.jar 

and all will be well. I know where you come from, because a year ago I was in the same boat as you. never used maven, saw a couple of smaller projects that used it poorly, and generally did not trust maven. Ant + ivy works fine, who needs maven?

As a result of using leiningen and starting a new job, where we have a very well configured maven configuration, I completely changed my setup; Now I think maven works fine and prefers the ant that I have been using for a long time.

In particular, with clojure, some of the benefits of leiningen are as follows:

  • Highway scaffolding: "lein new" creates a new project for you. agreement is important, it helps other developers understand your project and quickly build it up.
  • addiction and plugin management. adding dependencies is trivial, and I don’t know how to do it using dependency management other than maven, which is tightly integrated with clojure.
  • "lein repl" sets your class path and everything is correct, so you do not need to spoof it, you can just start and run REPL.
  • Creating an artifact: making a thick can (lein uberjar) is simple and already set up for you.

So, although you can definitely use clojure without leiningen, I honestly don't understand why you need it. Too many amenities for everyday development, not to use it, in my opinion.

+6
source share

regarding "Is Maven mandatory if you want to use Leiningen?"

leiningen uses and wraps Maven, so you really can't escape it, although you never need to touch XML

+4
source share

Maven is optional for Clojure, as others have rightly pointed out.

However, I would urge you to accept Maven (either directly or through leiningen). It has some great advantages in the Clojure world:

  • In the long run, you will be more productive . After you configure it, it will be very interesting for you to see how complex assembly, testing and deployment are performed in one team. Do you really want to manually configure class paths, upload dependencies, increase version numbers, upload them to FTP sites, etc.?
  • One of the biggest advantages of using Clojure in the JVM is access to the Java library ecosystem. Maven is the tool of choice for automatically managing Java library dependencies. Almost everything you might need will be in the repositories of Maven Central or Clojars.
  • Clojure has small focused libraries - this is good because they are "simple" and you can select and select the functions you need. At the same time, it also means that you are likely to have more library dependencies. Consequently, a build management system will be more useful.
  • You can make Maven builds as lean as you like . Obviously, you can pull every addiction under the sun if you want, but you can also create very meager cans, eliminating the unnecessary jerk. This is your choice.
  • This is the de facto standard in the Clojure world. If nothing else, using this means that you can collaborate with others more easily.

PS Like you, I really did not see the meaning of Maven 5 years ago. Then I let him know how powerful my workflow can be. Now I am a converter :-)

+4
source share

All Articles