Maven and updating snapshots

Answered

Hello.

Is there a way to tell IDEA to update snapshot jars?

I'm doing it like this:

1. Manually run mvn -U dependency:resolve
2. Re-import maven project in IDEA

The first is tedious, the second is slow.

Is there a better way?

Thanks.

7 comments
Comment actions Permalink

Why don't you use IDEA re-import? It shoult automatically update snapshots depending on your repository's update policy.
Thanks,
Anton Makeev

0
Comment actions Permalink

Because just re-importing doesn't work for me. Jar files appear in local maven repository only after "mvn -U". Could you tell me what is "repository update policy", please? Is it a maven settings.xml setting, or IDEA's?

Also, re-import is still very slow. It would be nice for a stand-alone feature, just to update snapshots, like in Eclipse's maven plugin.

0
Comment actions Permalink

OK, I got your point.

As for repository update policy, it is an option in a repository section of your pom file.
Please see http://maven.apache.org/ref/current/maven-model/maven.html#class_repository.

Anton Makeev.

0
Comment actions Permalink

Any news on this? I do perform an mvn -U from the console regularly and it would be great to have it as an option for clicking/executing the default lifecycle actions.

1
Comment actions Permalink

Hi all, I think that the current " always update snapshot" maven setting is not enough and we need also the possibility to handle the update more flexible like maven do it with the --update-snapshots flag. I will explain why: If I make a change on a pom I would like to do a maven re-import in IDEA but not update my snapshots. Specially if you have trunk based development approach you have a lot of snapshots dependencies. In that case you have to make sure that maven will not overwrite local build snapshots artifacts in the local repository with once from the remote repository. Maven checks for snapshots only the time stamp and for maven newer is always better and will overwrite your local build snapshots if e.g. the CI server has deployed a change from some other developer in the remote repository. To avoid this we change the updated policy of the remote repository to "never". So we can decide exactly when we would like to update our snapshots! That works fine if I only work with maven because I can set the --update-snapshots flag in the case I would like to update my snapshot dependencies. But in IDEA this is tricky because I can only force the update if the update policy is "never" by enable the "always update snapshots" maven setting. It would much better If IDEA would ask for that if I perform an re-import. Maybe a maven import setting "Ask for snapshots update" would be a good solution.

1

Please sign in to leave a comment.