<?xml version="1.0"?>
<!--
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 -->

<document>
  <properties>
    <title>Concepts to Understand Before Using Maven</title>
    <author email="jeffjensen@upstairstechnology.com">Jeff Jensen</author>
  </properties>

  <body>
    <section name="Plugins">
      <subsection name="What are Plugins">
        <p>
          Read the "Plugin" definition in the
          <a href="/reference/glossary.html">glossary</a>.
        </p>
        <p>
        Maven plugins implement the functionality.
        For example, the "java" plugin does java operations
        such as the "compile" goal.
        </p>
        <p>
        Plugins are installed in the local Maven repository
        along with the other non-plugin dependencies.
        </p>
        <p>
        For plugin reference information,
        refer to the <a href="/plugins/index.html">Plugins</a> page.
        </p>
        <p>
        Maven 1 has two types of plugins:
        <ol>
          <li>Bundled</li>
          <li>Non-Bundled</li>
        </ol>
        See below for details on these plugin types.
        </p>
        <p>
        Note that in Maven 2, all plugins are non-bundled.
        </p>
      </subsection>
      <subsection name="Bundled Plugins">
        <p>
          Bundled plugins are those that come with the Maven distribution.
          Users need no additional actions to use them.
          Refer to the
          <a href="/plugins/bundled/index.html">Plugins List</a>.
        </p>
      </subsection>
      <subsection name="Non-Bundled Plugins">
        <p>
          Non-bundled plugins are those that do not come with the Maven distribution.
          This is how Maven is expandable with new functionality -
          anyone can create a Maven plugin.
        </p>
        <p>
          Since these plugins do not ship with Maven,
          the user must install them into the local Maven repository.
        </p>
        <p>
          There are three ways to install a Maven plugin:
          <ol>
            <li>
              Declare the plugin as a dependency in the project.
              Maven will then automatically download and
              install it into the local repository.
              <p>
               This is typically the preferred method.
               The benefits of this approach are:
              <ul>
                <li>Reproducibility: The project has plugin dependencies documented in addition to jar dependencies.</li>
                <li>Ease: The download and install is automatic for all users/computers.</li>
                <li>Snapshots: When the version is a SNAPSHOT, Maven always checks for newer versions.</li>
              </ul>
              </p>
              For example:
<source><![CDATA[
<dependency>
  <groupId>maven-plugins</groupId>
  <artifactId>maven-findbugs-plugin</artifactId>
  <version>1.3</version>
  <type>plugin</type>
</dependency>
]]></source>

            </li>
            <li>
              Use the "plugin:download" goal to
              download and install it to your local repo.
              For example:
<source>
maven plugin:download -DgroupId=maven-plugins -DartifactId=maven-findbugs-plugin -Dversion=1.3
</source>
            </li>
            <li>
              Manually download the plugin and place it in the local repo.
            </li>
          </ol>
        </p>
        <p>
          Refer to the non-bundled plugins in the list on the
          <a href="/plugins/index.html">Plugins</a> page.
        </p>
      </subsection>
    </section>

    <section name="Goals">
      <p>
        Read the "Goal" definition in the
        <a href="/reference/glossary.html">glossary</a>.
      </p>
      <p>
        For example, Ant users run custom created "targets",
        and Maven users run goals.
        Usually, one runs pre-defined Maven goals
        (the bundled or non-bundled plugins have the goals),
        but sometimes users create their own goals in either
        a new plugin or in the maven.xml file.
      </p>
      <p>
        For example,
<source>
maven java:compile
</source>
        compiles the Java source.
      </p>
      <p>
        Note that you can run multiple goals one after the other
        in the same invocation of Maven.
        For example,
<source>
maven faq xdoc
</source>
        runs the faq plugin followed by the xdoc plugin.
      </p>
      <p>
        Refer to the
        <a href="/start/index.html">Getting Started</a> and
        <a href="/using/index.html">Using Maven</a>
        pages for more info.
      </p>

    </section>

    <section name="Lifecycle">
      <p>
        Maven has a "lifecycle",
        such that some plugin goals cause other plugin goals to run first.
        For example,
        running
<source>
maven jar
</source>
        causes these goals to run in this order:
        <ol>
          <li>java:compile</li>
          <li>test:test</li>
          <li>jar:jar</li>
        </ol>
      </p>
    </section>

    <section name="project.xml">
      <p>
        The project.xml file is the "POM" - project object model.
        It contains the configuration information for the project.
      </p>
      <p>
        Refer to the
        <a href="/reference/project-descriptor.html">Project Descriptor</a>
        on the Reference page for its info.
      </p>
      <p>
        Refer to
        Project Inheritence section in
        <a href="/customising.html">Customising Maven</a>
        for more info.
      </p>
    </section>

    <section name="project.properties">
      <p>
        Properties for the project are set in this file.
        When a plugin lists customization properties,
        this is the file to put them in.
      </p>
      <p>
        When extending from another POM,
        this file is inherited too.
      </p>
      <p>
        In addition to plugin properties,
        the Maven core itself has many properties.
      </p>
      <p>
        Refer to the
        <a href="/reference/properties.html">Properties Reference</a>
        on the Reference page and
        Extending the Build with Properties section in
        <a href="/customising.html">Customising Maven</a> and
        for more info.
      </p>
    </section>

    <section name="maven.xml">
      <p>
        Note, it is recommended to limit use of this file.
        The maven.xml file can contain processing customization.
        This includes
        complete custom goals and
        adding to the lifecycle of another plugin.
      </p>
      <p>
        Refer to
        Scripting Maven section in
        <a href="/customising.html">Customising Maven</a> and
        <a href="/tags.html">Maven Jelly Tag Libraries</a>
        for more info.
      </p>
      <p>
        One of the best ways to understand maven.xml
        is to look at ones in existing Maven projects,
        including those in Maven source.
      </p>
      <p>
        Note that Maven 2 does not have this file.
        Instead, the plugins and the POM has all processing and configuration.
      </p>
    </section>

  </body>
</document>

