[Java] Maven goal types

less than 1 minute read

Introduction

Maven executes the build based on the pom.xml build tool for Java. Describes the command.

Convert to #eclipse

mvn eclipse:eclipse
mvn eclipse:clean

To IntelliJ

mvn idea:idea
mvn idea:clean

Mavne Project Creation

Creating a Mavne project

mvn archetype:generate

Specify archetype

mvn archetype:generate -DarchetypeGroupId=${groupId} -DarchetypeArtifactId=${ArtifactId}

Specify the property with -D. It can also be used to specify other properties.

Build related

This is used in actual projects.

Compile

mvn compile

Unit test

mvn test

Mainly tested with Junit.

Create Jar or War

mvn package

Specify jar or war in pom.xml.

Install plugins and libraries in your local repository

mvn install

By default, the library (Jar) is installed from the maven central repository to the local repository. The local repository is located in the path set in ~/.m2/repository or ${Maven home}/conf/settings.xml.

Erase artifacts

Delete the target directory and below.

mvn clean

Summary

The CICD environment of Java may be prepared. Since it is only hitting Maven command internally, I summarized it this time.

References

https://qiita.com/KevinFQ/items/e8363ad6123713815e68