-1

I have some non maven jars in .m2 local repository. Whenever there is a change in the non maven project, I run the build and generate a newer version of jar in the repository. Is it possible to ask maven to get the latest version of jar from the local repository without explicitly mentioning the version of the dependency in pom.xml ? What would be the suggested approach to do this ?

A_J
  • 977
  • 4
  • 16
  • 44
  • 1
    possible duplicate of https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency/1172805#1172805 – nitnamby Apr 24 '18 at 14:50
  • Usually this is a JOB for SNAPSHOT versions...and why is a new jar generated with each build? Do you do `mvn clean install`? From where is it generated by another maven build? – khmarbaise Apr 24 '18 at 16:55
  • The non Maven projects are updated frequently. So to be on the safe side I build those projects everytime so that I don't miss an update – A_J Apr 26 '18 at 06:54
  • @ nitnamby Thanks for the link and sorry for not searching properly on SO. This finally solved my issue http://www.mojohaus.org/versions-maven-plugin/examples/advancing-dependency-versions.html – A_J Apr 26 '18 at 10:04

1 Answers1

1

How do the files get to the repository? If you install the files with maven install and use a SNAPSHOT version the maven build will generally use the newest version. If you are using a different manual versioning like 1.2.3, 1.2.4 and so on you can use an open interval in the pom like

<dependency>
    <groupId>yourGroup</group>
    <artifactId>yourArtifact</artifactId>
    <version>[1.2.3,)</version>
</dependency>

There is also a lot of documentation on this topic i.e. How do I tell Maven to use the latest version of a dependency?

DrHopfen
  • 752
  • 3
  • 13