Issues using ivy:publish task

一笑奈何 提交于 2019-11-26 17:16:08

问题


I'm trying to use ivy:publish to publish a jar that I've built to the .ivy repository, but I'm getting an error. I'm pretty sure I'm not using it correctly, so I was hoping someone could point me in the right direction.

The project structure is something like this:

root--|
      |--src
      |--build
      |      |
      |      |--someorganisation-commonlib-1.0.0.jar
      |
      |--ivy.xml
      |--build.xml

The build.xml looks something like this:

<target name="publish"> 
        <ivy-publish organisation="someorganisation" resolver="local" module="commonlib" revision="1.0.0">
               <artifacts pattern="build/[organisation]-[module](-[revision])(-[type]).[ext]" />
        </ivy-publish>  
    </target>

ivy.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
    <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

        <info
            organisation="someorganisation"
            module="commonlib"
            status="integration">
        </info>

    <dependencies>  
            <dependency org="com.thoughtworks.xstream" name="xstream" rev="1.3.1" transitive="false"/>
            <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" transitive="false"/>
            <dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.1" transitive="false"/>
            <dependency org="joda-time" name="joda-time" rev="1.6.2" transitive="false"/>
        </dependencies>

    </ivy-module>

When I run the build.xml, I get the following error:

 C:\workspaces\wkspc\someproject\build.xml:8: someorganization#commonlib;1.0.0: java.lang.IllegalStateException: ivy file not found in cache for someorganization#commonlib;1.0.0: please resolve dependencies before delivering (C:\Documents and Settings\someuser\.ivy2\cache\resolved-someorganization-commonlib-1.0.0.xml)

回答1:


You've forgotten a publications section in your ivy file.

<ivy-module version="2.0">
    <info organisation="someorganisation" module="commonlib"/>

    <publications>
        <artifact name="commonlib" type="jar"/>
    </publications>

    <dependencies>  
        <dependency org="com.thoughtworks.xstream" name="xstream" rev="1.3.1" transitive="false"/>
        <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" transitive="false"/>
        <dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.1" transitive="false"/>
        <dependency org="joda-time" name="joda-time" rev="1.6.2" transitive="false"/>
    </dependencies>    
</ivy-module>

The status and revision (pubrevision) fields can be specified by the publish task as follows:

   <ivy:publish resolver="${publish.resolver}" pubrevision="${publish.revision}" status="${publish.status}">
        <artifacts pattern="${build.dir}/[organisation]-[artifact].[ext]"/>
    </ivy:publish>

Note 1:

It would be simpler to generate the jar file without the revision number in the name. Just let ivy's artifact pattern pick up the jar file.

Note 2:

You will require an ivy resolve at some stage in your build, otherwise the ivy file doesn't get processed.



来源:https://stackoverflow.com/questions/8304562/issues-using-ivypublish-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!