Practical Java Tips
Copyright © 2009 Maximilian Berger, University of Innsbruck
This document or part of this document may only be re-published with the written consent of the copyright holder. Source code examples may be re-used under the following conditions:
-
The resulting code must be published under an OSI approved open-source license.
-
The source code must refer to this document and contain my name (Max Berger).
-
If the project contains a contributor or thanks list, it must mention my name (Max Berger) in the same style as it would mention someone contributing a patch.
Project Management
Maven
-
Download from http://maven.apache.org/
-
Complete Project Management Tool
-
Describe WHAT rather than HOW
-
Convention over configuration
Important Conventions
-
Project is described in
pom.xml -
Java source is in
src/main/java -
Java tests are in
src/test/java -
Webpage is in
src/site -
Artifacts go to
target/
<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.uibk.ac.at.dps</groupId>
<artifactId>sample</artifactId>
<name>Sample Project</name>
<version>0.1.0-SNAPSHOT</version>
<inceptionYear>2009</inceptionYear>
<licenses>
<license>
<name>GNU General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/gpl-3.0-standalone.html</url>
<distribution>manual</distribution>
</license>
</licenses>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<debug>false</debug>
<optimize>true</optimize>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
Important Maven commands
- mvn test
-
Compile and run tests
- mvn package
-
Compile, run tests, and package
- mvn install
-
Compile, run tests, package, and install locally
- mvn site
-
Run reports and generate website
For a list of available plugins use http://www.mvnrepository.com/ .
Other items that can be configured are
-
description
-
developers
-
contributors
-
scm