ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <xavier.ha...@gmail.com>
Subject Re: Classifier frustration
Date Thu, 17 Apr 2008 07:35:51 GMT
On Mon, Apr 14, 2008 at 1:30 AM, Jim White <jim@pagesmiths.com> 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:
>
> 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',
> url:'
> http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.2.1/json-lib-2.2.1-jdk15.jar
> ')
>       }
>   }
> }
>
> Naturally that is not so satisfying, so then I see this ("Re: How can I
> retrieve binary files and source files in one shot"):
>
> http://marc.info/?l=ivy-user&m=119939232121568&w=2
>
> which makes me think, Aha! but alas no joy because if I try to make an Ivy
> like that I get:
>
> 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', 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 ResolveTest.java 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="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.

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!

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

Xavier


>
> 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:
>
> http://www.ifcx.org/
>
> 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
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/

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