3

Our Ivy repo is set up as described here: http://ant.apache.org/ivy/history/latest-milestone/terminology.html

I'm attempting to access it from maven. The paths map to the module no problem. We have a module foo, and then foo creates artifacts foo-api.2.1.0.jar and foo.2.1.0.jar (the implementation). Its the foo-api.2.1.0.jar that is the problem.

I've tried the maven classifier, but then it wants to find foo.2.1.0-api.jar, not foo-api.2.1.0.jar.

The diagram in the link implies that an ivy.xml or pom.xml could create the example layout they have for mymod-api, mymod-impl. How does one do that with a pom?

Update:

A suggestion was to make the maven artifacts be mymod-api and mymod-impl, but this then has maven query the repo for:

  /com/mycorp/foo-api/2.1.0.0/foo-api.jar
  /com/mycorp/foo/2.1.0.0/foo.jar

Whereas Ivy puts them:

  /com/mycorp/foo/2.1.0.0/foo-api.jar
  /com/mycorp/foo/2.1.0.0/foo.jar

Consequently, just using maven artifacts renders them undiscoverable.

Update 2:

We are using the Nexus repo manager.

jamie
  • 2,963
  • 1
  • 26
  • 27
  • It would be simpler to use a Maven repository manager like Nexus to manage artifacts for you. It's very lightweight, only uses filesystem (no DB) and more importantly is standards compliant. I use it all the time for both Maven and Ivy projects – Mark O'Connor Dec 04 '12 at 19:41
  • We are using Nexus. How are you mapping Ivy artifacts to Maven artifacts? What is your resolver config for Ivy? – jamie Dec 04 '12 at 19:50

2 Answers2

1

You don't want the classifier, that'll do what you said. What you need is that the artifact id to be "foo-api" for that artifact. It's not a problem, it's working as intended.

Michael
  • 6,141
  • 2
  • 20
  • 21
1

If you are using Nexus, as your repository manager, then check out this answer on how to configure your ivy build:

Use public maven repository with ivy

Update1

Publishing files to Nexus from ivy is described here:

how to publish 3rdparty artifacts with ivy and nexus

Apologies in advance, it's very comprehensive and will also explain the significance of classifiers in Maven.

Update2

When publishing to Nexus:

<ivy:publish resolver="deploy"...>
    <artifacts pattern="${build.dr}/[artifact](-[classifier]).[ext]"/>
</ivy:publish>

make sure you're using an ibilio resolver:

<ivysettings>
    <settings defaultResolver="central"/>
    <credentials host="somehost" realm="Sonatype Nexus Repository Manager" username="????" passwd="????"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
        <ibiblio name="deploy" root="http://somehost/nexus/content/repositories/repo" m2compatible="true"/>
    </resolvers>
</ivysettings>

The "gotcha" is m2compatible="true". For historical reasons the resolver supports the much older Maven 1 respository format (Ibilio is the old name for Maven Central).

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • 1
    I've got a Nexus repo full of Ivy builds that I need to access via Maven. That post is about a Nexus repo full of Maven builds that they need to access through Ivy. – jamie Dec 04 '12 at 20:19
  • @jamie Ok, now you're really confusing me... Nexus is a Maven repository manager, by definition that means it's designed to support Maven clients.... How are you publishing content to the repository? I've updated my answer – Mark O'Connor Dec 04 '12 at 20:51
  • We're using is as an Ivy repo. We're publishing to it using in our ant files. Nexus doesn't really care where you put things, it just wants a path. And ivy doesn't care where you put things, it just wants an artifact pattern. Maven, however, unless someone can tell me otherwise, demands artifacts be on a specific path. I'm beginning to think that the only solution is to move our files around in Nexus, and modify our ivy resolvers to match maven. – jamie Dec 04 '12 at 21:34
  • @jamie Ahhh, now I understand. Apologies I thought Nexus would do some checking on the format of the posted artifact... Clearly not :-( If you read the detail of my other answer you'll notice that I'm using the ibilio resolver when publishing artifacts. This ensures the publish task is Maven compliant. – Mark O'Connor Dec 04 '12 at 22:26
  • @jamie And yes, the Maven client is very picky and offers no flexibility in respository layout.... That is both good and bad... Using the ibilio resolver is ivy's way of emulating that inflexibility :-) – Mark O'Connor Dec 04 '12 at 22:36
  • So your solution looks like it would almost work for us except for classifiers. We don't use them. Our (great many) ivy.xml files use separate artifacts for things that (in maven) I would solve using classifiers. There's also the problem that I wouldn't handle an "api" as a classification in maven, but as a separate artifact. Our Ivy files specify XYZ-api as an artifact. In maven I'd specify XYZ-api to be an artifact of the XYZ group. There's no nice way to map them. – jamie Dec 04 '12 at 23:50
  • @jamie The "classifier" attribute in my publish example is wrapped in brackets which means it's optional. I normally use this to upload javadoc and source artifacts which are the normal classifier artifacts in a Maven module. – Mark O'Connor Dec 05 '12 at 22:53