ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kirby Files <kfi...@masergy.com>
Subject Re: ivy:publish build error
Date Thu, 15 Sep 2011 13:52:07 GMT
zharvey wrote on 09/15/2011 09:29 AM:
>
> Hi Kirby,
>
> Thanks for getting back to me so quickly.
>
> Here's my settings file (ivy-settings.xml):
> ===============================
> <ivysettings>
> 	<properties file="ivy-settings.properties"/>
>      <settings defaultResolver="defResolver"/>
>      <latest-strategies>
>      	<latest-lexico/>
>      </latest-strategies>
>      <resolvers>
>          <chain name="defResolver" returnFirst="true">
>           	<url name="jarServer">
> 				<ivy
> pattern="http://my-server.net/module_descriptors/[organisation]/[module]-[revision]-ivy.xml"/>
> 				<artifact
> pattern="http://my-server.net/artifacts/[organisation]/[artifact]-[revision].[ext]"/>
>           	</url>
>          </chain>
>      </resolvers>

You only have url resolvers defined here. You cannot really publish to 
those. You need to publish to a resolver you can write to: filesystem, 
sftp, webdav via common-vfs, etc.

>      <modules>
>      	<module organisation="myOrg" name="*" resolver="defResolver"/>
>      </modules>

If you have a defaultResolver defined, as you do above, you don't need 
to do explicit module mapping to a resolver.


>      <publications defaultconf="publish">
> 		<artifact name="MyModule" />
> 	</publications>

You're going to publish your artifacts to a configuration named 
publish, so any modules depending on MyModule will need to have a 
confMapping of compile->publish. Is that what you want? I typically 
publish artifacts to configurations based upon how they will be used 
by the consuming project. So jars needed for running an app will be in 
the "runtime" configuration, while jars only needed for building will 
be published to the "compile" configuration, etc. I also defined 
javadocs and sources configurations.


> 	<!-- Ivy "publish" task; publish the distribution to SVN for downstream
> projects -->
> 	<target name="publish">
> 		<ivy:publish organisation="myOrg" module="MyModule" resolver="defResolver"
> revision="1.0">
> 			<artifacts pattern="dist/[artifact]-[revision].[ext]"/>
> 		</ivy:publish>
> 	</target>
> </project>

So there's your problem. The publish target needs to depend on the 
resolve target, which needs to depend on the settings target.

The settings task should only ever be run once during an ant build, so 
I guard against executing twice (say resolve->settings and 
deliver->settings are both executed in the same build):

     <target name="ivysettings" unless="ivysettings.completed">
         <property name="ivysettings.completed" value="true" />
         <ivy:settings id="ivy.instance"
                       url="${ivy.settings.url}"
         />
     </target>


You'll also want to publish to a resolver to which you can write. I 
generally would not add the artifacts child element (use publications 
in ivy.xml instead); use artifactspattern to define where to find the 
jars specified in <publications>. Unless you have multiple modules per 
buildfile, I wouldn't use the org or module attributes, either. You 
should probably specify a pubrevision and status.

Here's an example from one of my projects:

     <target name="publish_only"
             depends="resolve"
             description="--&gt; publish this project in the prod ivy 
repository">
         <property name="revision" value="${version}" />
         <ivy:publish 
artifactspattern="${dist.dir}/[type]s/[artifact]-[revision].[ext]"
                      resolver="masrep_sftp"
                      pubrevision="${revision}"
                      status="release"
                      overwrite="false"
                      update="true" />
         <echo message="project ${ant.project.name} released with 
version ${revision}" />
     </target>

Also,
Thanks,
---
Kirby Files
Software Architect
Masergy Communications
kfiles@masergy.com


Mime
View raw message