maven.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 09 Dec 2013 21:34:08 +0200
changeset 1526 1e5c611f8ab3
parent 1512 db0fedd5662e
child 1580 638073b869c6
permissions -rw-r--r--
Join sections.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

========
 Maven.
========
.. contents::

Maven tutorial.
===============

 * http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
 * http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Maven FAQ.
==========

 * http://maven.apache.org/general.html

Maven plugins.
==============

 * http://maven.apache.org/plugins/

Generate simple project.
========================
::

  $ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Search for maven artifact by Java package or class name.
========================================================

 * https://repository.sonatype.org/
 * http://search.maven.org/

Get help on Maven plug-in.
==========================
::

  $ mvn help:describe -DartifactId=maven-war-plugin -DgroupId=org.apache.maven.plugins
  $ mvn help:describe -Dcmd=dependency:resolve -Ddetail

  $ mvn dependency:tree
  $ mvn dependency:list
  $ mvn dependency:resolve
  $ mvn dependency:resolve-plugins

  $ mvn -X ...

Reason for inclusion or omitting dependencies::

  $ mvn dependency:tree -Dverbose=true

What actual code processed by Maven::

  $ mvn help:effective-settings
  $ mvn help:effective-pom

Run Java main from Maven.
=========================
::

  mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main" -Dexec.args="arg0 arg1 arg2"

How to run single unit test?
============================

``test`` property substituded to ``**/${test}.java`` pattern and override any
include/exclude patterns::

  $ mvn test -Dtest=SeriousComponentTest

or mostly same::

  $ mvn test-compile surefire:test -Dtest=RunMe

How do I skip the tests during the default lifecycle?
=====================================================
::

  $ mvn -DskipTests package

Download all external dependencies sources and javadocs.
========================================================
::

  mvn dependency:resolve -Dclassifier=javadoc
  mvn dependency:resolve -Dclassifier=sources

Run Ant from Maven.
===================

 * https://support.sonatype.com/entries/20736282-executing-an-external-ant-script-in-a-maven-build
 * https://support.sonatype.com/entries/20723081-running-an-inline-ant-script-in-a-maven-build
 * https://support.sonatype.com/entries/20744068-writing-a-maven-plugin-with-ant