mvn[options] <One or more Phases OR Goal Plugins[along with plugin options], in any order>
mvn[phase-name]
mvn[plugin-name]:[goal-name]
compile: org. apache. maven. plugins:maven-compiler-plugin:2. 3. 2:compile
). To figure out a valid pluginName please see the next section. -Dcmd=compile
belongs to default lifecycle. -Dcmd=compiler:compile
maven-<plugin_name>-plugin
if group id is org.apache.maven.plugins
otherwise it is <plugin_name>-maven-plugin
. The first one is the reserved naming pattern for official apache maven plugins maintained by the apache maven team with groupId org.apache.maven.plugins
.[plugin_name]:[goal_name]
. For example from above output, look at the following line closely*test: org.apache.maven.plugins:maven-surefire-plugin:2.10:test
phase_name: plugin_group-id:plugin_qualified_name:version:plugin_goal_name
. From this kind of output, we can easily figure out the plugin goal syntax. In this case, that would be: surefire:test
-Dplugin=[plugin_name]
option of describe mojo. For example mvn
help:describe
-Dplugin=
compiler
Command | Description | Task details |
---|---|---|
mvnclean | Invoking clean phase of Clean LifeCycle | Removes the files from a project's working directory, that were generated at build-time. Alternatively we can execute the plugin: mvnclean:clean That will do the same thing. |
mvncompile | Invoking compile phase of Default Lifecycle | Compiles the source code of the projects. This command will do all pre compile phases which are validate, initialize, generate-sources, process-sources, generate-resources, process-resources, and finally compile. Remember execution falls from start to the phase we are invoking. That makes sense because for a phase to work it's prerequisite state must be achieved. One important point here: by default executing this phase will download external dependencies from remote repository. In fact any first plugin in execution sequence annotated with @requiresDependencyResolution will cause that (we will see that annotation in action when we learn how to write our own plugins) Again we can do the same thing as: mvncompiler:compile |
mvnclean package | Invoking clean phase of Clean Lifecycle followed by package phase of Default Lifecycle. | Cleans the target directory first then compiles, runs unit tests and packages the compiled code and other files into a single file. The type of final file being created depends on what we have defined in <packaging> in our pom.xml. the valid packaging values are jar, war, ear and pom |
mvnclean install | Invoking clean phase of Clean Lifecycle followed by install phase of Default Lifecycle. | Cleans the previous build, then packages and then install the package into the local repository. Which by default is at User Home Directory/.m2/repository/. The local repository is a cache of the remote downloads(dependencies), and locally installed artifacts) which can be used as a dependency in other local projects. Our locally installed artifacts are actually temporary ones until we release that and put into some remote repository. |
mvntest | Invoking test phase of Default Lifecycle. | Runs the unit test from compiled source and test source files. This is one step above package phase. If we are running some post test phase and want to skip tests then use skip optionObject. For example mvninstall-Dmaven.test.skip=true |
mvndependency:list | Invoking list goal of dependency plugin (a tool, not bound to any phase by default) | Lists all Maven dependencies from our project. Please usemvn help:describe -Dplugin= dependency to see other goals available with this plugin. From help:describe you can discover more goals of a plugin, then to know more about a particular goal (let's say 'get' goal of 'dependency' plugin), you can use: mvn help:describe -Dcmd= dependency:get |
mvnhelp:effective-pom | Invoking effective-pom goal of help plugin(tool) | Displays the effective POM as an XML for this build. This is also helpful to know what currently plugins (either bound to a phase or tool plugins) are available/installed. Please invoke to see all goals available with help plugin. |
-X
flag (which provides some extra DEBUG information). For example mvn-Xcompile