tags:

views:

174

answers:

3

I have a remote repository which updates the jar once in 5 hours without changing the version number.Pom file is not able to update as the version is same.Each time I need to manually delete.Is there any way i can get the latest files using the settings.xml.

A: 

Do you control this remote repository? If yes, then use a "-SNAPSHOT" version number.

Or ask the people who do control the repository to do that. It's the correct way to tell Maven that the dependency is in a state of flux.

And if you're unable/unwilling to do that, write yourself a batch/shell script to invoke Maven, which deletes the file beforehand.

kdgregory
A: 

I have a remote repository which updates the jar once in 5 hours without changing the version number. Pom file is not able to update as the version is same. Each time I need to manually delete. Is there any way i can get the latest files using the settings.xml.

No, there is no way to achieve this. Once an artifact with a fixed version (as opposed to SNAPSHOT) has been downloaded, it won't be downloaded again, unless you remove it from your local repository. Actually, re-releasing a jar without changing its fixed version number is an EVIL practice and must be avoided. This is just not how maven works and when doing this, it's impossible to predict which version people are really using (without asking them to explicitly remove the jar from their local repository which is a very weak practice) and this will lead to unpredictable results.

The right way to handle frequent releases is either to change the version number (and updating POMs accordingly) or to use a SNAPSHOT version which is the common approach used during development. By definition, SNAPSHOT version will be downloaded if a newer version is made available in the remote repository. This is what you are looking for and this is the maven way to manage this situation. For more details about SNAPSHOT, see the chapter 9.3.1.2. SNAPSHOT Versions of Maven: The Definitive Guide.

Pascal Thivent
A: 

You can set element updatePolicy to always for a repository in your settings.xml:

<profiles>
  <profile>
    <id>default</id>
    <repositories>
      <repository>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
          <updatePolicy>always</updatePolicy>
        </snapshots>
        <id>snapshots.jboss.org</id>
        <name>Snapshot JBoss Repository for Maven</name>
        <url>http://snapshots.jboss.org/maven2/&lt;/url&gt;
        <layout>default</layout>
      </repository>
    </repositories>
  </profile>
</profiles>
Daniel Murygin