使用常春藤的问题:发布任务

时间:2011-11-29 01:06:47

标签: ivy

我正在尝试使用常春藤:发布来发布我已经构建到.ivy存储库的jar,但是我收到了一个错误。我很确定我没有正确使用它,所以我希望有人能指出我正确的方向。

项目结构是这样的:

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

build.xml看起来像这样:

<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>

当我运行build.xml时,出现以下错误:

 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 个答案:

答案 0 :(得分:15)

您忘记了常春藤文件中的publications部分。

<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>

状态修订(pubrevision)字段可由publish任务指定,如下所示:

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

注1:

生成名称中没有修订号的jar文件会更简单。只要让常春藤的工件模式拿起jar文件。

注2:

您需要在构建的某个阶段使用常春藤解析,否则不会处理常春藤文件。