ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Coene <maarten_co...@yahoo.com>
Subject Re: Question about publishing snapshots to nexus
Date Wed, 16 Dec 2009 23:22:03 GMT
To solve your problem of having to duplicate the ivy.xml, you might want to deliver your ivy.xml
file first to a temporary location.
With the ivy:deliver task, you can set the revision of the delivered ivy.xml file, and in
addition, ivy:deliver can optionally replace all dynamic revisions with static ones. This
can avoid problems because maven won't understand revisions like for instance "latest.integration".

After that, you can use the ivy:makepom task to transform your delivered ivy.xml file into
a pom file.

Another approach could be that you specify the revision in your ivy.xml as an ant property?
Ivy will replace such properties when parsing the ivy.xml file...

I don't know how to solve your second problem though. I think Ivy can download these kind
of timestamped snapshots, but it probably can't publish them this way. Maybe you could open
a JIRA improvement request for this? Or maybe you can add those timestamped artifacts as extra
<artifact> element to your ivy:publish task?

Maarten




----- Original Message ----
From: Burt Leung <burt.leung@gmail.com>
To: ivy-user@ant.apache.org
Cc: Bruce Harris <bruce.harris@21csi.com>
Sent: Wed, December 16, 2009 1:50:16 AM
Subject: Question about publishing snapshots to nexus

Hi All,

I've recently started studying IVY and am interested in using it in our own
development process. One of the problems I'm trying to solve is how to
publish a "snapshot" type artifact to our company's Sonatype Nexus
repository.

Actually, I did manage to publish and consume a snapshot of a dependency,
but I think there's something I'm not quite doing correctly. I'm hoping
someone can provide some guidance. Here is what I did:
1) In order to publish a jarFileA to Nexus I had to use the "makepom" ANT
task. This is because Nexus works with pom files and I'm not the server
admin so I can't dictate that we'll configure things to use ivy.xml
descriptor files instead (I'm just guessing that's possible, not sure).

1a) In the ivysettings.xml I defined the resolver for a release type
repository on the Nexus server:
<ibiblio name="localReleasesRepo" m2compatible="true" checkmodified="true"
root="http://localhost:8080/nexus-webapp-1.3.3/content/repositories/releases
"/>

1b) Here is the "info" section" in the ivy.xml (just showing for the sake of
the revision value):
    <info
        organisation="someOrg"
        module="someMod"
        revision="1.0.0"  <==========
        status="integration">
        <repository name="21CSINexus" url="
http://buildsvr.21csi.com:8081/nexus"/>
    </info>

1c) Here is what my ANT build target looks like for publishing a release:
    <target name="publishRelease" >
        <available property="isArtifactsDirCorrect" file="${artifactsDir}"/>
        <fail message="The directory is not valid: ${artifactsDir}"
unless="isArtifactsDirCorrect" />

        <ivy:makepom ivyfile="ivy.xml"
pomfile="${artifactsDir}/${ivyModule}.pom"/>  <====================

        <tstamp>
            <format property="now" pattern="yyyyMMddHHmmss"/>
        </tstamp>

        <ivy:publish resolver="localReleasesRepo"
settingsref="defaultSettings" organisation="${ivyOrg}"
            module="${ivyModule}" revision="${ivyModuleVersion}"
pubdate="${now}"
            forcedeliver="false" overwrite="true"
artifactspattern="${artifactsDir}/[artifact].[ext]"
            publishivy="false" status="release">
            <!-- need to specify that the pom file will be published too,
otherwise it won't be. -->
            <artifact name="${ivyModule}" type="pom" ext="pom"/>
        </ivy:publish>
    </target>

2) Now for a normal "release" version of the artifact(s), the above is
perfectly fine. It will publish to the release type repository. However, if
I want to publish a snapshot of the artifact, then I had to do the
following:

2a) In the ivysetting.xml I had to specify a snapshot type repository on
Nexus and also a changingPattern:
<ibiblio name="localSnapshotsRepo" m2compatible="true" checkmodified="true"
changingPattern="*-SNAPSHOT" root="
http://localhost:8080/nexus-webapp-1.3.3/content/repositories/snapshots"/>

2b) I had to create a _separate_ ivy.xml file (named ivy.integration.xml)
which had a revision value that indicated it was a snapshot:
    <info
        organisation="com.p21csi.aedgex"
        module="bathymetry"
        revision="1.0.0-SNAPSHOT" <=============================
        status="integration">
        <repository name="21CSINexus" url="
http://buildsvr.21csi.com:8081/nexus"/>
    </info>

2c) A separate ANT target for publishing a snapshot had to be created which
invoked the makepom operation on the ivy.integration.xml file:
    <target name="publishSnapshot" >
        <available property="isArtifactsDirCorrect" file="${artifactsDir}"/>
        <fail message="The directory is not valid: ${artifactsDir}"
unless="isArtifactsDirCorrect" />

        <!--<ivy:makepom ivyfile="ivy.xml"
pomfile="${artifactsDir}/${ivyModule}.pom"/>-->
        <ivy:makepom ivyfile="ivy.integration.xml"
pomfile="${artifactsDir}/${ivyModule}.pom"/> <============

        <tstamp>
            <format property="now" pattern="yyyyMMddHHmmss"/>
        </tstamp>

        <ivy:publish resolver="localSnapshotsRepo"
settingsref="defaultSettings" organisation="${ivyOrg}"
            module="${ivyModule}" revision="${ivyModuleVersion}"
            pubrevision="${ivyModuleVersion}-SNAPSHOT"
<================================
            pubdate="${now}"
            forcedeliver="true" overwrite="true"
artifactspattern="${artifactsDir}/[artifact].[ext]"
            publishivy="false" status="integration">
            <!-- need to specify that the pom file will be published too.
-->
            <artifact name="${ivyModule}" type="pom" ext="pom"/>
        </ivy:publish>
    </target>


So, while I did verify that I was able to publish the snapshot and then
consume it from a project that depended on that snapshot, is there a way to
do this without having to _duplicate_ the ivy.xml file?

Another issue I found is that the snapshot I published to nexus, using Ivy
and its generated POM file, is placed according to the following file system
structure:
<nexus server root directory>
    <snapshot repository folder>
        <artifactName>
            <versionNumber-SNAPSHOT>
                <artifactName>-1.0.0-SNAPSHOT.jar
                <artifactName>-1.0.0-SNAPSHOT.pom

Whereas, artifacts published using Maven are placed according to the
following file system structure:
<nexus server root directory>
    <snapshot repository folder>
        <artifactName>
            <versionNumber-SNAPSHOT>
                <artifactName>-1.0.0-<timestamp>.jar
                <artifactName>-1.0.0-<timestamp>.pom

How can I get the timestamp to be substituted when I publish artifacts?


Thanks in advance for any help that can be provided!
Burt



      

Mime
View raw message