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
2598
votes
31 answers

How can I create an executable JAR with dependencies using Maven?

I want to package my project in a single executable JAR for distribution. How can I make a Maven project package all dependency JARs into my output JAR?
soemirno
  • 26,526
  • 3
  • 17
  • 14
827
votes
12 answers

How do I tell Maven to use the latest version of a dependency?

In Maven, dependencies are usually set up like this: wonderful-inc dream-library 1.2.3 Now, if you are working with libraries that have frequent…
Anders Sandvig
  • 19,763
  • 16
  • 56
  • 71
714
votes
24 answers

Can I add jars to Maven 2 build classpath without installing them?

Maven 2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development. I have a pom.xml file that defines the dependencies for the web-app framework I want to use, and I can quickly generate starter projects from that…
purple
575
votes
13 answers

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.
BillMan
  • 8,105
  • 9
  • 29
  • 51
436
votes
6 answers

Maven Modules + Building a Single Specific Module

I have a multi-module Maven project with a parent project P and three sub-modules A, B, and C. Both B and C are war projects and both depend on A. I can type mvn compile in P and have all of the sub-modules properly compiled. The problem comes…
Brian Ferris
  • 6,222
  • 5
  • 23
  • 27
425
votes
6 answers

How to configure encoding in Maven?

When I run maven install on my multi module maven project I always get the following output: [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! So, I googled around a bit, but all I can find…
Ethan Leroy
  • 13,244
  • 5
  • 32
  • 59
388
votes
15 answers

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into the jar as well. Update: I know that I cant just…
racer
  • 3,967
  • 3
  • 16
  • 13
316
votes
5 answers

Maven artifact and groupId naming

I'm currently in the process of moving some project from Ant to Maven. Conformist as I am, I want to use well-established conventions for finding groupId and artifactId, but I can't find any detailed conventions (there are some, but they don't cover…
Noarth
  • 3,631
  • 6
  • 19
  • 16
310
votes
7 answers

Maven command to determine which settings.xml file Maven is using

How do I use maven command line to determine which settings.xml file Maven is picking up?
harschware
  • 11,609
  • 17
  • 50
  • 81
301
votes
21 answers

Find Oracle JDBC driver in Maven repository

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is: com.oracle ojdbc14
rperez
  • 8,100
  • 10
  • 33
  • 44
300
votes
5 answers

Is there a simple way to remove unused dependencies from a maven pom.xml?

I have a large Maven project with many modules and many pom.xml files. The project has changed and I suspect the pom's contain some unnecessary dependencies. Is there is a command which removes any unused dependencies from a pom?
thickosticko
290
votes
5 answers

Maven: Command to update repository after adding dependency to POM

I've added a new dependency to my POM. Is there a simple command I can run to download this dependency to my repository?
DJ180
  • 15,554
  • 19
  • 59
  • 105
287
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
  • 8,494
  • 6
  • 38
  • 45
284
votes
12 answers

Retrieve version from maven pom.xml in code

What is the simplest way to retrieve version number from maven's pom.xml in code, i.e., programatically?
mikhail
  • 3,905
  • 7
  • 21
  • 30
281
votes
2 answers

run main class of Maven project

I've created a simple console Java application that is built with Maven. Is there a way that the main class (which doesn't require any arguments) can be run from the command-line using a maven command like: mvn run-app com.example.MainClass
Dónal
  • 176,670
  • 166
  • 541
  • 787
1
2 3
99 100