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

5648 questions
266
votes
15 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
  • 2,789
  • 3
  • 17
  • 5
266
votes
5 answers

Making Maven run all tests, even when some fail

I have a project with several modules. When all tests pass, Maven test runs them all. When tests fail in the first module, maven will not continue to the next project. I have testFailureIgnore set to true in Surefire settings, but it doesn't…
ripper234
  • 202,011
  • 255
  • 600
  • 878
263
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
  • 30,291
  • 37
  • 89
  • 120
252
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…
Tom G
  • 11,950
  • 2
  • 38
  • 54
240
votes
9 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
  • 232,954
  • 184
  • 384
  • 491
233
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
  • 13,426
  • 18
  • 41
  • 38
232
votes
16 answers

SLF4J: Class path contains multiple SLF4J bindings

I'm getting the following error. It seems there are multiple logging frameworks bound to slf4j. Not sure how to resolve this. Any help is greatly appreciated. SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in…
user1493140
  • 5,056
  • 4
  • 26
  • 48
230
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
  • 78,414
  • 98
  • 279
  • 415
219
votes
31 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
  • 3,682
  • 3
  • 23
  • 28
213
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,420
  • 5
  • 25
  • 24
198
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
  • 15,727
  • 14
  • 65
  • 108
198
votes
9 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
  • 25,736
  • 34
  • 119
  • 148
197
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
  • 22,528
  • 15
  • 64
  • 84
190
votes
4 answers

Sharing Test code in Maven

How can you depend on test code from another module in Maven? Example, I have 2 modules: Base Main I would like a test case in Main to extend a base test class in Base. Is this possible? Update: Found an acceptable answer, which involves…
flicken
  • 14,624
  • 4
  • 27
  • 27
186
votes
8 answers

Importing Maven project into Eclipse

I want to import existing Maven project into Eclipse. I found 2 ways to do it: Through running from command line mvn eclipse:eclipse To install Maven Eclipse plugin from Eclipse. What is the difference between the both and which one is preferable?…
Thunderhashy
  • 5,191
  • 13
  • 39
  • 46