How do I tell maven to update local metadata?

I am trying to figure out how to get maven to update the local maven-metadata-local.xml file by checking which versions of the artifact are available in our maven repository and update the tag release

in the local metadata file to the latest version.

My team and I are working on a large code base made up of several code modules. These modules have dependencies on each other.

For example, the ER_catalog module depends on ER_CORE_api, so in the ER_catalog pom.xml we declare a dependency on ER_CORE_api and use the RELEASE version.

Maven then looks at the local metadata to see what the latest version of ER_CORE_api is and uses that to compile the code in ER_catalog.

My local version of this metadata file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.company.er</groupId>
<artifactId>ER_CORE_api</artifactId>
<versioning>
<release>0.562.0</release>
<versions>
  <version>0.561.0</version>
  <version>0.562.0-SNAPSHOT</version>
  <version>0.562.0</version>
  <version>0.563.0-SNAPSHOT</version>
  <version>0.564.0-SNAPSHOT</version>
 </versions>
  <lastUpdated>20150513150410</lastUpdated>
 </versioning>
</metadata>

      

However, a colleague of mine recently downloaded version 0.563.0 (using the maven release plugin). So, in the repository where the artifact lives, the metadata looks like this:

<metadata>
<groupId>com.company.er</groupId>      
<artifactId>ER_CORE_api</artifactId>
<versioning>
<latest>0.563.0</latest>
<release>0.563.0</release>
<versions><version>0.561.0</version>
<version>0.562.0</version><version>0.563.0</version>
</versions>
<lastUpdated>20150513122648</lastUpdated>
</versioning>
</metadata>

      

My code won't compile because it requests a local maven rep for the latest ER_CORE_api and gets 0.562.0 instead of 0.563.0. How can I cause this metadata to be updated (not before deleting the file)?

NB I know someone will say that we should use version specific tags and not RELEASE. This is why we use RELEASE:

We can have 5 modules that depend on ER_CORE_api. If each of them has a hard-coded version for ER_CORE_api, then when we update ER_CORE_api to a new version, each of these modules must be updated - and then everyone must have a new version created too (since they were changed). This means that each change will cause a cascade of changes in the dependency tree, which is a lot. Also, there is no easy way to find out which modules depend on the module I changed.

When we freeze a release of an application, we put specific versions in the pom.xml files for all modules.

+3


source to share





All Articles