Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 89 Next »

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.

Answered Questions

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:

  1. If you are behind a http proxy, please check the Maven2 proxy settings guide.
  2. Try running with -U - this will force an update check on all plugins. This is often necessary if upgrading Maven from a pre-beta release.

If the problem still persists you may seek help from the Maven user list, browse archived discussions, or log a ticket describing your problem if you think you have found a bug. Tickets could also be issued for feature enhancement requests, and other tasks.

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).

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

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.

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

Are there any ways of including/excluding the other modules in the navigation menu in the parent site?, 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.

Where is the ______ plugin?

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


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:

How does Maven compare with Ivy?

For a comparison of Maven's features vs Ivy's you can refer to our feature comparison

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

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

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

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.

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.

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 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:

The script above has been tested on Cygwin and is provided as is and with no guarantee.

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.

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.

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).

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.

What to do when Ibiblio is down?

You may use mirror site for the central repository

Where can I find the list of archetypes?

You may refer to this page

What is the equivalent of 'maven.repo.remote' in M2?

In maven 2 you may specify your remote repo by adding the <repositories> element in your pom.

or you may refer to this page

Is it possible to control which output folders the eclipse plugin puts into the .classpath file?

What's the m2 equivalent of "maven dist"?

This is already the maven-assembly-plugin.

Is it possible for a profile to inherit the configuration of a sibling profile?

Profiles merge when their id's match - so you can inherit them from a parent pom (but you can't inherit them from the same pom).

I need to run an ant task twice on two different phases. How do I do this?

You can specify multiple execution elements under the executions tag, giving each a different id and binding them at different phases.

The tests run twice after i add a config for the surefire plugin. How do I prevent this?

Declare the configuration outside of the executions tag of the plugin.

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

You can integrate your static pages in this several steps,

  • Put your static pages in the resources directory, ${basedir}/src/site/resources.
  • Create your site.xml and put it in ${basedir}/src/site. An example below:
  • Link the static pages by modifying the <menu> section, create items and map it with the filename of the static pages.

I have a number of web modules that contain a common group of files. Is it possible to have a parent web module that contains all the common files which the other web modules will just inherit?

maven-war-plugin supports merging of wars. Just reference the common WAR project from another WAR project as a dependency of <type>war</type> and it will automatically be merged.

Is there a way to determining which POM contains missing transitive dependency?

run "mvn -X"

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

There are no more properties files for plugin configuration in maven 2. You can already configure the plugins directly in command line using the -D arguement or in the pom of the plugin using the <configuration> element.

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

This can be done using the following piece of code:

The second parameter to the StaleSourceScanner is the set of includes, while the third parameter is the set of excludes. You must add a source mapping to the scanner (second line). In this case we're telling the scanner what is the extension of the result file (.html) for each source file extension (.xml). Finally we get the stale files as a Set<File> calling the getIncludedSources method, passing as parameters the source and target directories (of type File). The Maven API doesn't support generics, but you may cast it that way if you're using them.

In order to use this API you must include the following dependency in your pom:

I get a FATAL ERROR with the message "Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log" when using the maven-checkstyle-plugin. What am I doing wrong?

Checkstyle uses commons-logging, which has classloader problems when initialized within a Maven plugin's container. This results in the above message - if you run with '-e', you'll see something like the following:

Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log

buried deep in the stacktrace.

The only workaround we currently have for this problem is to include another commons-logging Log implementation in the plugin itself. So, you can solve the problem by adding the following to your plugin declaration in your POM:

While this may seem a counter-intuitive way of configuring a report, it's important to remember that Maven plugins can have a mix of reports and normal mojos. When a POM has to configure extra dependencies for a plugin, it should do so in the normal plugins section.

We will probably try to fix this problem before the next release of the checkstyle plugin.

UPDATE: This problem has been fixed in the SVN trunk version of the checkstyle plugin, which should be released very soon.

Which part of the pom should we configure report plugins like javadoc? Plugin section under <build> or plugin section under <reporting>?

Generally, you should configure it in the reporting section. Configuration there applies to both the site, and when run on the
command line, and adding the plugin there adds the report to the generated site.

