Goal:

I wish to publish the same artifact to multiple Confs using a url based
resolver and the ivy:publish ant task.

Steps Taken:

1- Build an artifact named my.jar

2- Copy it to folders matching the artifacts pattern of the publish task
[conf]/[artifact].[ext]

   -

   pub/confA/my.jar
   -

   pub/confB/my.jar

3- Invoke <ivy:publish> task specifying

   -

   artifactspattern="pub/[conf]/[artifact].[ext]"
   -

   resolver="URL resolver with pattern
   [conf]/[module]/[revision]/[artifact]-[revision].[ext]"
   -

   conf="confA,confB"


Observed Results:

   -

   The <ivy:publish> task attempts to publish using a single conf named “
   default”
   -

   If the artifact is not present in pub/default/my.jar, nothing is
   published
   -

   If the artifact is copied to pub/default/my.jar, the jar is successfully
   published to the “default” [conf] in the url based respository.


Source Code investigation:

The relevant source code for the <ivy:publish> tasks seems reside in the
PublishEngine class’s publish method

public Collection publish(

ModuleDescriptor md,

Collection srcArtifactPattern,

DependencyResolver resolver,

PublishOptions options)

This method contain two relevant loops.

The first loop builds a hashSet of artifacts by iterating over each conf
(confA, confB).  Only the first artifact is added because the equals method
of the AbstractArtifact class considers the second to be identical to the
first - as it does not incorporate“conf” as a differentiator.  This may be
OK since the one added artifact does specify both confs in its
“configurations” member.

The second loop builds a list of files for each artifact by iterating over
each artifact’s srcPattern (i.e., artifact pattern).  In my case there is
one artifact pattern that includes a [conf] token.  I was expecting this to
result in two separate files, one each for confA and confB.  It doesn’t.
Conf is not passed to the parser (IvyPatternHelper) so it defaults to a
conf of “default”.

Ivy does consider the [conf] token in my artifact pattern when searching
for the associated file, but uses “default”.  It also only publishes this
to the default conf in the remote repository.

I am pretty sure I am making incorrect assumptions about expected ivy
behavior.   Any advice on accomplishing the above goal would be appreciated.

Thanks for your help.

Vincent

Reply via email to