Ok, so I think I figured it out, but still not sure if anything is out
of the ordinary. I took bits and pieces of this from the ivy
Main.main method...
Ivy ivy = Ivy.newInstance();
ivy.configureDefault();
File ivyfile = File.createTempFile("ivy", ".xml");
ivyfile.deleteOnExit();
String[] dep = new String[]{"commons-lang", "commons-lang", "1.0"};
DefaultModuleDescriptor md = DefaultModuleDescriptor
.newDefaultInstance(ModuleRevisionId.newInstance(dep[0],
dep[1] + "-caller", "working"));
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]),
false, false, true);
md.addDependency(dd);
XmlModuleDescriptorWriter.write(md, ivyfile);
String[] confs = new String[]{"default"};
ResolveOptions resolveOptions = new ResolveOptions().setConfs(confs);
ResolveReport report = ivy.resolve(ivyfile.toURL(), resolveOptions);
It would be nice for someone to document this. I can imagine many
systems wanting to use ivy's resolution mechanism outside of the ant
process.
Ilya
On Sun, Sep 21, 2008 at 10:55 PM, Ilya Sterin <[EMAIL PROTECTED]> wrote:
> Yes, it works fine using it with ant from command line for the same
> dependency. I just used the commons-cli dep, same error using the
> retriever from java, but it's fine otherwise.
>
> Any docs, example you can point me to that would outline the usage
> pattern/bootstrapping of ivy from java?
>
> Thanks
>
> Ilya
>
> On Sun, Sep 21, 2008 at 5:32 PM, Maarten Coene <[EMAIL PROTECTED]> wrote:
>> What happens when you do the same from within Ant?
>> <ivy:resolve organisation="org.bcel" module="bcel" resolveId="res.bcel" />
>>
>> Maarten
>>
>>
>>
>>
>> ----- Original Message ----
>> From: Ilya Sterin <[EMAIL PROTECTED]>
>> To: [email protected]
>> Sent: Sunday, September 21, 2008 6:23:14 PM
>> Subject: Embedded ivy
>>
>> So I'm trying to use ivy as an embedded dependency manager in another
>> build system. I'm having issues finding documentation as to how to
>> use Ivy's libs outside of ant. I'm not sure about the bootstrapping
>> requirements and how each task can be used in isolation and its
>> dependencies.
>>
>> I've tried numerous things with some luck, but I'm still not all the
>> way there and don't feel comfortable with the stability of such a
>> solution being that it's not documented?
>>
>> Project proj = new Project();
>>
>> IvyResolve resolve = new IvyResolve();
>> resolve.setOrganisation("org.bcel");
>> resolve.setModule("bcel");
>> resolve.setProject(proj);
>> resolve.setTaskName("ivy:resolve");
>> resolve.setResolveId("res.bcel");
>> resolve.execute();
>>
>> IvyRetrieve retrieve = new IvyRetrieve();
>> retrieve.setResolveId("res.bcel");
>> retrieve.setProject(proj);
>> retrieve.setOrganisation("org.bcel");
>> retrieve.setModule("bcel");
>> retrieve.setRevision("5.2");
>> retrieve.setTaskName("ivy:retrieve");
>> retrieve.execute();
>>
>>
>> I'm getting...
>>
>> impossible to resolve dependencies:
>> resolve failed - see output for details
>> at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:315)
>> at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:275)
>> at
>> com.googlecode.alexbuild.antlr.com.googlecode.alexbuild.commands.IvyTest.testDependencyRetrieve(IvyTest.java:59)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>>
>> I'm sure I'm missing something obvious. Can anyone help me resolve
>> this issue and/or give me a brief overview/point me to documentation
>> of how to use Ivy embedded?
>>
>> Thanks.
>>
>> Ilya
>>
>>
>>
>>
>>
>