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 61 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. If the plugin you seek cannot be redistributed freely then you may add it manually to your repository.

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?

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.

Where is the ______ plugin?

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

  1. http://mojo.codehaus.org
  2. https://svn.codehaus.org/mojo/trunk/mojo
  3. https://svn.codehaus.org/mojo/trunk/mojo/mojo-sandbox

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?

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.

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

http://maven.apache.org/guides/mini/guide-mirror-settings.html

Where can I find the list of archetypes?

You may refer to this page http://svn.apache.org/viewcvs.cgi/maven/archetype/trunk/maven-archetypes

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 http://maven.apache.org/guides/mini/guide-multiple-repositories.html

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

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?

Can I disable transitive dependencies?

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

Are resources inherited in the POM?

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

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$
Unknown macro: {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?

  • No labels