The publications section of the ivy-file (module descriptor) of your module
specifies for which configuration you publish the artifact(s) which are
part of your module:

<publications>
  <artifact name="myjar.jar" conf="confA,confB" />
</publications>

Normally the ivy-file is checked-in in your source control system, and
during the build you will create a "resolved" ivy-file. The resolved
ivy-file (also called "delivered" ivy-file)  will then be published
together with your artifact. This delivered ivy-file will also contain the
fixed revision number for that built module.

Related to the location where the artifacts are created and where they will
be published:
the artifactspattern in the settings of your resolver specifies the
location where the artifact will be copied to when published. You don't
have to mimic that pattern in your build directory. It's only relevant that
its location in the build-directory maps to the artifactpattern you specify
in your publish task.

Regards,
Marc


2016-09-30 17:18 GMT+02:00 Vincent Case <vincent.c...@gmail.com>:

> 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