ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Foreman <Alexander.Fore...@morganstanley.com>
Subject Re: How to programaticly gather all the artifacts from an ivy file.
Date Mon, 12 Oct 2009 15:46:18 GMT
Hi,
To knowledge share and close thread.

After snooping around the API this is how to get the artifacts list
for the current ivy.xml file (not its dependent projects).

ModuleDescriptorParserRegistry parserRegistry =
ModuleDescriptorParserRegistry.getInstance();
ModuleDescriptor md = parserRegistry.parseDescriptor(ivySettings, new
File(ivyFile).toURI().toURL(), true);
Artifact[] allArtifacts = md.getAllArtifacts();

I now have access to all the artifacts that _my_ ivy.xml produces
programatically for use.

Hope that helps other people.

Thanks,

2009/10/9 Alex Foreman <foremaa@morganstanley.com>:
> Great place to start.  If I find a nice solution I'll update here for
> knowledge purposes.
>
> Mitch:  Yes indeed I only want the projects artifacts and not its
> dependencies, thanks.
>
> Many thanks,
>
> Alex
>
>
>
> 2009/10/8 Mitch Gitman <mgitman@gmail.com>:
>> The standard way to gather the artifacts for a given Ivy conf is to invoke
>> the following Ant tasks in sequence:
>> 1. ivy:resolve
>> 2. ivy:cachefileset
>>
>> If you want to accomplish the same programmatically, I would suggest looking
>> into how you can leverage these existing tasks or the top-level APIs they
>> call.
>>
>> By the way, it sounds like you only want the artifacts within the module
>> itself, and not the artifacts belonging to its dependencies. In that case,
>> ivy:resolve should have transitive="false".
>>
>
> 2009/10/8 Troy Self <tself@bbn.com>:
>> There is an option when using ivy standalone to output the current classpath
>> from an ivy.xml file:
>>
>> java -jar ivy.jar -confs runtime -cachepath classpath.txt
>>
>> I would start there in the source code and see how it achieves it. There are
>> probably methods there that you can call directly.
>>
>> -- tBs
>>
>>> -----Original Message-----
>>> From: Alex Foreman [mailto:Alexander.Foreman@morganstanley.com]
>>> Sent: Thursday, October 08, 2009 10:51 AM
>>> To: ivy-user@ant.apache.org
>>> Subject: How to programaticly gather all the artifacts from an ivy file.
>>>
>>> Hey Guys,
>>>
>>> I have a runscript generator which is driven by ivy.
>>> Currently however I am only including the main jar my build creates.
>>>
>>> If someone has a artifact list like this:
>>>
>>> <artifact name="prod" ext="jar" type="jar" conf="runtime" />
>>> <artifact name="prodstandalone" ext="jar" type="jar" conf="standalone" />
>>>
>>> <artifact name="qa" ext="jar" type="jar" conf="qa-runtime" />
>>>
>>> <artifact name="prod-spring" ext="xml" type="xml" />
>>> <artifact name="qa-spring" ext="xml" type="xml" />
>>>
>>> I wish to be able to use Ivy to say for my ivy.xml tell me all
>>> artifacts that are in 'x' config.
>>> This way I can setup my classpath on the fly and be completely driven
>>> from Ivy.xml
>>>
>>> Is there any easy way to do this.  I'm not to keen on writing a
>>> separate xml parser to gather this information which I would presume I
>>> should have access to already.
>>>
>>> Many thanks in advance!
>>>
>>>
>>> --
>>> Alex Foreman
>>
>>
>>
>
>
>
> --
> Alex Foreman
>



-- 
Alex Foreman

Mime
View raw message