Skipping tests, gpg and javadoc

mvn clean install -DskipTests -Dgpg.skip -Dmaven.javadoc.skip=true

Maven Dependency Graph

Open pom.xml and go to the Graph tab to see dependency graph.

Creating maven archetypes

Generate the base-archetype

cd into the project directory (or, in the case of a multi-module project, cd into the parent/aggregator project) and run the following command:

$ mvn archetype:create-from-project
$ mvn clean

This will generate a bulk of files and folders under the target/generated-sources/archetype directory: From the folder structure you can discard the target directory sub-tree, just mvn clean it.

$ cd target/generated-sources/archetype
$ tree -d
└── src
    ├── main
    │   └── resources
    │       ├── META-INF
    │       │   └── maven
    │       └── archetype-resources
    │           └── src
    │               └── main
    │                   ├── java
    │                   └── webapp
    │                       └── WEB-INF
    └── test
        └── resources
            └── projects
                └── basic

Adjusting the archetype

  • ${rootArtifactId} to rename variables, methods, comments, etc that depends on the supplied project name.
  • __rootArtifactId__ to rename files/folders.

How to add a local library to a maven project in NetBeans?

  1. Right-click on the “Dependencies” folder in the Projects view
  2. Enter some groupId, artifactId and version information
  3. Dependency will be added to the pom.xml and will appear under “Libraries” node of maven project
  4. Right-click lib node and “manually install artifact”, fill the path to the jar
  5. Jar should be installed to local Maven repo with coordinates entered in step 2

Netbeans will issue the following mvn command behind the scenes

mvn -DartifactId={artifact id} -DgroupId={group id} -Dversion={version} -Dpackaging=jar -Dfile={path to jar} -DgeneratePom=false install:install- file

Inject Maven project informations into Java application

Install local jar with the maven-install-plugin

Suppressing GPG signing for Maven builds

Add gpg plugin in a profile as below and then when you need to do a release, add the property to your mvn command:

mvn -DperformRelease=true ...

OSSRH Sonatype Nexus

Maven always uses either one or two settings files. The global settings defined in (${M2_HOME}/conf/settings.xml) is always required. The user settings file (defined in ${user.home}/.m2/settings.xml) is optional. Any settings defined in the user settings take precedence over the corresponding global settings.

# settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns=""