Patan
Patan

Reputation: 17883

how to replace a Jar in .m2 repository

I want to replace a Jar in my .m2 repository. I have older version of Jar in my repository. I want to update it to newer one.

Currently I have jtidy-4aug2000r7-dev.jar at C:\.m2\repository\jtidy\jtidy\4aug2000r7-dev.

I want to update it to jtidy-r938. I have this jar at my local folder.

Can some one tell me how to do it.

Upvotes: 1

Views: 6705

Answers (6)

Anugoonj
Anugoonj

Reputation: 575

update the version in the dependency tag in the pom.xml. It will automatically download the new version from the central maven repo.

Upvotes: 1

Anders R. Bystrup
Anders R. Bystrup

Reputation: 16060

Since it's on central, the easiest way is to declare it as a dependency to your project and run mvn dependency:get.

<dependency>
    <groupId>net.sf.jtidy</groupId>
    <artifactId>jtidy</artifactId>
    <version>r938</version>
</dependency>

This will put the r398 version in (another) subdirectory beside the 4aug2000r7-dev version.

To manually install an artifact refer to this answer.

Cheers,

Upvotes: 4

Sajan Chandran
Sajan Chandran

Reputation: 11487

If you have the updated jar locally, you use the following command

mvn install:install-file  -Dfile=path-to-your-artifact-jar \
                          -DgroupId=your.groupId \
                          -DartifactId=your-artifactId \
                          -Dversion=version \
                          -Dpackaging=jar \
                          -DlocalRepositoryPath=path-to-specific-local-repo

which install your updated jar file locally.

Upvotes: 2

TheWhiteRabbit
TheWhiteRabbit

Reputation: 15758

update your pom.xml

purticularly the one similar to this

<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>**4.0**</version>
      <type>jar</type>
      <scope>test</scope>
      <optional>true</optional>
    </dependency>

update Version as per your need

Upvotes: 1

Alex M
Alex M

Reputation: 136

Delete it, update the version-number in your pom.xml and update your dependencies. If the version is not available in the maven repository, build your own artifact with the specified version use it for your purpose.

Upvotes: 0

user425367
user425367

Reputation:

  • Update your dependancies in the POM file
  • Delete the folder
  • Run a maven command that depends on the Jar and it will automatically fetch it

Upvotes: 0

Related Questions