*NOTE:* _This page contains drafts of user contributed FAQ entries. The content you see here might not be fully fool-proof or might not comply with the best practices promoted by Maven. What is only guaranteed is that they have worked once for some members. It is best to treat these items as "works in progress" until they have been reviewed and promoted to the main Maven documentation site._

Users may also list questions here that they would like answered. So this page can serve as a collection of questions that users would like answered. Please put unanswered questions at the bottom. Please follow the format that is being used because it will help in our automated exaction of material which can then be incorporated into the main site.

h1. Answered Questions

h3. Why am I getting a "<plugin name> does not exist or no valid version" error? 

This means that Maven is unable to access the required plugin from your local repository, and unable to access the official or 'central' Maven2 plugin repository. 

You may troubleshoot the problem by performing the following actions: 
# If you are behind a http proxy, please check the Maven2 [proxy settings guide|http://maven.apache.org/guides/mini/guide-proxies.html]. 
# If the plugin you seek cannot be redistributed freely then you may [add it manually to your repository|http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html]. 

If the problem still persists you may seek help from the Maven user list, browse [archived discussions|http://www.mail-archive.com/users@maven.apache.org/], or log a [ticket|http://jira.codehaus.org/browse/MNG] describing your problem if you think you have found a bug. Tickets could also be issued for feature enhancement requests, and other tasks.

h3. How do I install a file in my local repository along with a generic Pom?

This solution requires at least 2.0.1-SNAPSHOT or above version of Maven 2. You may do this by typing this command (please take note that this is a single line only).

{code}
mvn install:install-file 
      -DgroupId=<group-id> 
      -DartifactId=<artifact-id>
      -Dversion=<version>
      -Dfile=<path-to-file>
      -Dpackaging=<packaging> (i.e. jar)
      -DgeneratePom=true
{code}

This command installs the jar in your local repository with the generated generic pom.

h3. How do I install a file in my local repository along with my customed Pom?

The solution requires at least 2.0.1-SNAPSHOT or above version of Maven 2 and add the -DpomFile=<path-to-pom> parameter just like the sample below.

{code}
mvn install:install-file 
      -DgroupId=<group-id> 
      -DartifactId=<artifact-id>
      -Dversion=<version>
      -Dfile=<path-to-file>
      -Dpackaging=<packaging> (i.e. jar)
      -DpomFile=<path-to-pom>
{code}

This command will install the file in your local repository along with your customed pom.

h3. Are there any ways of including/excluding the other modules in the navigation menu in the parent site?

[http://jira.codehaus.org/browse/MNG-661], provides a simple patch which provides parent and module links using the project URLs which as you
correctly point out only work when the site is deployed.

h3. Where is the ______ plugin?

If you cannot find a certain plugin, you may want to take a look on the following sites. 

# http://mojo.codehaus.org  
# https://svn.codehaus.org/mojo/trunk/mojo
# https://svn.codehaus.org/mojo/trunk/mojo/mojo-sandbox

h3. Why are there no pre/post goals in Maven 2.x?

In Maven 1.x, pre/postGoals were used to inject custom behavior to the build process. This caused a problem, since declaring your code to be a preGoal of some other goal meant that you depended on that specific goal, rather than the work it did. It also caused confusion when trying to inject other behavior into a build that already had pre/postGoals attached: Where would the new behavior be injected?.

Pre- and post-goals in Maven 1.x were usually used to develop the concept of a workflow, or lifecycle, for the build, where *x* happened before *y*, which had to happen before the sources could be compiled. In Maven 2, we've incorporated this concept of a build lifecycle natively. The steps - or phases - in this lifecycle correspond to the types of actions that might occur in a build. Your plugin can declare which type of action it performs - or which phase it should bind to - and that will guarantee it is executed before the next action type. For example, if your plugin generates some source code, you might want it to bind to the "generate-sources" lifecycle phase, so it is guaranteed to run before the "compile" phase.

For more information, see:

* [Introduction to the Build Lifecycle|http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html]

h3. How does Maven compare with Ivy?

For a comparison of Maven's features vs Ivy's you can refer to our [feature comparison|http://docs.codehaus.org/display/MAVEN/Feature+Comparisons]

h3. How do I get the dependencies of a plug-in from within a Mojo?

{code}
public class MyMojo
    extends AbstractMojo
{
    /**
     * @parameter expression="${plugin.artifacts}"
     * @required
     */
    private List pluginArtifacts;

    public void execute()
        throws MojoExecutionException
    {
        ...
        for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
        {
            Artifact pluginArtifact = (Artifact) i.next();
        }
        ...
    }
}
{code}

h3. How do I get the sources for a project within a Mojo?

{code}
public class MyMojo
    extends AbstractMojo
{
    /**
     * @parameter expression="${project.compileSourceRoots}"
     * @required
     */
    private List sourceRoots;

    public void execute()
        throws MojoExecutionException
    {
        ...
        for ( Iterator i = sourceRoots.iterator(); i.hasNext(); )
        {
            String sourceRoot = (String) i.next();

           // Do what you want with these directories
        }
    }
}
{code}

h3. How do I use SNAPSHOT versions of plug-ins?

The POM is meant to be current state, not history. We actually only record the versions in the repository, and if the SCM tag is populated in the <scm> section of the POM for each released version you can reconstruct the information.

There were other issues with putting history in the POM: forgetting to add it, getting the right level of information when you work on multiple branches, and similar things.

h3. How do I create a report that does not require using Doxia's Sink interface?

Make it a report and override the isExternalReport() method to return true. Then you don't need to use the Sink at all.

h3. Is it possible to prevent warnings from a custom repository?

Warnings from custom repositories (usually located within the organization's network, or even on the same workstation) are triggered when Maven tries to verify the integrity of the files in the repository. This verification is done via the SHA1 or MD5 sum of the file. If these sum files do not exist then a warning is shown.

Support for downloading the the security sum files is not yet included in the Maven2 distribution. There are free command-line utilities on the Internet that generate these sums. Below is an example of a bash script (use [Cygwin|http://cygwin.com] if you are using a windows machine) that generates sha1sum for all jar, xml and pom files contained in the directory where it is executed:

{code}
#!/usr/bin/bash

gensum(){
   shaname=$1.sha1

   sum=`sha1sum $1 | cut -f1 -d" "`
   echo $sum > $shaname
}

processFile(){
   while read oneline 
   do
      gensum $oneline

   done < "$1"
}

tmpFile=$TMP/shagen.list

echo "Generating sha1 sums for XML files"
find . -name "*.xml" > "$tmpFile"

processFile "$tmpFile"

echo "Generating sha1 sums for POM files"
find . -name "*.pom" > "$tmpFile"

processFile "$tmpFile"

echo "Generating sha1 sums for JAR files"
find . -name "*.jar" > "$tmpFile"

processFile "$tmpFile"

rm "$tmpFile"
{code}

The script above has been tested on [Cygwin|http://cygwin.com] and is provided as is and with no guarantee.

h3. Why am I getting the following error when I run the <plugin_name>: "ERROR: Cannot override read-only parameter: <parameter_name>"?

This means that the parameter you are overriding in your pom.xml is readonly. Hence, it is not possible to override this parameter.

h3. The sites of the plugins of Maven have a page with an overview of the goals and the parameters of the plugin. How is this generated?

Include maven-plugin-plugin as a report.

h3. how can I define the antrun plugin to be executed on demand like "mvn antrun:run"?

This isn't actually possible with the plugin, unless perhaps you do this:
- put everything in a top level configuration of the plugin
- pass in a variable from the command line, eg -Dtarget=foo antrun:run
- execute the appropriate target in the script based on the variable

Ideally, you would write a plugin for these goals (Ant support for
plugins will be available soon, currently you must write them in java
or beanshell).

h3. When I extend a mojo from another plugin, it's variables are not properly populated. Why?

The field metadata when creating plugins is read from source files, so is not available when the original source is not. The metadata is available in the plugin in {{META-INF/maven/plugin.xml}}, but at this point there is no way to incorporate it when building a new plugin.

We currently recommend building your plugins using composition instead of inheritence.

h1. Unanswered Questions

h3. Where can I find a listing of the available variable references that could be use during site generation?

h3. How do I generate sources with the antrun plug-in?

h3. Can I disable transitive dependencies?

h3. How do I run a shell script from inside a Mojo?

h3. Are resources inherited in the POM?

h3. Why is there no <versions/> element in the v4.0.0 POMs?

h3. How do I find the stale resources in a Mojo to avoid reprocessing them?

h3. Will the release plug-in resolve all my SNAPSHOT dependencies?

h3. How do I integrate static (x)html into my Maven site?

h3. Where did the properties files go for plug-in configuration in Maven 1.x?
