Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to configure maven to add junit 4.10 instead of 3.8 dependency in new project

When i am creating a new maven project in eclipse kepler, eclipse automatically adds junit 3.8 dependency in pom.xml like

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8</version>
    <scope>test</scope>
</dependency>

I want to be available newer version like: 4.10,

Where can i configure to use newer version instead of old?

like image 491
Abhishek Nayak Avatar asked Feb 14 '14 10:02

Abhishek Nayak


3 Answers

The junit version is described in archetype that is used to create maven project.

You need to either find archetype that will fit your needs, or create your own.

Then once you have it you need to select to use this archetype when creating the project in Eclipse.

like image 157
František Hartman Avatar answered Oct 11 '22 19:10

František Hartman


It's pretty common to have a company/product wide version of one of the following: -

  • A common parent pom with a dependency management section controlling all your versions
  • A common pom which is included as a dependency and imports all the testing dependencies, e.g., my-company-test. That can either include your common test code as well or be of type pom and just act as a dependency vacuum.
  • An archetype (as frant.hartm says) which defines all of your common dependency versions up front.

I would personally go with both the dependency based pom and an archetype which imports it.

You can always override versions if you need too.

like image 38
James Avatar answered Oct 11 '22 19:10

James


You have to state the version that you want in the dependency, for example I use JUnit 4.11 in Eclipse Juno:

<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
</dependency>

So you need to set your version to 4.10 or whatever version there is that you desire.

like image 21
Omoro Avatar answered Oct 11 '22 18:10

Omoro