1

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.

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
Patan
  • 17,073
  • 36
  • 124
  • 198

6 Answers6

4

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,

Community
  • 1
  • 1
Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
2

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.

Sajan Chandran
  • 11,287
  • 3
  • 29
  • 38
  • 2
    But this is the wrong way to do it. The OP should put the dependency into his POM with the required version. Then the POM will build for other people too. You should only install stuff into .m2 by hand if there is a specific reason that you can't use a version from a public maven repo or your group / institution's repo. – Stephen C Jan 31 '13 at 12:31
  • @StephenC I agree that its not the proper way to do it, but i dont think its wrong because the developer dont want to wait till the jar is uploaded to their local maven repo, in this way they can proceed with their development, once the jar is uploaded in the repo then everything falls into place. – Sajan Chandran Jan 31 '13 at 12:34
1

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

TheWhiteRabbit
  • 15,480
  • 4
  • 33
  • 57
1

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

Anugoonj
  • 575
  • 3
  • 9
0
  • 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
0

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.

Alex M
  • 136
  • 7