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 zharvey <za...@gmail.com> on 2011/09/15 14:58:39 UTC

ivy:publish vs publications

(1) What is is the difference between the ivy:publish task called from the
ant buildscript, and the "publications" element defined in the ivy.xml file
("module descriptor")? According to the docs, the publications element is
used to "declare artifacts to be published", whereas the ivy:publish task
actually publishes artifacts. But how are these two connected? Can they
conflict with one another? If they are connected, what are the best
practices for making them work nicely with one another? For example, here's
what I have so far:

ivy.xml
=====
<publications defaultconf="publish">
    <artifact name="[artifact]-[revision].[ext]"/>
</publications>

build.xml
======
<target name="publish">
    <ivy:publish>
        <artifacts pattern="dist/[artifact]-[revision].[ext]"/>
    </ivy:publish>
</target>

Am I doing it right?!?
-- 
View this message in context: http://old.nabble.com/ivy%3Apublish-vs-publications-tp32471368p32471368.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: ivy:publish vs publications

Posted by Kirby Files <kf...@masergy.com>.
zharvey wrote on 09/15/2011 09:20 AM:
>
> Alan,
>
> Wow - thanks for such a thorough answer! I'm still not seeing the blatent
> connection between the publications tag and my ivy:publish task though.  Say
> I change my ivy.xml:
>
> <publications defaultconf="publish">
>      <artifact name="MyModule"/>
> </publications>

If you're just going to stick with the default of having the artifact 
have the same name as the ivy module, you don't even need to list the 
artifact up there, though it can help clear up any ambiguity for 
someone reading your ivy.xml.

> This just tells Ivy that I've got something to publish called MyModule.  But
> where do I tell Ivy that MyModule is actually located at
> workspace\MyProject\dist\MyModule-1.0.jar and that I want to publish it to
> my pubRepo repository when I run ivy:publish? I know what you're saying is
> correct, I'm just having trouble connecting all the dots.

In a publish task, the artifactspattern attribute describes the 
location of the file to be published on disk; the resolver attribute 
describes which resolver to publish to (a filesystem resolver or sftp, 
for example), and then you generally want a pubrevision and status as 
well.

As an example, here's my default ant target for publishing:


    <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="true"
                      update="true" />
         <echo message="project ${ant.project.name} released with 
version ${revision}" />
     </target>

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

Re: ivy:publish vs publications

Posted by Alan Chaney <al...@writingshow.com>.
On 9/15/2011 6:20 AM, zharvey wrote:
> Alan,
>
> Wow - thanks for such a thorough answer! I'm still not seeing the blatent
> connection between the publications tag and my ivy:publish task though.  Say
> I change my ivy.xml:
>
> <publications defaultconf="publish">
>      <artifact name="MyModule"/>
> </publications>
>
> This just tells Ivy that I've got something to publish called MyModule.  But
> where do I tell Ivy that MyModule is actually located at
> workspace\MyProject\dist\MyModule-1.0.jar and that I want to publish it to
> my pubRepo repository when I run ivy:publish? I know what you're saying is
> correct, I'm just having trouble connecting all the dots.
Try something like:

<target name="publish">
      <ivy:publish resolver="pubRepo">
          <artifacts pattern="dist/[artifact]-[revision].[ext]"/>
      </ivy:publish>
</target>

This will take all the defaults from the ivy settings you are using. I assume that your ant 'basedir' ===
workspace\MyProject\

Alan



>
> Alan Chaney-2 wrote:
>> On 9/15/2011 5:58 AM, zharvey wrote:
>>> (1) What is is the difference between the ivy:publish task called from
>>> the
>>> ant buildscript, and the "publications" element defined in the ivy.xml
>>> file
>>> ("module descriptor")? According to the docs, the publications element is
>>> used to "declare artifacts to be published", whereas the ivy:publish task
>>> actually publishes artifacts. But how are these two connected?
>> Well, the way I see it, the publications element is a definition of what
>> you want published and the Ivy publish task
>> reads the definition and does what you ask.
>>
>>
>>>    Can they
>>> conflict with one another?
>> Following my definition above, they can't "conflict with each other"
>> because they are two different aspects of the same concept.
>>
>>> If they are connected, what are the best
>>> practices for making them work nicely with one another? For example,
>>> here's
>>> what I have so far:
>> They are indeed connected because the ivy.xml publications element tells
>> the ivy:publish task what to do.
>>
>>> ivy.xml
>>> =====
>>> <publications defaultconf="publish">
>>>       <artifact name="[artifact]-[revision].[ext]"/>
>>> </publications>
>>>
>>> build.xml
>>> ======
>>> <target name="publish">
>>>       <ivy:publish>
>>>           <artifacts pattern="dist/[artifact]-[revision].[ext]"/>
>>>       </ivy:publish>
>>> </target>
>>>
>>> Am I doing it right?!?
>> See
>> http://ant.apache.org/ivy/history/latest-milestone/ivyfile/artifact.html,
>> specifically,
>> under 'Attributes'
>>
>> name the name of the published artifact. This name must not include
>> revision.
>>
>> The name of the artifact should be something meaningful, like your
>> project name - see the examples in the section above
>>
>> As far as your ivy:publish target goes, there is a required attribute -
>> 'resolver' but normally I find that I need to specify the pubrevision as
>> well.
>>
>> See examples in:
>> http://ant.apache.org/ivy/history/latest-milestone/use/publish.html
>>
>> But, I wouldn't class myself as an "expert" on Ivy - I just use it a
>> lot. I find the best approach is to read the documentation *very*
>> carefully, and then take the examples and tweak them to do what I need.
>> Ivy is a very powerful beast but there are a number of traps for the
>> unwary.
>>
>> Alan
>>
>>
>>
>>
>>
>>


