You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Steve Stevenson <lo...@gmail.com> on 2012/12/19 00:42:25 UTC

Publish task not consistently respecting extra attributes

Hi, thanks in advance for the help!  (or at least reading this)

I'm having difficulties with the Publish task.  The task is correctly using
the value of an extra attribute/token value as defined in the src ivy
pattern when it does its internal deliver task of the ivy file, but then
ignoring the value of that attribute/token when retrieving the resolved Ivy
file for publishing.

Here is a simplified case.  I have a C# .NET project that produces a .dll
(no dependencies), and publishes that .dll to a file system repository.

Short version:
I define an extra attribute e:folderItegRev on my Ivy file, and set it
using an ant property set to the value "101."
I call ivy:publish with:
 srcivypattern="${ivy.basedir}/bin/Release/[module](-[folderItegRev])-ivy.xml"
The internal publish task delivers ivy file
as " [...]\PublishTest\bin\Release\PublishTest-101-ivy.xml" as expected,
but fails to publish the ivy file, apparently looking for
"[...]\PublishTest\bin\Release\PublishTest-ivy.xml," which is not what was
delivered (missing the "101").

Long version, with code:
Ivy file (ivy.xml):
-----------------------

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info organisation="Personal" module="PublishTest"
e:folderItegRev="${folder.itegrev}"/>
<configurations>
<conf name="Primary" visibility="public"/>
</configurations>
<publications>
<artifact name="PublishTest" ext="dll" type="dll" conf="Primary"
e:folderItegRev="${folder.itegrev}"/>
</publications>
</ivy-module>


Ivy settings (ivysettings.xml):
-----------------------------------------

<ivysettings>
<settings defaultResolver="localRepo"/>
<resolvers>
<filesystem name="localRepo">
<ivy
pattern="${ivy.home}/localRepo/[organization]/[module]/[folderItegRev]/[revision]/[type]s/[module]-ivy.xml"
/>
<artifact
pattern="${ivy.home}/localRepo/[organization]/[module]/[folderItegRev]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]"
/>
</filesystem>
</resolvers>
</ivysettings>


Ant build file (build.xml):
------------------

<project default="build" xmlns:dn="antlib:org.apache.ant.dotnet"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="folder.itegrev" value="101"/>
 <target name="build">
<ivy:configure file="ivysettings.xml" />
<ivy:resolve conf="Primary" />
<dn:msbuild buildfile="${basedir}/${ivy.module}.csproj">
<property name="Configuration" value="Release" />
<property name="BuildProjectReferences" value="false"/>
<property name="WarningLevel" value="4"/>
</dn:msbuild>
<ivy:publish
resolver="localRepo"
artifactspattern="${ivy.basedir}/bin/Release/[artifact].[ext]"
srcivypattern="${ivy.basedir}/bin/Release/[module](-[folderItegRev])-ivy.xml"
conf="Primary"
/>
</target>
</project>


My build works successfully and ivy:publish is called.  The deliver task
delivers the resolved Ivy file as expected, including the folderItegRev
value:

[ivy:publish] :: delivering :: Personal#PublishTest;working@computer ::
20121218161637 :: integration :: Tue Dec 18 16:16:37 MST 2012
[ivy:publish] options = status=integration pubdate=Tue Dec 18 16:16:37 MST
2012 validate=true resolveDynamicRevisions=true merge=true resolveId=null
pubBranch=null
[ivy:publish] delivering ivy file to
[...]\PublishTest\bin\Release\PublishTest-101-ivy.xml
[ivy:publish] deliver done (16ms)


Note that the delivered Ivy file is "PublishTest-101-ivy.xml," including
the [folderItegRev] value, as expected.  But when the publish is called an
IllegalArgumentException is thrown that the ivy file to publish was not
found:

BUILD FAILED
[...]\PublishTest\build.xml:17: impossible to publish artifacts for
Personal#PublishTest;working@computer: java.lang.IllegalArgumentException:
ivy file to publish not found for Personal#PublishTest;working@computer:
call deliver before ([...]\PublishTest\bin\Release\PublishTest-ivy.xml)


I've tried explicitly calling <ivy:deliver /> prior to publish, and it
again works as expected, but the publish does not.  I've tried manually
calling <ivy:info /> prior to publish, thinking it might update a necessary
property that publish is not setting... no luck.

I'm about ready to go spelunking through the source, but thought I'd ask
the experts first.  Thanks again!

-Chris

Re: Publish task not consistently respecting extra attributes

Posted by marcdb <md...@gmail.com>.
I think that this is related to the fact that the actual value for that extra
attribute is only filled in at the moment when you do your ivy:publish (or
ivy:deliver). So at the moment when the publish is executed, the actual
value for this attribute is probably not known.

Maybe you can use the related ant property instead of the attribute itself
in your pattern:
* First run ivy:init in your build file, which should result in the setting
of the property ivy.extra.folderItegRev.
* Then you can use that in your pattern when publishing:
<ivy:publish
resolver="localRepo"
artifactspattern="${ivy.basedir}/bin/Release/[artifact].[ext]"
srcivypattern="${ivy.basedir}/bin/Release/[module]-${ivy.extra.folderItegRev}-ivy.xml"
conf="Primary"
/>
Alternatively, you could use directly your original property
${folder.itegrev}.

I don't understand why the attribute folderItegRev was optional in your
pattern. Because you always set the property to "101" in your buildfile(or
maybe this was just for testing purposes ?). Anyhow, you could simulate in
ant this optional clause, using conditional statements, or by using the <if>
task from the ant-contrib package together with the <isset> condition.

Regards,
Marc

-- 
View this message in context: http://old.nabble.com/Publish-task-not-consistently-respecting-extra-attributes-tp34813029p34814018.html
Sent from the ivy-user mailing list archive at Nabble.com.