0

In ivysettings.xml I have the following resolver for the artifact:

<resolvers>
    <url name="shared" m2compatible="true">
      <artifact pattern="${ivy.shared.default.root}/[orgPath]/[module]/[revision]/[module]-[revision]-[conf].[ext]" />
    </url>
  </resolvers>

My ivy.xml file has two configurations and two publications:

 <configurations>
    <conf name="debug"/>
    <conf name="release"/>
  </configurations>

  <publications>
    <artifact name="project-debug" type="zip" conf="debug" ext="zip" />
    <artifact name="project-release" type="zip" conf="release" ext="zip"/>
  </publications>

In the build.xml I use ivy:publish:

<target name="publish" "description="--> publish the project in the ivy repository">
    <property name="revision" value="${project.revision}"/>
    <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]" 
        resolver="shared"
        pubrevision="${revision}"
    />
</target>

The filename of the published artifact is not what I would expect:

project-1.0-default.zip

I would expect two files:

project-1.0-release.zip
project-1.0-debug.zip

Please note that I cannot use the following pattern:

${ivy.shared.default.root}/[orgPath]/[module]/[revision]/[artifact]-[revision].[ext]

That's because the repository I have to use (Archiva) requires the artifact to be of the form [module]-[revision]-... Otherwise we get exceptions like this:

Not a valid artifact path in a Maven 2 repository, filename 'project-debug-1.0.zip' doesn't contain version '1.0'.
Roel
  • 329
  • 1
  • 4
  • 14

1 Answers1

0

Updated answer

Take a second look at your resolver:

<resolvers>
  <url....>
    <artifact pattern="....../[module]-[revision]-[conf].[ext]" />
  </url>
</resolvers>

The two published artefacts would resolve to the same name (because they share the same module and the same publish configuration "default").

Try the following arifact pattern instead:

<artifact pattern="....../[artifact]-[revision].[ext]" />

This should yield the following published files:

project-debug-1.0.zip
project-release-1.0.zip

If you want to add extra optional attributes to the filename consider using extra attributes, for example:

Old answer

How many files does your build produce? The artifactpattern parameter suggests there is only one file?

<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"

That would explain why a single file is published.

For examples of how to publish more than one artefact using ivy:

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • I don't think that's correct. Publish task actually does try to publish two artifacts: [ivy:publish] published project-debug to http://.../project-9.0-default.zip [ivy:publish] published project-release to http://.../project-9.0-default.zip while I would expect: [ivy:publish] published project-debug to http://.../project-9.0-**debug**.zip [ivy:publish] published project-release to http://.../project-9.0-**release**.zip – Roel May 12 '16 at 15:03
  • @RoelVZ Updated answer – Mark O'Connor May 13 '16 at 03:40