ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <>
Subject Re: Classifier frustration
Date Thu, 17 Apr 2008 07:35:51 GMT
On Mon, Apr 14, 2008 at 1:30 AM, Jim White <> wrote:

> Hello Xavier and friends!
> I've been lurking around Ivy for a long while and am glad to see it close
> to being released as Apache Ant software.
> Today I tried to sort out a problem someone was having using JSON-lib with
> Groovy and ran smack into a M2 classifier.  So I workaround it sort of this
> way:
>   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',
> url:'
> ')
>       }
>   }
> }
> Naturally that is not so satisfying, so then I see this ("Re: How can I
> retrieve binary files and source files in one shot"):
> which makes me think, Aha! but alas no joy because if I try to make an Ivy
> like that I get:
>   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', classifier:'jdk15')
>       }
>   }
> }
> : syntax errors in ivy file: java.text.ParseException: [xml parsing:
> file:/tmp/ifcx-wings-ivy-23918.xml:5:65: cvc-complex-type.3.2.2: Attribute
> 'classifier' is not allowed to appear in element 'artifact'. in
> file:/tmp/ifcx-wings-ivy-23918.xml
> ]
> Same problem if I try that in 'dependency'.  I look into the ivy.xsd in
> SVN and see that indeed there is no 'classifier' anywhere, nor is there in
> the related Java files.
> I then find the code which uses a classifier in a POM
> which it hands off to ivy.resolve(File), and so I think Aha! again and set
> about trying to give the Ivy Ant resolve task a POM, but that doesn't seem
> to be working out either, although perhaps I just need to do further
> debugging.
> 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 :-)).

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="">
    <info organisation="org.apache"
        <dependency org="net.sf.json-lib" name="json-lib" rev="2.2.1">
            <artifact name="json-lib" type="jar" m:classifier="jdk15"/>

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

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

BTW again :-), I like the idea of using groovy inside Open Office, and even
more with Ivy :-)


> Thanks in advance for any pointers.
> And if you want to get a peek at Ivy integrated with Groovy inside
> OpenOffice, you can try it out here:
> It's the "IFCX Wings" literate scripting document that is enabled by
> GroovyForOpenOffice, but you can just look at the document without using
> G4OO for the macro.
> Jim

Xavier Hanin - Independent Java Consultant

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message