Re: ivy:publish vs publications

Posted by zharvey <za...@gmail.com>.
Alan,

Wow - thanks for such a thorough answer! I'm still not seeing the blatent
connection between the publications tag and my ivy:publish task though.  Say
I change my ivy.xml:

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

This just tells Ivy that I've got something to publish called MyModule.  But
where do I tell Ivy that MyModule is actually located at
workspace\MyProject\dist\MyModule-1.0.jar and that I want to publish it to
my pubRepo repository when I run ivy:publish? I know what you're saying is
correct, I'm just having trouble connecting all the dots.


Alan Chaney-2 wrote:
> 
> On 9/15/2011 5:58 AM, zharvey wrote:
>> (1) What is is the difference between the ivy:publish task called from
>> the
>> ant buildscript, and the "publications" element defined in the ivy.xml
>> file
>> ("module descriptor")? According to the docs, the publications element is
>> used to "declare artifacts to be published", whereas the ivy:publish task
>> actually publishes artifacts. But how are these two connected?
> Well, the way I see it, the publications element is a definition of what 
> you want published and the Ivy publish task
> reads the definition and does what you ask.
> 
> 
>>   Can they
>> conflict with one another?
> Following my definition above, they can't "conflict with each other" 
> because they are two different aspects of the same concept.
> 
>> If they are connected, what are the best
>> practices for making them work nicely with one another? For example,
>> here's
>> what I have so far:
> They are indeed connected because the ivy.xml publications element tells 
> the ivy:publish task what to do.
> 
>>
>> ivy.xml
>> =====
>> <publications defaultconf="publish">
>>      <artifact name="[artifact]-[revision].[ext]"/>
>> </publications>
>>
>> build.xml
>> ======
>> <target name="publish">
>>      <ivy:publish>
>>          <artifacts pattern="dist/[artifact]-[revision].[ext]"/>
>>      </ivy:publish>
>> </target>
>>
>> Am I doing it right?!?
> See 
> http://ant.apache.org/ivy/history/latest-milestone/ivyfile/artifact.html,
> specifically, 
> under 'Attributes'
> 
> name the name of the published artifact. This name must not include 
> revision.
> 
> The name of the artifact should be something meaningful, like your 
> project name - see the examples in the section above
> 
> As far as your ivy:publish target goes, there is a required attribute - 
> 'resolver' but normally I find that I need to specify the pubrevision as 
> well.
> 
> See examples in: 
> http://ant.apache.org/ivy/history/latest-milestone/use/publish.html
> 
> But, I wouldn't class myself as an "expert" on Ivy - I just use it a 
> lot. I find the best approach is to read the documentation *very* 
> carefully, and then take the examples and tweak them to do what I need. 
> Ivy is a very powerful beast but there are a number of traps for the
> unwary.
> 
> Alan
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/ivy%3Apublish-vs-publications-tp32471368p32471538.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: ivy:publish vs publications

Posted by Alan Chaney <al...@writingshow.com>.
On 9/15/2011 5:58 AM, zharvey wrote:
> (1) What is is the difference between the ivy:publish task called from the
> ant buildscript, and the "publications" element defined in the ivy.xml file
> ("module descriptor")? According to the docs, the publications element is
> used to "declare artifacts to be published", whereas the ivy:publish task
> actually publishes artifacts. But how are these two connected?
Well, the way I see it, the publications element is a definition of what 
you want published and the Ivy publish task
reads the definition and does what you ask.


>   Can they
> conflict with one another?
Following my definition above, they can't "conflict with each other" 
because they are two different aspects of the same concept.

> If they are connected, what are the best
> practices for making them work nicely with one another? For example, here's
> what I have so far:
They are indeed connected because the ivy.xml publications element tells 
the ivy:publish task what to do.

>
> ivy.xml
> =====
> <publications defaultconf="publish">
>      <artifact name="[artifact]-[revision].[ext]"/>
> </publications>
>
> build.xml
> ======
> <target name="publish">
>      <ivy:publish>
>          <artifacts pattern="dist/[artifact]-[revision].[ext]"/>
>      </ivy:publish>
> </target>
>
> Am I doing it right?!?
See 
http://ant.apache.org/ivy/history/latest-milestone/ivyfile/artifact.html, specifically, 
under 'Attributes'

name the name of the published artifact. This name must not include 
revision.

The name of the artifact should be something meaningful, like your 
project name - see the examples in the section above

As far as your ivy:publish target goes, there is a required attribute - 
'resolver' but normally I find that I need to specify the pubrevision as 
well.

See examples in: 
http://ant.apache.org/ivy/history/latest-milestone/use/publish.html

But, I wouldn't class myself as an "expert" on Ivy - I just use it a 
lot. I find the best approach is to read the documentation *very* 
carefully, and then take the examples and tweak them to do what I need. 
Ivy is a very powerful beast but there are a number of traps for the unwary.

Alan