Maven

Since we use Maven dependencies in our projects, I have looked at it and learnt the installation but I am still confused about it’s usage and I found it a bit complicated. Explain please?

Re: Maven

can you be more specific about your question ?

I will try to give you ELI5 (Explain like I am 5) version.

So in java, we may end up using lots of JAR files (could be third party, could be our own). One of the problem happen is that Team 1 may download a jar which is version 1 and the other team may download jar which is version 2. To make sure that both of you are on same versions, you build your project using maven.

So in maven, you tell it

  • What libraries my project is dependent on
  • What version of these libraries
  • How should you (maven) build my project

So every time when you build your project (to deploy on jboss, tomcat, weblogic etc) you build using maven (mvn clean package) and maven will take care of all the libraries and everything.

By this way, your whole team would be using same libraries, same project structure etc. The cherry on top, you can add lots of other plugins like test cases, static code analysis etc to rule out pre-liminary bugs.

Re: Maven

We use ivy but the concept should be same. What Mustafa has explained above is correct. Here is an example of our ivy.xml file for the project which downloads all the dependencies to build the jar file as the end result.



<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
	<info organisation="platform" module="data"
		revision="${version.major}.${version.minor}.${version.patch}" />
	<dependencies>
	<dependency org="junit" name="junit" rev="3.8.1" conf="default"/>
	
	
		<dependency org="javax" name="api" rev="2.3" conf="default"/>
		<dependency org="platform" name="log" rev="0.0.0">
			<artifact name="log" m:classifier="" ext="jar" />
		</dependency>
		<dependency org="electric" name="EXML" rev="0.0.0">
			<artifact name="EXML" m:classifier="" ext="jar" />
		</dependency>
		<dependency org="platform" name="controller" rev="3.8.1">
		<artifact name="controller" m:classifier="${ivy.classifier}" ext="jar" />
		</dependency>
	</dependencies>

</ivy-module>


Re: Maven

Ahaan, I understood it now, much appreciated. :k: