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 Carl Quinn <ca...@gmail.com> on 2010/02/10 03:49:38 UTC

Getting a module's artifacts for build

I'm trying to put together a set of standard Ant build scripts for my company
and I'd like the Ant code to be able to derive what to do based almost
entirely from each module's ivy.xml file.

Where I am having trouble is getting the list of artifacts for the module
into Ant properties. The closest I've gotten to to fake a publish and then
capture the pre-publish-artifact trigger information. This seems like a
terrible hack though.

It seems like ivy:info could give me more info. Is there any way to coax it
to do that?

-- 
View this message in context: http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27525526.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: Getting a module's artifacts for build

Posted by Maarten Coene <ma...@yahoo.com>.
Thanks for the patch Carl,
I've added a comment to the issue. Could you take a look?

An alternative solution to your problem is using xmltask to find the artifacts defined by your ivy.xml.
I use the approach myself in some of the build files @ work...

Maarten




----- Original Message ----
From: Carl Quinn <ca...@gmail.com>
To: ivy-user@ant.apache.org
Sent: Wed, February 10, 2010 8:36:32 AM
Subject: Re: Getting a module's artifacts for build


Aha, it looks like I'm not the first to ask for this:
http://issues.apache.org/jira/browse/IVY-395

Maybe I'll just extend ivy:info itself and submit a patch. The actual Java
code is pretty easy.



Carl Quinn wrote:
> 
> Good idea using properties, I might try that out.
> 
> My main motivation for eliminating the duplication is that we have
> hundreds of modules that I am convincing teams to convert to Ivy. If I can
> move all the imperative logic to a common core of Ant imports, then all we
> need in each project is the ivy.xml and maybe a tiny build.xml stub. Works
> with Ant, and works with IvyDE and IntelliJ. A very easy sell if I can
> pull it off :)
> 
> I think I will try my hands at an Ivy plugin to add an extended info task.
> 
> 
> 
> Mitch Gitman wrote:
>> 
>> Carl, interesting use case. I can't think of any existing Ivy task that
>> accomplishes what you're looking for.
>> 
>> And I can't say I'd be motivated myself to go to the lengths you're going
>> to
>> to avoid redundancy. However, I can attest that I have run into trouble
>> where I've changed the name of an artifact I'm publishing but I forgot to
>> change the name in the ivy.xml. Then I'd be poring over an error message
>> like:
>> impossible to publish artifacts for [module]: java.io.IOException:
>> missing
>> artifact [artifact]
>> 
>> This problem is strictly a matter of keeping track of the same name in
>> two
>> places. And the straightforward solution is to use a ${} Ant property
>> placeholder for the artifact name in the ivy.xml--since property
>> substitutions are allowed in source (unpublished) ivy.xml files.
>> 
>> On Tue, Feb 9, 2010 at 7:54 PM, Carl Quinn <ca...@gmail.com> wrote:
>> 
>>>
>>> Yes, I've had that part all figured out for awhile. I can build and
>>> publish
>>> all my simple projects now.
>>>
>>> What I would like to do next is to remove all knowledge of specific
>>> artifacts from my Ant files, and derive the artifact build actions from
>>> the
>>> metadata already available in the ivy.xml file. (I don't like
>>> redundancy)
>>>
>>> So, I would like to have something like Ivy:info that also gave me the
>>> artifact declarations from my module's ivy file, including extra
>>> attributes
>>> if possible. All of that this is well before publish. I could then know
>>> what
>>> to build and put into the dist dir and then invoke publish on all of
>>> that.
>>>
>>> Ideas? Or should I write a new Ivy Ant task?
>>>
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27527071.html
Sent from the ivy-user mailing list archive at Nabble.com.


      

Re: Getting a module's artifacts for build

Posted by Carl Quinn <ca...@gmail.com>.
Aha, it looks like I'm not the first to ask for this:
http://issues.apache.org/jira/browse/IVY-395

Maybe I'll just extend ivy:info itself and submit a patch. The actual Java
code is pretty easy.



Carl Quinn wrote:
> 
> Good idea using properties, I might try that out.
> 
> My main motivation for eliminating the duplication is that we have
> hundreds of modules that I am convincing teams to convert to Ivy. If I can
> move all the imperative logic to a common core of Ant imports, then all we
> need in each project is the ivy.xml and maybe a tiny build.xml stub. Works
> with Ant, and works with IvyDE and IntelliJ. A very easy sell if I can
> pull it off :)
> 
> I think I will try my hands at an Ivy plugin to add an extended info task.
> 
> 
> 
> Mitch Gitman wrote:
>> 
>> Carl, interesting use case. I can't think of any existing Ivy task that
>> accomplishes what you're looking for.
>> 
>> And I can't say I'd be motivated myself to go to the lengths you're going
>> to
>> to avoid redundancy. However, I can attest that I have run into trouble
>> where I've changed the name of an artifact I'm publishing but I forgot to
>> change the name in the ivy.xml. Then I'd be poring over an error message
>> like:
>> impossible to publish artifacts for [module]: java.io.IOException:
>> missing
>> artifact [artifact]
>> 
>> This problem is strictly a matter of keeping track of the same name in
>> two
>> places. And the straightforward solution is to use a ${} Ant property
>> placeholder for the artifact name in the ivy.xml--since property
>> substitutions are allowed in source (unpublished) ivy.xml files.
>> 
>> On Tue, Feb 9, 2010 at 7:54 PM, Carl Quinn <ca...@gmail.com> wrote:
>> 
>>>
>>> Yes, I've had that part all figured out for awhile. I can build and
>>> publish
>>> all my simple projects now.
>>>
>>> What I would like to do next is to remove all knowledge of specific
>>> artifacts from my Ant files, and derive the artifact build actions from
>>> the
>>> metadata already available in the ivy.xml file. (I don't like
>>> redundancy)
>>>
>>> So, I would like to have something like Ivy:info that also gave me the
>>> artifact declarations from my module's ivy file, including extra
>>> attributes
>>> if possible. All of that this is well before publish. I could then know
>>> what
>>> to build and put into the dist dir and then invoke publish on all of
>>> that.
>>>
>>> Ideas? Or should I write a new Ivy Ant task?
>>>
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27527071.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: Getting a module's artifacts for build

Posted by Carl Quinn <ca...@gmail.com>.
Good idea using properties, I might try that out.

My main motivation for eliminating the duplication is that we have hundreds
of modules that I am convincing teams to convert to Ivy. If I can move all
the imperative logic to a common core of Ant imports, then all we need in
each project is the ivy.xml and maybe a tiny build.xml stub. Works with Ant,
and works with IvyDE and IntelliJ. A very easy sell if I can pull it off :)

I think I will try my hands at an Ivy plugin to add an extended info task.



