Questions tagged [maven-2]

Apache Maven is a software project management and comprehension tool. This is a tag for Maven related questions that are specific to Maven versions 2.x.

About Maven:

Apache Maven is a software project management and comprehension tool. 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.

For questions that are not version-specific, use , for Maven 3.x - specific questions, use

Please be aware of Maven 2 End Of Life

Maven Releases History, with documentation

5702 questions
295
votes
4 answers

Maven parent pom vs modules pom

There seem to be several ways to structure parent poms in a multiproject build and I wondering if anyone had any thoughts on what the advantages / drawbacks are in each way. The simplest method of having a parent pom would be putting it in the root…
Jamie McCrindle
  • 9,114
  • 6
  • 43
  • 48
292
votes
16 answers

Make Maven to copy dependencies into target/lib

How do I get my project's runtime dependencies copied into the target/lib folder? As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the runtime dependencies.
Michael
  • 3,049
  • 3
  • 19
  • 5
276
votes
33 answers

How to get Maven project version to the bash command line

Previous I issued a question on how to change Maven project vesion from command line which lead me to a new issue. Previously I was able to get the version number since the version was stored as a property that was easy to grep and parse from the…
mkko
  • 4,262
  • 3
  • 25
  • 29
275
votes
9 answers

How to get a dependency tree for an artifact?

dependency:tree can be used to see the dependency tree for a given project. But what I need is to see the dependency tree for a 3rd party artifact. I guess I can create an empty project, but I'm looking for something easier (I need to do this for…
IttayD
  • 28,271
  • 28
  • 124
  • 178
271
votes
7 answers

Build Maven Project Without Running Unit Tests

How do you build a Maven project without running unit tests? Currently restructuring some code I have for a Servlet and would like to try it out in my web browser (which means running mvn install to get the .war to upload to Tomcat). I'm fully aware…
Federer
  • 33,677
  • 39
  • 93
  • 121
270
votes
10 answers

Maven: add a dependency to a jar by relative path

I have a proprietary jar that I want to add to my pom as a dependency. But I don't want to add it to a repository. The reason is that I want my usual maven commands such as mvn compile, etc, to work out of the box. (Without demanding from the…
flybywire
  • 261,858
  • 191
  • 397
  • 503
262
votes
12 answers

Exclude all transitive dependencies of a single dependency

In Maven2, to exclude a single transitive dependency, I have to do something like this: sample.group sample-artifactB 1
pbreault
  • 14,176
  • 18
  • 45
  • 38
260
votes
9 answers

Convert Existing Eclipse Project to Maven Project

For a project at work, we're considering using the Maven plugin for Eclipse to automate our builds. Right now the procedure is far more complicated than it ought to be, and we're hoping that Maven will simplify things to a one-click build. My…
Thorn G
  • 12,620
  • 2
  • 44
  • 56
236
votes
11 answers

Maven dependency for Servlet 3.0 API?

How can I tell Maven 2 to load the Servlet 3.0 API? I tried: javax.servlet servlet-api 3.0 provided I use…
deamon
  • 89,107
  • 111
  • 320
  • 448
235
votes
14 answers

How can I download a specific Maven artifact in one command line?

I can install an artifact by install:install-file, but how can I download an artifact? For example: mvn download:download-file -DgroupId=.. -DartifactId=.. -Dversion=LATEST
Lenik
  • 13,946
  • 17
  • 75
  • 103
233
votes
10 answers

Controlling Maven final name of jar artifact

I'm trying to define a property in our super pom which will be used by all child projects as the destination of the generated artifact. For this I was thinking about using project/build/finalName yet this does not seem work, even for simple…
Maxim Veksler
  • 29,272
  • 38
  • 131
  • 151
216
votes
10 answers

Maven compile with multiple src directories

Is there a way to compile multiple java source directories in a single maven project?
sal
  • 23,373
  • 15
  • 66
  • 85
215
votes
13 answers

What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?

I imported a Maven project and it used Java 1.5 even though I have 1.6 configured as my Eclipse default Preferences->Java->Installed JREs. When I changed the Maven project to use the 1.6 JRE it still had the build errors left over from when the…
Chris Collins
  • 3,440
  • 5
  • 27
  • 24
212
votes
14 answers

Best practices for copying files with Maven

I have config files and various documents that I want to copy from the dev environment to the dev-server directory using Maven2. Strangely, Maven does not seem strong at this task. Some of the options: Simple use a copy task in Maven
Joshua Fox
  • 18,704
  • 23
  • 87
  • 147
208
votes
4 answers

Maven: how to do parallel builds?

When you build with maven on a multicore / multi-CPU machine it would often be possible to build different subprojects in parallel. Is there a way to do this with maven? Is there a plugin for this / whatever?
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139