[Java] Maven goal types

less than 1 minute read


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.


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


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