2

I'm coming from a Maven background. The project I am working on is not Java based. However, it is a requirement to use standalone Ivy for the dependency management. The repository manager is Nexus.

The project produces several zip artifacts and needs to deploy them to Nexus via standalone Ivy. I would like an analogue of Maven classifiers, but for Ivy.

This is my ivysettings.xml:

<ivysettings>
    <settings defaultResolver="nexus"/>
        <credentials host="localhost"
                     realm="Sonatype Nexus Repository Manager"
                     username="user"
                     passwd="pass"/>

    <property name="nexus-public"
              value="http://localhost:8081/nexus/content/groups/public"/>
    <property name="nexus-releases"
              value="http://localhost:8081/nexus/content/repositories/releases"/>
    <property name="nexus-snapshots"
              value="http://localhost:8081/nexus/content/repositories/snapshots"/>

    <resolvers>
        <ibiblio name="nexus"
                 m2compatible="true"
                 root="${nexus-public}"/>
        <ibiblio name="nexus-releases"
                 m2compatible="true"
                 root="${nexus-releases}"/>
        <ibiblio name="nexus-snapshots"
                 m2compatible="true"
                 root="${nexus-snapshots}"
                 checkmodified="true"
                 changingPattern="*-SNAPSHOT"/>
    </resolvers>
</ivysettings>

I have the following ivy.xml:

<ivy-module version="2.0">
    <info organisation="kung.fu" module="ninja" revision="1.2.3"/>

    <publications>
        <artifact name="ninja" type="zip" ext="zip"/>
        <artifact name="ninja" type="win32" ext="zip"/>
        <artifact name="ninja" type="linux-x32" ext="zip"/>
        <artifact name="ninja" type="linux-x64" ext="zip"/>
    </publications>
</ivy-module>

I am trying to deploy to Nexus as follows:

java -jar /path/to/ivy.jar
     -settings /path/to/.ivy/ivysettings.xml
     -ivy ivy.xml
     -publish nexus-releases
     -publishpattern "target/[artifact]-[revision](-[classifier]).[ext]"
     -revision 1.2.3
     -status released
     -overwrite

What am I doing wrong?

carlspring
  • 31,231
  • 29
  • 115
  • 197

1 Answers1

3

I think you're missing an special extra attribute for the classifier field.

Additionally you'll need to generate and upload the Maven POM file. Unfortunately command-line tool doesn't support this...

See:

Update

The stand-alone jar is designed to support publishing to a repository, but there is an implicit understanding that it's an ivy repository....

This explains why the ivy file is pushed, it's the module metadata file required by ivy modules. Maven, on the other hand, uses a POM file for it's module metadata and this needs to created and also published to the Maven repository.

If you were doing all this from within ANT, you'd have makepom task to automatically generate the POM fileand the ivy publish task has a "publishivy" attribute that can be used to suppress the upload of the ivy.xml file.

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thank you very much! The part about the extra attribute does not become immediately clear from their documentation. – carlspring Jan 31 '13 at 11:17
  • Why would I need to publish the pom file? And... why is Ivy uploading an ivy.xml file to Nexus? – carlspring Jan 31 '13 at 11:26
  • @carlspring Answer updated. Have you considered using a groovy script instead of the standalone jar? Groovy has excellent integration with ANT and can call the ivy tasks directly. If you're interested post a new question and I can expand. Example: http://stackoverflow.com/questions/3955209/using-ivy-dependencies-manager-programmatically/3963721#3963721 – Mark O'Connor Jan 31 '13 at 14:10