Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Freezing transitive dependencies on maven release to get build fully reproducible

A problem that relates to basic maven concepts:

Once released I would like to have a guarantee that the project build is fully reproducible. So all project and plugin dependencies, including transitive one, should be always resolved the same way.

Unfortunately it is not the case, if dependencies are expressed in terms of version ranges. It can happen that even though direct dependencies of a project are set (using versions:use-releases), the transitive dependencies can still be resolved in some other way in the future.

How to address the problem? Is there a known solution?

I was thinking (just an idea), about creating a plugin, which on release time would dump all dependencies of the project to a separate file, and then once building in the future, the dependencies read from the file would take precedence over the standard way maven uses to resolve dependencies. But I'm afraid that there is no plugin api for that. So it would require some hacking, which I would like to avoid. Is there another way?

Thanks, Lukasz

like image 731
Lukasz Guminski Avatar asked Oct 23 '22 19:10

Lukasz Guminski


1 Answers

Freeze artifacts versions using <dependencyManagement>. Even if you don't use version ranges (as you said), but rather 3rd party libs (your dependencies) do, your <dependencyManagement> will have higher priority in specifying version of any artifacts.

like image 120
Michał Kalinowski Avatar answered Oct 31 '22 11:10

Michał Kalinowski