bnd
bnd copied to clipboard
bnd-indexer-maven-plugin does not take into account mirrors when trying to determine artifact URIs
We have the bnd-indexer-maven-plugin set up for https://github.com/apache/sling-org-apache-sling-starter . It all works well when we only use release artifacts that come from Maven Central. However, it fails once we:
- use SNAPSHOT dependencies
- run with Maven configured to have a mirror of the snapshots repository
I'll expand below:
- We have a deployment repository named
apache.snapshots
configured via our parent pom: https://github.com/apache/maven-apache-parent/blob/2c37c34d2c67f7cb3e5eb7a8df0a4779e676b5b0/pom.xml#L111-L118
<repository>
<id>apache.snapshots</id>
<name>Apache Snapshot Repository</name>
<url>https://repository.apache.org/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
- Maven the Jenkins server that we use defines a mirror for this repository
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<!-- auth info here -->
</servers>
<mirrors>
<mirror>
<id>Nexus</id>
<mirrorOf>apache.snapshots</mirrorOf>
<name>Nexus</name>
<url>http://repository.apache.org/snapshots</url>
</mirror>
</mirrors>
</settings>
- The indexer plugin detects deployment repository, but not the mirror
[DEBUG] Located an artifact repository maven-default-http-blocker
[DEBUG] Located an artifact repository central
[DEBUG] Located a deployment repository apache.snapshots.https
- Maven associates the SNAPSHOT artifacts with the 'Nexus' mirror, rather than the 'apache.snapshots' repository
[INFO] Downloading from Nexus: http://repository.apache.org/snapshots/org/apache/sling/org.apache.sling.launchpad.integration-tests/13-SNAPSHOT/maven-metadata.xml
[INFO] Downloaded from Nexus: http://repository.apache.org/snapshots/org/apache/sling/org.apache.sling.launchpad.integration-tests/13-SNAPSHOT/maven-metadata.xml (1.0 kB at 2.1 kB/s)
[INFO] Downloading from Nexus: http://repository.apache.org/snapshots/org/apache/sling/org.apache.sling.launchpad.integration-tests/13-SNAPSHOT/org.apache.sling.launchpad.integration-tests-13-20220504.132057-21.pom
[INFO] Downloaded from Nexus: http://repository.apache.org/snapshots/org/apache/sling/org.apache.sling.launchpad.integration-tests/13-SNAPSHOT/org.apache.sling.launchpad.integration-tests-13-20220504.132057-21.pom (14 kB at 42 kB/s)
- When trying to associate artifacts, the indexer plugin is unable to do so
[ERROR] Failed to determine the artifact URI for artifact org.apache.sling:org.apache.sling.launchpad.test-fragment:jar:13-20220429.031819-11
java.io.FileNotFoundException: Unable to index artifact org.apache.sling:org.apache.sling.launchpad.test-fragment:jar:13-20220429.031819-11. The repository Nexus is not known to this resolver
at aQute.bnd.maven.indexer.plugin.IndexerMojo$RepositoryURLResolver.resolver (IndexerMojo.java:343)
at aQute.bnd.maven.indexer.plugin.IndexerMojo.execute (IndexerMojo.java:177)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
I seem to be able to work around by adding a new repository to the pom.xml with the same id as the mirror, so that the indexer plugin is happy
<repository>
<id>Nexus</id>
<name>Nexus</name>
<url>https://repository.apache.org/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
But that seems like something that the indexer plugin should support out-of-the-box.
@timothyjward Can you provide any assistance here?