How do I prevent "[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!"

This or a similar warning is emitted by a plugin that processes plain text files but has not been configured to use a specific file encoding. So eliminating the warning is simply a matter of finding out which plugin emits it and how to configure the file encoding for it. This is as easy as adding the following property to your POM (or one of its parent POMs):

<project>
  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  ...
</project>

[top]


How do I prevent including JARs in WEB-INF/lib? I need a "compile only" scope!

The scope you should use for this is provided. This indicates to Maven that the dependency will be provided at run time by its container or the JDK, for example.

Dependencies with this scope will not be passed on transitively, nor will they be bundled in an package such as a WAR, or included in the runtime classpath.

[top]


How do I list available plugins?

The "Available Plugins" page lists them and provides additional information. See https://maven.apache.org/plugins

[top]


How do I determine what version of a plugin I am using?

You can use the Maven Help Plugin's describe goal. For example, to find out the version of the install plugin:

mvn -Dplugin=install help:describe

Note that you must give the plugin prefix as the argument to plugin, not it's artifact ID.

[top]


How can I use Ant tasks in a Maven build?

There are currently 2 alternatives:

[top]


How can I use Maven features in an Ant build?

The Maven Ant Tasks allow many of the features of Maven, such as dependency management and repository deployment, to be used in an Ant build.

[top]


How do I set up Maven so it will compile with a target and source JVM of my choice?

You must configure the source and target parameters in your pom. For example, to set the source and target JVM to 7, you should have in your pom:

<project>
  ...
  <properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>
  ...
</project>

Or if a parent pom overrides for compiler plugin default values and you can't fix it, you'll have to explicitely force the values in the compiler plugin configuration:

<project>
  ...
  <build>
  ...
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  ...
  </build>
  ...
</project>

[top]


Is it possible to create my own directory structure?

Absolutely yes!

By configuring <sourceDirectory>, <resources> and other elements of the <build> section.

In addition, you may need to change the plugin configuration if you are not using plugin defaults for their files/directories.

[top]


Where is the source code? I couldn't seem to find a link anywhere on the Maven site.

The source code can be found in our subversion and git repositories.

For more information, see Building Maven.

[top]


Maven can't seem to download the dependencies. Is my installation correct?

You most probably need to configure Maven to use a proxy. Please see the information on Configuring a proxy for information on how to configure your proxy for Maven.

[top]


I have a jar that I want to put into my local repository. How can I copy it in?

If you understand the layout of the Maven repository, you can copy the jar directly into where it is meant to go. Maven will find this file next time it is run.

If you are not confident about the layout of the Maven repository, then you can adapt the following command to load in your jar file, all on one line.

mvn install:install-file
  -Dfile=<path-to-file>
  -DgroupId=<group-id>
  -DartifactId=<artifact-id>
  -Dversion=<version>
  -Dpackaging=<packaging>
  -DgeneratePom=true

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar
     

This should load in the file into the Maven repository, renaming it as needed.

[top]


How do I unsubscribe from Maven mailing lists?

To unsubscribe from a Maven mailing list you simply send a message to

[mailing-list]-unsubscribe@maven.apache.org

So, if you have subscribed to users@maven.apache.org then you would send a message to users-unsubscribe@maven.apache.org in order to get off the list. People tend to have problems when they subscribe with one address and attempt to unsubscribe with another. So make sure that you are using the same address when unsubscribing that you used to subscribe before asking for help.

If you find you still cannot get off a list then send a message to [mailing-list]-help@maven.apache.org. These instructions are also appended to every message sent out on a maven mailing list ...

[top]


How do I skip the tests?
Add the parameter -Dmaven.test.skip=true or -DskipTests=true in the command line, depending on whether you want to skip test compilation and execution or only execution. See the example Skipping Tests in the Surefire Plugin's documentation for more details.

[top]


How can I run a single unit test?
Use the parameter -Dtest=MyTest at the command line. NB: do not specify the entire package (org.apache.x.y.MyTest)

[top]


Handle special characters in site

Configure your ide to use the correct encoding. With Eclipse, add -Dfile.encoding=ISO-8859-1 in eclipse.ini file

Configure the reporting output encoding in your pom

<project>
  ...
  <properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  ...
</project>
or if default encoding is overridden in a parent pom that you can't change, configure the site plugin explicitely:
<project>
  ...
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.6</version>
    <configuration>
      <outputEncoding>UTF-8</outputEncoding>
    </configuration>
  </plugin>
  ...
<project>

Configure the file encoding use by mvn. add to MAVEN_OPTS the encoding (same as the ide). This can be made with adding MAVEN_OPTS="-Dfile.encoding=ISO-8859-1" in $HOME/.profile

[top]


How do I include tools.jar in my dependencies?

The following code includes tools.jar for JDKs on Windows, Linux and Solaris (it is already included in the runtime for Mac OS X and some free JDKs).

<project>
...
  <profiles>
    <profile>
      <id>default-tools.jar</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>1.4.2</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
  ...
</project>

[top]


Maven compiles my test classes but doesn't run them?

Tests are run by the surefire plugin. The surefire plugin can be configured to run certain test classes and you may have unintentionally done so by specifying a value to ${test}. Check your settings.xml and pom.xml for a property named "test" which would like this:

<project>
  ...
  <properties>
    <property>
      <name>test</name>
      <value>some-value</value>
     </property>
  </properties>
  ...
</project>

or

<project>
  ...
  <properties>
    <test>some-value</test>
  </properties>
  ...
</project>

[top]


Where are Maven SNAPSHOT artifacts?

If you are trying to build a development version of Maven or plugins, you may need to access the Maven snapshot repositories.

You need to update your settings.xml file using the Guide to Plugin Snapshot Repositories

[top]


Where are the Maven XSD schemas?

The Maven XSD is located here and the Maven Settings XSD is located here.

Your favorite IDE probably supports XSD schema's for pom.xml and settings.xml editing. You need to specify the following:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      https://maven.apache.org/xsd/maven-4.0.0.xsd">

  ...
</project>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
</settings>

[top]


Maven doesn't work, how do I get help?

We have compiled a list of available resources on the getting help page

[top]


How to produce execution debug output or error messages?

You could call Maven with -X parameter or -e parameter. For more information, run:

mvn --help

[top]


What is a Mojo?

A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a Maven plugin is a distribution of one or more related mojos.

[top]


How to find dependencies on public Maven repositories?

You could use the following search engines:

[top]