Blog

  • 2024
  • 2023
  • 2022
  • 2021
  • 2020
  • 2019
  • 2018
  • 2017
  • 2016
  • 2015
  • 2014
  • 2013
  • 2012




If you happen to encounter a broken relocation in your local Maven repository, the module generation process with JBoss Modules Maven Plugin will produce an unexpected result with two generated modules instead of one.

For this example we assume that the project references the relocated commons-io in Version 1.3.2. This artifact is broken in the local repository as shown below.

Broken relocated Artifact

The relocated but broken artifact in org/apache/commons/commons-io/1.3.2 looks like this:

commons-io-1.3.2-javadoc-resources.jar.lastUpdated
commons-io-1.3.2-javadoc.jar
commons-io-1.3.2-javadoc.jar.sha1
commons-io-1.3.2-sources.jar
commons-io-1.3.2-sources.jar.sha1
commons-io-1.3.2-test-javadoc-resources.jar.lastUpdated
commons-io-1.3.2.jar
commons-io-1.3.2.jar.sha1
commons-io-1.3.2.pom
commons-io-1.3.2.pom.sha1

The contents of the POM shows the following:

<project>
  ...
  <groupId>commons-io</groupId>
  <artifactId>commons-io</artifactId>
  <version>1.3.2</version>
  ...
</project>

Why is it broken? The groupId does not match the location within the repository. It is a fault that the folder contains artifacts instead of the relocation POM.

 

The reason for the broken relocation folder remains unclear. It seems that a yet unknown process simply replaces the relocated folder with the contents of the new location.

Correct relocated Artifact

This is the correct contents of org/apache/commons/commons-io/1.3.2 as a relocated artifact:

commons-io-1.3.2.pom
commons-io-1.3.2.pom.sha1
_maven.repositories

This is the correct POM of the relocated artifact:

<project>
 <modelVersion>4.0.0</modelVersion>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-io</artifactId>
 <version>1.3.2</version>
 <distributionManagement>
   <relocation>
     <groupId>commons-io</groupId>
     <artifactId>commons-io</artifactId>
     <message>https://issues.sonatype.org/browse/MVNCENTRAL-244</message>
   </relocation>
 </distributionManagement>
</project>

The unexpected Result

The unexpected result created from the broken relocation is that the created modules folder contains two modules for commons-io. This is because the resolvement of the broken relocated project results in two artifacts instead of one.

These are the modules for the artifact:

  • org.apache.commons.commons-io
  • org.apache.commons.io

Solving the Issue

To solve this issue, remove the broken artifact from the local repository. The next build will restore the correct form. The resolved artifact will create only one module, as expected.

So if you encounter a seemingly unaccountable duplication of modules, please check if it is caused by a relocated relocated artifact, whose folder in the local repository is broken.


Link

Link

Posts