67

What is the difference between Maven and Jenkins?

Both support automated builds and automated execution of JUnits.

If so, are they complimentary, or mutually exclusive? When should onebe used over the other?

1
  • 6
    Thanks for both the answers, what I got from here is that Maven in itself is a build tool while Jenkins is a Continuos Integration tool which can be configured to make automated builds through Maven or Ant files
    – abson
    Commented May 31, 2012 at 13:41

4 Answers 4

90

Maven is building tool/environment. Jenkins is a CI (continuous integration) tool.

Maven is more like a replacement for Ant.

  1. It assists building of the project through plugins e.g build and version control, JUnit tests, etc...
  2. It manages dependencies of your project. you define how a project should be built(plugins), and what libraries are needed (dependencies) in a pom.xml file.

Jenkins as a smart job scheduler, can not assists you with tasks like version control or JUnit test, however it can indirectly assists you with all this, by making calls to the pom.xml file in your project. And Jenkins gives you the power to decide when to call the pom.xml file, based on what condition to call, and what you want to do with the outcome. and Jenkins can listen to different events, e.g svn commit, current time is midnight etc..

This is a powerful idea. For example, you can ask Jenkins to trigger a build or run through all JUnit tests whenever a new code is committed and then, if the unit tests are passed, deploy on a target machine. or schedule heavy tasks at midnight e.g unit tests.This is the basic idea of auto deployment or AKA continuous integration. CI for short if you like.

5
  • thanks for ur reply but Junits can be executed even through pom.xml via Maven rite...Correct me otherwise. Thanks in advance
    – abson
    Commented May 31, 2012 at 13:24
  • like I said in the second paragraph, Maven gives you support to run junit. to trigger the Maven test phase, you need type "mvn test". again Jenkins doesn't help you carry out the test, it depends on maven and the pom file Commented May 31, 2012 at 13:26
  • 2
    I wouldn't say Maven is a replacement for Ant; I'd use the word alternative instead. My preference is Ant, because I find Maven to be rather heavy and not as intuitive as Ant. It also forces a directory convention on me that I don't like and can't override.
    – duffymo
    Commented May 31, 2012 at 14:29
  • 6
    In general maven was designed to over come issues Ant had before. Also in reality, more and more projects start using maven over Ant. In recent years Eclipse and Netbeans choose Maven rather then Ant as their default built tool. For those reasons I say Maven is intended to be the replacement for Ant. To help you think, Java and C++ doesn't stop people using assembly language, but its a fact, 99.9% programs are not implemented by assembly anymore. Commented Jun 2, 2012 at 10:12
  • I like your answer -- however, I question the accuracy of the statement can not assists you with tasks like version control -- because there are plugins that facilitate interaction between it and various VCSs
    – amphibient
    Commented Oct 11, 2017 at 20:58
28

Maven is a build tool that manages dependencies and the application life cycle. It also had a plug in design that allows you to add other tasks to the standard compile/test/package/install/deploy tasks.

Jenkins is a continuous integration suite that checks your code out of a repository, builds and packages it, and dumps it out to a server so you can test it - all hands-off. It can use Maven or Ant as its build tool.

In summary, Jenkins can use Maven as its build tool for continuous integration. You can use Maven without Jenkins if you choose not to do CI.

6
  • 2
    @abson - Yes. Read this page wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project ... and note it says "... some sort of build script that performs the build (ant, maven, shell script, batch file, etc.) where the real work happens"
    – Stephen C
    Commented May 31, 2012 at 13:27
  • @duffymo, How can we use Maven without CI like Jenkins?Can you please explain more about it?If we use maven only, how CI will contact pom.xml? what is use of maven without CI? Can We uniform unit tests without CI using maven only in xcode?
    – user141302
    Commented Jun 4, 2013 at 4:41
  • Certainly you can use Maven without CI - just run it. I said it was possible to run CI without Maven. The ones I know accept Ant just fine.
    – duffymo
    Commented Jun 4, 2013 at 9:02
  • what is the use when we use maven without CI.If we use CI only,we can uniform unit testing..Can you please help in this as i am newbie?Can we get any benifit when we use maven without CI,bcos main purpose is depending on CI?
    – user141302
    Commented Jun 6, 2013 at 5:37
  • No, it's not. You don't know the history of either one. Maven and Ant are both build tools - that's all. Maven helps you manage JAR dependencies from a central repository; Ant does not. That's it. Maven came along before CI. Most CI platforms started off with Ant because it's far simpler than Maven.
    – duffymo
    Commented Jun 6, 2013 at 9:13
4

The first paragraph of the Jenkins Maven plugin wiki page explains the interaction between Jenkins and Maven:

"Managing Jenkins jobs is not easy when there are many of them, especially if certain parameters should be identical among many jobs. "jenkins-maven-plugin" allows to generate Jenkins jobs, one "config.xml" per job, from a simple Maven POM. This way we can have all Jenkins jobs controlled in one place, reusing any amount of configuration between them."

1

Maven is a build tool, in short a successor of ant. It helps in build and version control.

However Jenkins is continuous integration system, where in maven is used for build. Jenkins can be used to automate the deployment process. When ever the new code is committed, automatically run all Junit test cases and if they're passed, package and deploy the project to the specific location.

Not the answer you're looking for? Browse other questions tagged or ask your own question.