Configuration in the build section is only used during the normal lifecycle or the command line invocation (eg javadoc:javadoc).
Configuration should go there if you do not want the report on the site, or the configuration differs from what is on the site (eg, some
plugins have a fail build option).

I want my binary to be deployed during deploy phase, how do I do that?

Then run "mvn deploy".

How to add main class in the manifest of the generated jar?

Configure the maven-jar-plugin and add your main class.

How to install artifacts in a remote repository?

You need at least 2.1-SNAPSHOT version of maven-deploy-plugin to make this work, current workaround to use this is to copy the wagon provider jar (ie. wagon-ftp-1.0-alpha-3.jar) in your %M2_HOME%/lib and execute the command:

Are resources inherited in the POM?

Yes, resources are inherited but only if the child pom does not define any resources. If it does, then the project just uses those resources defined in its pom and the parents resources are overridden.

How do I use SNAPSHOT versions of plug-ins?

I want to short circuit the build/package/deploy process so that developers can get a quick on-demand build/deploy to an integration box, possibly not wanting to wait for reporting and/or unit tests. How do I do this?

You could create a specific profile that skips the reporting and test phases.

How can I configure the equivalent of maven.war.src of war plugin in m2?

See for other configurable properties of the war plugin.

How to execute the assembly plugin with different configurations?

Add this to your pom,

and run mvn install, this will execute the assembly plugin twice with different config.

What is the order of inheritance?

  1. parent pom
  2. project pom
  3. settings
  4. CLI parameters

where the last overrides the previous.

In modello, do I need to copy the generated sources in my source tree or will the sources be automatically added to the compile path of maven?

Modello generate the sources in the generate-sources phase and automatically add the source
directory for compilation in maven. So you don't have to copy the generated sources.

You have to declare the modello-plugin in the build of your plugin for
source generation (in that way the sources are generated each time).

How can I add a java source to my war package?

You cant, but you can use assembly plugin to create a source distribution and a binary distribution for your project

Please refer to these sites for more info

Where is the site.xml DTD?

There is no DTD but XSD.

Maven is returning this message "You cannot have two plugin executions with the same (or missing) <id/> elements". What does it mean?

It means that you have executed a plugin multiple times with the same <id>. Provide each <execution> with a unique <id> then it would be ok.

Can I disable transitive dependencies?

No you cant, but you may exclude the dependencies you dont want to include in your project.

Following is a sample on how to exclude transitive dependencies.

Where can I get the offline documentation of maven?

Check it out from and run mvn site:site

How do I skip unit tests when building a project?

Run the mvn command with "-Dmaven.test.skip=true" argument.

Unanswered Questions

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

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

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

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

What is the purpose of displaying read-only plugin fields in the user documentation if they could not be configured in the project descriptor?

How to copy files from local repo to remote repository?

Where should sql, dtds, test data and generated docs go?

Why the FTP Wagon hangs?

Is there a way for plugin goals to be aware of the phase they are being executed on?

I've got my plugin pom setup to build everything and construct the final zip file. The issue I'm trying to wrap my brain around is keeping my feature.xml and site.xml files up to date with the correct version info. Since I can't use versions like 1.0.0-SNAPSHOT in my plugin, I have to munge the plugins pom version into something like 1.0.0.v${DATETIME} and insert that into the plugins descriptor (plugin.xml). Since the version in the plugin.xml changes I have to update the plugin entries in the feature descriptor (feature.xml), rev the feature and update the site.xml with the new feature version. Just curious to see if anyone else out there is struggling with these same issues and what if any solutions/band-aids have been implemented

In a multi-module project, is there any way for maven to build only those modules that have changed from the previous build and leave the unchanged modules alone (i.e. not build them)?

When I run the release:prepare goal I get an authorization failed error. I tried adding the username and password into my pom.xml file and I still get the error. I checked using the command line and my username and password is being cached by subversion. Any ideas?

When you have a project using a code generator plugin, how can we add the generated sources in the list of eclipse source directory?

Why am I getting this error when I build my project: "Unable to locate the Javac Compiler"?

Why do I get java.lang.NullPointerException while trying to generate site for a project?

How do I tell maven which version of ant I want it to call?

Is there a way to get Maven to report the number of compile errors found?

  • No labels