Intellij does not handle Snapshots dependencies for big Maven projects correctly

Answered

Our Maven project is big (142 Maven poms in one pom as modules) and we never release our Snapshots. So thats not how you should use Maven, but it is actually how we do it. So all 142 jars are Snapshots and on the same version of the Snapshot. Incompatible changes are also introduced, so there is no semantic versioning.

Still our project builds fine.

The trouble comes when I only take out one pom as an Intellij project. In Maven on the command line everything is almost always fine . In Intellij it is fine at the beginning. And if I change with git pull and mvn -U the environment Intellij gets confused and shows lots of compile errors. It took me hours to fix that. Nothing helped no rebuild, no reload, no delete caches. And after lets say 1 hour and getting crazy all of a sudden it works again also in Intellij. (Remember: Maven commandline works)

So I found out that Intellij stores the version of the Snapshot in the dir "libraries" under ".idea". When I update the Snapshots in my local Maven Repo, these files remain unchanged. e.g. It shows a dependency to "xyz201628-12918.jar". This jar was deleted and replaced by a newer Snapshot. But Intellij does not realize that and does not change it.

When I delete the "libraries" dir and then do a "maven reload" in Intellij the "libraries" dir is recreated correctly and fresh and everything compiles

So:
*Are my observations in line with how Intellij works or do I misinterpret sth.?

*Can you fix this, so that the libraries are checked wether the Snapshots still exist in the local Maven repo?

 

 

1
4 comments

Please try Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Always update snapshots option.

0

I do not want to update always. When I work on one item I want a stable environment until I move on to the next. Other colleagues might spoil my environment because the changes in the Snapshots are not compatible with my env.
I want to tell Intellij when to update Snapshots.

So I need to toggle the option?

 

I would prefer a button: Update Snapshots now!

0

When this option is enabled, IDE will always try to download the snapshot dependencies when you Reload a Maven project. There is no a separate option to do this on demand.

To force update dependencies you can also use -U Maven command line option:

mvn -U clean install
0

This means: "Reload" is the button to update the Snapshots inside Intellij when I have the option "always update Snapshots" on? In other words:

This option does not "always" update Snapshots, but only when I press "reload Maven project"?

If this is true the word "always" should be changed to "update snapshots when reloading a Maven project".

Always means in my understanding that Intellij is polling regulary for new Snapshots without control.

I know  mvn -U and this is not the question here.

The question is how to control Snapshots versions in Intellij as a user. With maven its easy. With Intellij not.

 

0

Please sign in to leave a comment.