References

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

http://ovaraksin.blogspot.com.tr/2012/02/inject-maven-project-informations-into.html

Install local jar with the maven-install-plugin

http://www.baeldung.com/install-local-jar-with-maven/

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 ...
<profiles>
  <profile>
    <id>release-sign-artifacts</id>
    <activation>
      <property>
        <name>performRelease</name>
        <value>true</value>
      </property>
    </activation>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.6</version>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>