Questions tagged [maven]

Apache Maven is a build automation and project management tool used primarily for Java projects. This tag is for questions that don't relate to a specific Maven version. Use the gradle tag instead for questions relating to Gradle.

Apache Maven is a build automation tool used primarily for Java projects. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information.

Maven's objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. Maven adheres to the principle of "convention over configuration" that helps building Maven projects with very little configuration. Systems, libraries, and frameworks should assume reasonable defaults, and systems should "just work" without requiring unnecessary configuration. In order to attain this goal, there are several areas of concern that Maven attempts to deal with:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features

The configuration of a Maven project is done by creating a file called pom.xml located at the root of the project. This file is referred to as the POM file. Each POM file inherits from a global Super POM that defined common properties for all Maven projects.

If you see questions with this tag that specifically refer to the Maven versions 2.x, 3.x (or the legacy 1.x), please re-tag them with , and , respectively.

If you see questions related to a specific Maven plugin, please also check whether the related plugin tag is present (i.e. , ).

Questions related to Maven plugin development should also have the , while questions related to Maven profiles should also have the tag, and questions related to Maven archetypes should also have the tag.

More information

Free Maven Books

Frequently Asked Questions:

People often ask about the following topics:

General:

Maven Repository:

87627 questions
163
votes
13 answers

How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?

I've searched up and down the internet for this one. There's lots of half-answers out there, to do with Maven properties such as ${sonar.jacoco.reportPath}, or org.jacoco:jacoco-maven-plugin:prepare-agent or setting maven-surefire-plugin argLine…
Stewart
  • 17,616
  • 8
  • 52
  • 80
161
votes
3 answers

What is the difference between Nexus and Maven?

What is the difference between Nexus and Maven? What is a basic scenario of usage only Maven? What about a scenario considering only Nexus? And how it looks when I want to use both?
ruhungry
  • 4,506
  • 20
  • 54
  • 98
160
votes
11 answers

Is there anyway to exclude artifacts inherited from a parent POM?

Artifacts from dependencies can be excluded by declaring an element inside a But in this case it's needed to exclude an artifact inherited from a parent project. An excerpt of the POM under discussion follows:
Miguel
  • 1,999
  • 2
  • 14
  • 14
160
votes
25 answers

Lombok is not generating getter and setter

I just tried to send a Maven-based project to another computer and HORROR, red markers everywhere!! However, mvn clean install is building just fine. Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the…
Heetola
  • 5,791
  • 7
  • 30
  • 45
159
votes
4 answers

Sample settings.xml

How to configure settings.xml in Maven? Also, please share a sample settings.xml!
brindha
  • 1,607
  • 2
  • 11
  • 3
158
votes
15 answers

Maven: The packaging for this project did not assign a file to the build artifact

I'm using Maven 3.0.3 on Mac 10.6.6. I have a JAR project and when I run the command "mvn clean install:install", I'm getting the error, [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-cli) on…
Dave
  • 8,667
  • 25
  • 72
  • 90
156
votes
8 answers

maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e

I have a fairly simple Maven project: ... org.apache.maven.plugins
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
156
votes
19 answers

Surefire is not picking up Junit 5 tests

I wrote a simple test method with JUnit 5: public class SimlpeTest { @Test @DisplayName("Some description") void methodName() { // Testing logic for subject under test } } But when I run mvn test, I…
Ali Dehghani
  • 46,221
  • 15
  • 164
  • 151
156
votes
18 answers

Compiling Java 7 code via Maven

My pom file lists org.apache.maven.plugins maven-compiler-plugin
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
155
votes
14 answers

Java version automatically change to java 1.5 after maven update

I am using eclipse as IDE. When I right click on the project and then click maven update my java version change to 1.5. Here is what I did so far, I followed all the steps listed here…
asdlfkjlkj
  • 2,258
  • 6
  • 20
  • 28
154
votes
7 answers

Downloading all maven dependencies to a directory NOT in repository?

I started to convert my project to maven because I needed to use a library that was distributed in binary form over maven only, but after banging my head against the wall on it for far too long I've decided to stop hurting myself and just use Ant. …
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
154
votes
7 answers

Where is the list of predefined Maven properties

I know there is a list of all predefined Maven properties (you know like project.build.sourceEncoding, or project.build.sourceDirectory). I once saw the list but I just can't find it again.
Martin
  • 11,577
  • 16
  • 80
  • 110
154
votes
22 answers

web.xml is missing and is set to true

Consider: When I create a simple Maven project in Eclipse I am getting this error: web.xml is missing and is set to true How can I fix this problem?
Yogesh Doke
  • 1,706
  • 2
  • 12
  • 20
154
votes
7 answers

Building a fat jar using maven

I have a code base which I want to distribute as jar. It also have dependency on external jars, which I want to bundle in the final jar. I heard that this can be done using maven-assembly-plug-in, but I don't understand how. Could someone point me…
bianca
  • 7,004
  • 12
  • 43
  • 58
154
votes
3 answers

What is the difference between "pom" type dependency with scope "import" and without "import"?

Starting from Maven 2.0.9 there is possibility to include pom import in the section. As I understand it, it will be "replaced" with dependencies included in this pom as if they were originally…
grafthez
  • 3,921
  • 4
  • 28
  • 42