Java Reference
In-Depth Information
Solution
Use Maven.
Discussion
Maven is a tool one level up from Ant. Although Ant is good for managing compilation,
Maven includes a sophisticated, distributed dependency management system that also gives
it rules for building application packages such as JAR, WAR, and EAR files and deploying
them to an array of different targets. Whereas Ant build files focus on the
how
, Maven files
focus on the
what
, specifying what you want done.
Maven is controlled by a file called
pom.xml
(for Project Object Model). A sample
pom.xml
might look like this:
<project
<project xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
<modelVersion>
4.0.0
</modelVersion>
</modelVersion>
<groupId>
<groupId>
com.example
</groupId>
</groupId>
<artifactId>
<artifactId>
my-se-project
</artifactId>
</artifactId>
<version>
<version>
1.0-SNAPSHOT
</version>
</version>
<packaging>
<packaging>
jar
</packaging>
</packaging>
<name>
<name>
my-se-project
</name>
</name>
<url>
<url>
http://com.example/
</url>
</url>
<properties>
<properties>
<project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
<groupId>
junit
</groupId>
</groupId>
<artifactId>
<artifactId>
junit
</artifactId>
</artifactId>
<version>
<version>
4.8.1
</version>
</version>
<scope>
<scope>
test
</scope>
</scope>
</dependency>
</dependencies>
</dependency>
</dependencies>
</project>
</project>