Mitch Gitman wrote:
> 
> Carl, interesting use case. I can't think of any existing Ivy task that
> accomplishes what you're looking for.
> 
> And I can't say I'd be motivated myself to go to the lengths you're going
> to
> to avoid redundancy. However, I can attest that I have run into trouble
> where I've changed the name of an artifact I'm publishing but I forgot to
> change the name in the ivy.xml. Then I'd be poring over an error message
> like:
> impossible to publish artifacts for [module]: java.io.IOException: missing
> artifact [artifact]
> 
> This problem is strictly a matter of keeping track of the same name in two
> places. And the straightforward solution is to use a ${} Ant property
> placeholder for the artifact name in the ivy.xml--since property
> substitutions are allowed in source (unpublished) ivy.xml files.
> 
> On Tue, Feb 9, 2010 at 7:54 PM, Carl Quinn <ca...@gmail.com> wrote:
> 
>>
>> Yes, I've had that part all figured out for awhile. I can build and
>> publish
>> all my simple projects now.
>>
>> What I would like to do next is to remove all knowledge of specific
>> artifacts from my Ant files, and derive the artifact build actions from
>> the
>> metadata already available in the ivy.xml file. (I don't like redundancy)
>>
>> So, I would like to have something like Ivy:info that also gave me the
>> artifact declarations from my module's ivy file, including extra
>> attributes
>> if possible. All of that this is well before publish. I could then know
>> what
>> to build and put into the dist dir and then invoke publish on all of
>> that.
>>
>> Ideas? Or should I write a new Ivy Ant task?
>>
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27526318.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: Getting a module's artifacts for build

Posted by Mitch Gitman <mg...@gmail.com>.
Carl, interesting use case. I can't think of any existing Ivy task that
accomplishes what you're looking for.

And I can't say I'd be motivated myself to go to the lengths you're going to
to avoid redundancy. However, I can attest that I have run into trouble
where I've changed the name of an artifact I'm publishing but I forgot to
change the name in the ivy.xml. Then I'd be poring over an error message
like:
impossible to publish artifacts for [module]: java.io.IOException: missing
artifact [artifact]

This problem is strictly a matter of keeping track of the same name in two
places. And the straightforward solution is to use a ${} Ant property
placeholder for the artifact name in the ivy.xml--since property
substitutions are allowed in source (unpublished) ivy.xml files.

On Tue, Feb 9, 2010 at 7:54 PM, Carl Quinn <ca...@gmail.com> wrote:

>
> Yes, I've had that part all figured out for awhile. I can build and publish
> all my simple projects now.
>
> What I would like to do next is to remove all knowledge of specific
> artifacts from my Ant files, and derive the artifact build actions from the
> metadata already available in the ivy.xml file. (I don't like redundancy)
>
> So, I would like to have something like Ivy:info that also gave me the
> artifact declarations from my module's ivy file, including extra attributes
> if possible. All of that this is well before publish. I could then know
> what
> to build and put into the dist dir and then invoke publish on all of that.
>
> Ideas? Or should I write a new Ivy Ant task?
>
>
>

Re: Getting a module's artifacts for build

Posted by Carl Quinn <ca...@gmail.com>.
Yes, I've had that part all figured out for awhile. I can build and publish
all my simple projects now.

What I would like to do next is to remove all knowledge of specific
artifacts from my Ant files, and derive the artifact build actions from the
metadata already available in the ivy.xml file. (I don't like redundancy)

So, I would like to have something like Ivy:info that also gave me the
artifact declarations from my module's ivy file, including extra attributes
if possible. All of that this is well before publish. I could then know what
to build and put into the dist dir and then invoke publish on all of that.

Ideas? Or should I write a new Ivy Ant task?



Mitch Gitman wrote:
> 
> Carl, no need to set special properties. Ivy's pattern matching takes care
> of finding the correct origin artifacts. Suppose in your project's ivy.xml
> you say you want to publish foo.jar like so:
>   <publications>
>     <artifact name="foo" type="jar" conf="default" />
>   </publications>
> 
> And suppose that, in the course of your build, you create a foo-1.0.jar in
> your dist directory where 1.0 is your desired version. To get ivy:publish
> to
> know where to look, you would specify ivy:publish's artifactpattern
> attribute like so:
>     <ivy:publish
> artifactspattern="${dist.dir}/[artifact]-[revision].[ext]"
> ... />
> 
> Ivy's smart enough to know to match each artifact in your ivy.xml against
> each potential [artifact]-[revision].[ext]-matching file in ${dist.dir}.
> As
> for how Ivy negotiates the revision, check the documentation on the
> ivy:publish task:
> http://ant.apache.org/ivy/history/trunk/use/publish.html
> 
> On Tue, Feb 9, 2010 at 6:49 PM, Carl Quinn <ca...@gmail.com> wrote:
> 
>>
>> I'm trying to put together a set of standard Ant build scripts for my
>> company
>> and I'd like the Ant code to be able to derive what to do based almost
>> entirely from each module's ivy.xml file.
>>
>> Where I am having trouble is getting the list of artifacts for the module
>> into Ant properties. The closest I've gotten to to fake a publish and
>> then
>> capture the pre-publish-artifact trigger information. This seems like a
>> terrible hack though.
>>
>> It seems like ivy:info could give me more info. Is there any way to coax
>> it
>> to do that?
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27525526.html
>> Sent from the ivy-user mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27525922.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: Getting a module's artifacts for build

Posted by Mitch Gitman <mg...@gmail.com>.
Carl, no need to set special properties. Ivy's pattern matching takes care
of finding the correct origin artifacts. Suppose in your project's ivy.xml
you say you want to publish foo.jar like so:
  <publications>
    <artifact name="foo" type="jar" conf="default" />
  </publications>

And suppose that, in the course of your build, you create a foo-1.0.jar in
your dist directory where 1.0 is your desired version. To get ivy:publish to
know where to look, you would specify ivy:publish's artifactpattern
attribute like so:
    <ivy:publish artifactspattern="${dist.dir}/[artifact]-[revision].[ext]"
... />

Ivy's smart enough to know to match each artifact in your ivy.xml against
each potential [artifact]-[revision].[ext]-matching file in ${dist.dir}. As
for how Ivy negotiates the revision, check the documentation on the
ivy:publish task:
http://ant.apache.org/ivy/history/trunk/use/publish.html

On Tue, Feb 9, 2010 at 6:49 PM, Carl Quinn <ca...@gmail.com> wrote:

>
> I'm trying to put together a set of standard Ant build scripts for my
> company
> and I'd like the Ant code to be able to derive what to do based almost
> entirely from each module's ivy.xml file.
>
> Where I am having trouble is getting the list of artifacts for the module
> into Ant properties. The closest I've gotten to to fake a publish and then
> capture the pre-publish-artifact trigger information. This seems like a
> terrible hack though.
>
> It seems like ivy:info could give me more info. Is there any way to coax it
> to do that?
>
> --
> View this message in context:
> http://old.nabble.com/Getting-a-module%27s-artifacts-for-build-tp27525526p27525526.html
> Sent from the ivy-user mailing list archive at Nabble.com.
>
>