Search code examples
mavenartifactorybndbndtools

Maven Bnd Repository Plugin fails to fetch artifact from remote artifactory


I'm trying to get bnd tools structure working (started with tutorial https://bndtools.org/tutorial.html)

Added use of javax.vecmath (as simple library as I could think of) in cnf/central.maven file

javax.vecmath:vecmath:1.5.2

and added it to build path in org.example.impl with everything resolving just fine.

I have fork of this library in jFrog artifactory running on remote server, so next step was defining that repository in cnf/build.bnd adding (as described in https://bnd.bndtools.org/plugins/maven.html)

-plugin.10.Remote = \
    aQute.bnd.repository.maven.provider.MavenBndRepository; \
        releaseUrl=https://artifactory.website.com/artifactory/libs-release-local/; \
        snapshotUrl=https://artifactory.website.com/artifactory/libs-snapshot-local/; \
        index=${.}/release.maven; \
        name="Maven Remote"

and appropriate reference in cnf/release.maven

javax.vecmath:vecmath:2.1.5

When adding this library to build path I get error "2.1.5 [Could not fetch javax.vecmath:vecmath:2.1.5]" with no further information.

I figured the only difference between maven central and my artifactory should be content of .m2/settings.xml with credentials (according to https://bnd.bndtools.org/instructions/connection-settings plugin should look there in the first place).

Configuration that works for maven in eclipse (when I open a maven project that has vecmath 2.1.5 as dependency it gets pulled without a problem to .m2/repository/javax/vecmath/vecmath/2.1.5 and once there it gets resolved just fine by bnd)

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>username</username>
      <password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
      <id>central</id>
    </server>
    <server>
      <username>username</username>
      <password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>https://artifactory.website.com/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>https://artifactory.website.com/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>https://artifactory.website.com/artifactory/libs-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>https://artifactory.website.com/artifactory/libs-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

From this it seems bnd has no problem fetching from maven central to local m2 repository and using it from there, but fails to connect to my artifactory. Is there some key setting or difference I'm missing?


Solution

  • Ended up solving the issue with help from https://groups.google.com/forum/#!forum/bndtools-users having found two (three?) problems with my configuration.

    The correct form for repository definition in build.bnd seems to be

    -plugin.10.Remote: \
        aQute.bnd.repository.maven.provider.MavenBndRepository; \
            releaseUrl=https://artifactory.website.com/artifactory/libs-release-local/; \
            snapshotUrl=https://artifactory.website.com/artifactory/libs-snapshot-local/; \
            index=${.}/release.maven; \
            name="Maven Remote"
    

    Looking in https://bnd.bndtools.org/instructions/connection-settings server auth configuration for bnd differs from maven configuration (0.3.4, for some reason I missed that part)

    <server>
      <username>username</username>
      <password>roigonsdnglosgnoisfgnsdjgnlafjksasgnl</password>
      <id>https://*website.com</id>
    </server>
    

    and bnd is looking for connection settings first in .bnd, if there are none, then in .m2, but if there are incorrect/insufficient settings in .bnd it does not look in .m2 even if it contains correct/sufficient ones.

    The default order in which bnd looks for settings is:
    `~/.bnd/connection-settings.xml`
    `~/.m2/settings.xml`