Xavier Hanin wrote:
On Mon, Apr 14, 2008 at 1:30 AM, Jim White <[EMAIL PROTECTED]> wrote:
...
Is it possible to use a POM with the Ivy Ant tasks? What do I need to do
to use a classifier from the Ant tasks? It's possible I could use the Ivy
Java API, but I'm trying to avoid tying my implementation too closely to
Ivy's internals and Ant tasks are preferred.
Yes you can use poms instead of Ivy files if you prefer, Ivy makes the
difference using the file extension: .pom => parses it as a pom, anything
else => parses it as an Ivy file. Unless you implement your own parser,
which can handle other cases (hint to implement a parser actually supporting
the groovy syntax you use :-)).
Well, I was generating a POM with a .pom extension and was getting an
error. I will try and get some more details at another time.
But everything that is supported by Ivy can be done in Ivy files, so you
don't need to actually use a pom. The trick to support classifiers in ivy
files is to use an extra attribute. Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.apache"
module="test"
revision="1.0"
status="integration"
publication="20080216150523"
/>
<dependencies>
<dependency org="net.sf.json-lib" name="json-lib" rev="2.2.1">
<artifact name="json-lib" type="jar" m:classifier="jdk15"/>
</dependency>
</dependencies>
</ivy-module>
With your syntax, you will lack xml namespaces (xml not that bad sometimes
:-)). But under the hood Ivy see it as a classifier attribute, so if you
disable validation as Gilles suggested, or use your own syntax with your own
parser and your own validation, you can simply support the classifier
attribute.
Actually Groovy's MarkupBuilder does support XML namespaces because it
is rather literally minded about such things.
http://groovy.codehaus.org/Creating+XML+using+Groovy's+MarkupBuilder
I put an attribute named 'xmlns:m2' in the root element and then I can
do this:
XWINGS.IVY {
info(organisation:"org.ifcx", module:"WingsIvyTest")
dependencies {
dependency(org:'net.sf.json-lib', name:'json-lib', rev:'2.2.1'
, conf:'default->runtime')
{
artifact(name:'json-lib', type:'jar'
, 'm2:classifier':'jdk15')
}
}
}
And that works to get the right artifact the first time.
Now the trouble is that if you change the value of the classifier Ivy
doesn't notice that the artifact in the local cache is wrong. I think
that the classifier needs to be appended to the module name in the cache
for this to work properly.
BTW, if you end up implementing a module descriptor parser for the joy of
using a groovy syntax in your metadata, please share the result with the
community!
Hmm, I am not a big fan of Groovy builder syntax outside of Groovy
scripts.
There are folks doing stuff like Gant which is Groovy scripts that use
AntBuilder and use their own script launching mechanism rather than
Ant's, and I think that is not a good direction because it fails to
effectively leverage the support Ant has in so many development
environments.
The parsing thing I do want to do though is annotation and Javadoc
processors that generate Ivy files and/or POM files using syntax like:
/**
* @use org="net.sf.json-lib" name="json-lib" rev="2.2.1"
*/
Also I'm planning a thing called "OOHTML" that will make creating these
sorts of files more fun too.
BTW again :-), I like the idea of using groovy inside Open Office, and even
more with Ivy :-)
Thanks!
I also have a thing called "AntAnywhere" which automates making things
runnable using JavaWebStart. Ivy integration has been next on the list
of things to do for that, and will be done eventually I think...
http://www.ifcx.org/wiki/AntAnywhere.html
Jim