Friday, 31 October 2014

Maven Usage

Maven is used for compiling and managing dependencies.
The pom.xml file is the XML representation of the project and thus contains all metadata pertaining to the project.

1. Generate a Maven Java project

$ mvn archetype:generate

you will have to enter the Maven "project co-ordinates" such as groupId, artifactId, version, and package.
groupId: com.companyname
artifactId: project name
version: 1.0-SNAPSHOT
packaging: jar

2. Compile a project. Navigate to pom.xml folder.

$ mvn compile
It will download dependencies, then It will trigger the Java compiler associated with the project.

3. $ mvn test

Triggers Maven to run the tests present in the .../src/test folder

4. Download sources of dependencies, check the default settings of maven
$ mvn -X
Load sources

$mvn dependency:sources

5. Run an individual module and skip the tests


$ mvn clean install -rf :ethoca-ejb -DskipTests


6.  build the JAR
mvn clean package

run the JAR

mvn exec:java -Dexec.mainClass="SimpleApp"





No comments:

Post a Comment