- Multiple jars
- Dependencies and versions
- Project structure
- Building, publishing and deploying
- create directory structure
Maven Repository
- create an archetype
$ archetype:generate
- Group ID:
- Artifact ID:
- Version:
- Package:
- Maven co-ordinates
- Metadata
- Build information
- Resources and Dependencies
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<packaging></packaging>
<name></name>
<url></url>
<!-- when to use the dependency -->
<dependencies>
<dependency>
<scope></scope>
</dependency>
<dependencies>
- scope: in which phase the dependency is available
It is important to setup the source directory so that IDE will look for source code files.
<build>
<sourceDirectory>../src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- only look for
<includes><include>**/core/**</include></includes>
</configuration>
</plugin>
</plugins>
</build>
In this example, the sources are found in the parent directory ../src/main/java, and only Java files within a core package are included.
- Previous phases need to be run successfully in order to run current phase.
-
validate
-
compile
-
test
-
package
-
install: publish an artifect to a local maven repository.
-
deploy: publish an artifect to remote maven repository.
-
clean: remove all jobs have been done. (e.g. remove target folder)
- We provide plugin block in
pom.xml
to overwrite default configuration.
pom.xml
<build>
<plugins>
<plugin>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<configuration></configuration>
</plugin>
</plugins>
</build>
- To use plugin
$ mvn plugin_name:supported_command
<!-- config compiler version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>