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
