开发者

Using packager resolver for external jar

I've been trying to download an external jar Jsoup by creating a packager.xml file.

When I try to building the file I get back an error which says

".......ivy2\packager\build\org.jsoup\jsoup\1.6.1\packager.xml is not a valid XML document"

The following are the changes I'v开发者_C百科e made in my ivysettings.xml

<settings defaultResolver="default"/>

    <resolvers>
       <ibiblio name="default" m2compatible="true"/>
        <packager name="packager" buildRoot="${user.home}/.ivy2/packager/build" resourceCache="${user.home}/.ivy2/packager/cache" preserveBuildDirectories="false">
            <ivy pattern="file:///${ivy.settings.dir}/[organisation]/[module]/[revision]/ivy.xml"/>
            <artifact pattern="file:///${ivy.settings.dir}/packager.xml"/>
        </packager>
    </resolvers>
    <modules>
        <module organisation="org.jsoup" name="jsoup" resolver="packager"/>
    </modules>

the following is the packager.xml file that I created,

<packager-module version="1.0">
<property name="name" value="${ivy.packager.module}"/>
    <property name="version" value="${ivy.packager.revision}"/>
<property name="packagename" value="${name}-${version}"/>

    <resource dest="archive" url="http://jsoup.org/$packagename.jar" />

    <build>
      <move file="archive/${packagename}.jar" tofile="artifacts/jars/${name}.jar"/>
    </build>
</packager-module>

The error,

[ivy:resolve] :: org.jsoup#jsoup;1.6.1: C:\blah....\blah.ivy2\packager\build\org.jsoup\jsoup\1.6.1\packager.xml is not a valid XML document.

I've tried doing all I could to make it a valid xml document but still the error doesn't revert......Can you please give some insight into this issue.

Thanks


I think I've reproduced the error.

The packager.xml file is failing it's XML schema validation check.

[ivy:retrieve] [xmlvalidate] /home/mark/.ivy2/packager/build/org.jsoup/jsoup/1.6.1/packager.xml:6:72: 
     cvc-complex-type.4: Attribute 'sha1' must appear on element 'resource'.
[ivy:retrieve] 
[ivy:retrieve] /home/mark/.ivy2/packager/build/org.jsoup/jsoup/1.6.1/build.xml:23: /home/mark/.ivy2/packager/build/org.jsoup/jsoup/1.6.1/packager.xml is not a valid XML document.

When troubleshooting the packager resolver I'd suggest setting preserveBuildDirectories attribute to "true" which enables you to see the intermediate files generated. Very clever stuff there....

Revised packager file

This is not the only problem. I finally got the packager to work as follows:

<packager-module version="1.0">
    <property name="name" value="${ivy.packager.module}"/>
    <property name="version" value="${ivy.packager.revision}"/>
    <property name="packagename" value="${name}-${version}"/>

    <resource dest="archive" url="http://jsoup.org/packages/jsoup-1.6.1.jar" sha1="b65281e9d00f255cdfab9e1880f7fc7a1fb1bffb"/>

    <build>
        <jar basedir="archive" destfile="artifacts/jars/${name}.jar"/>
    </build>
</packager-module>

The packager is really designed for unwrapping tar or zip archives containing jars. That is why I had to repack the jar file, downloaded by the packager resolver, in the example above.

Observation

You do know that you don't need the packager resolver at all? jsoup is available from Maven Central? I point this out because you already have an ibilio resolver configured in your ivy settings file.....

If you really want jsoup from it's project homepage I'd suggesting using the simpler url resolver


It sounds like your packager.xml file contains malformed XML - it has nothing to do with Ivy or JSoup, the problem is with the format of the file itself.

The snippet of packager.xml you posted looks okay, but I'm guessing it's not the whole file contents. You're welcome to post here the whole file.

You can use an XML-aware editor in order to understand where the problem is - such as an IDE (e.g. Eclipse) or a standalone XML editor.

Alternatively, you can find the offending section by trial-and-error: remove small portions of the file until the error disappears and you find the offending line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