Jofkos
Jofkos

Reputation: 759

IntelliJ/Maven not updating artifacts from Artifactory

I recently set up a password protected Artifactory server. A Jenkins server is deploying my artifacts to a maven repository on that Artifactory server.

Here is the problem:
The new builds are nor available at runtime (in IntelliJ) neither in Maven (when building). To get maven to update, I've to delete the artifacts from my local repo.

How can I tell Maven/IntelliJ to always check for the newest version?
Even that wasn't doing anything:

<releases>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
</releases>
<snapshots>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
</snapshots>

Upvotes: 3

Views: 8224

Answers (1)

JBaruch
JBaruch

Reputation: 22893

There are the cases to deal with:

  1. Releases. Not Maven nor Artifactory will never check for a newer binary if a release binary of the same version exists in the local cache (~/.m2/repository cache for Maven or remote repository cache for Artifactory). The only way to force Artifactory and Maven to re-fetch a release artifact is to delete it from the cache. Do not use the same version for different blob, ever.
  2. Snapshots. Although there is a difference between unique (file names end with timestamps) and non-unique (file names end with -SNAPSHOT and thus they violate the rule I just wrote, so don't use them), their retrieval policy is the same: Maven consider them expirable resources, it will occasionally check for a new blob, posted under the same version. Artifactory does the same: occasionally the expirable resource is declared "expired", so next time Maven asks for this resource, Artifactory will fetch to the remote repository to check for a new blob, posted under the same version. In both tools you can control the cache period and "zap the cache" manually.
    • In Maven <update-policy/> controls how often Maven checks for new snpashots, and the --update-snapshots flag forces Maven to check immediately.
    • In Artifactory the Retrieval Cache Period parameter in remote repository configuration controls how often Artifactory checks for new snapshots, and the Zap Caches action on the remote repository in the artifact browser screen makes sure that Artifactory will check for new snapshots on the next request.

Upvotes: 4

Related Questions