View RSS Feed

My Java Tips

Managing dependencies using Maven

Rate this Entry
by , 11-05-2011 at 06:42 PM (881 Views)
Maven can manage all jar file dependencies for the build machines. Let me explain how to do this.




We use dependency element to refer to a jar file which reside in a remote repository. It is said that in near future, the dependencies will extend beyond jar files. Maven places the jar files (fetched from remote repository) on the local repository. The element has three child elements, , , and . Maven looks in the remote repository for a directory with the same name as the . Under that directory, it looks for a jars subdirectory. Inside the jars directory should be a jar file that has the filename id-version.jar. In the given example, the defined first dependency will look for ant-1.4.1.jar in the remote repository. The url element is used for documentation only.</id></url></version></id></dependency>
<dependencies>
<dependency>
<id>ant </id>
<version>1.4.1 </version>
<url>http://jakarta.apache.org/ant/ </url>
</dependency>

<dependency>
<id>commons-beanutils </id>
<version>1.4 </version>
</dependency>

<dependency>
<id>commons-collections </id>
<version>2.0 </version>
<url>http://jakarta.apache.org/commons/collections.html </url>
</dependency>

<dependency>
<id>commons-configuration </id>
<version>1.0-dev </version>
<url>http://jakarta.apache.org/commons/ </url>
</dependency>

<dependencies>
</dependencies></dependencies>

Submit "Managing dependencies using Maven" to Facebook Submit "Managing dependencies using Maven" to Digg Submit "Managing dependencies using Maven" to del.icio.us Submit "Managing dependencies using Maven" to StumbleUpon Submit "Managing dependencies using Maven" to Google

Tags: None Add / Edit Tags
Categories
Maven , XML

Comments