ivy simple shared repository

﹥>﹥吖頭↗ 提交于 2019-11-27 15:54:21

A multi-module project is described in the documentation:

http://ant.apache.org/ivy/history/latest-milestone/tutorial/multiproject.html

and the source code is available in subversion:

http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/example/multi-project/

The simplified summary of how it works:

Wrapper build

Invokes each individual module build in the correct order. If Module A depends on module B, then B will be built first:

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="build-all" default="build">

    <!--
    ==========================================================================
    Use the ivy buildlist task to create an ordered list of sub-project builds
    ==========================================================================
    -->
    <target name="build-list">
        <ivy:buildlist reference="build-path">
            <fileset dir="." includes="modules/**/build.xml"/>
        </ivy:buildlist>
    </target>

    <!--
    ==============================
    Invoke targets in sub-projects
    ==============================
    -->
    <target name="build" depends="build-list" description="Invoke build target on sub-projects">
        <subant target="build" buildpathref="build-path" />
    </target>

</project>

For more information see the buildlist documentation.

Module build

Each module will download it's dependencies at the beginning of it's build

<target name="init">
    <ivy:settings file="../../ivysettings.xml"/>
    <ivy:resolve/>
</target>

At at the end, will publish it's built artifacts:

<target name="publish" depends="build" description="Publish module artifacts to the respository">
    <ivy:publish resolver="${publish.resolver}" pubrevision="${publish.revision}" overwrite="true">
        <artifacts pattern="${build.dir}/[artifact].[ext]"/>
    </ivy:publish>
</target>

Don't forget that for all this to work each module must declare what it depends on and what it publishes

<ivy-module version='2.0'>

    <info organisation='com.myorg' module='mymod'/>

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

    <dependencies>
         ..
    </dependencies>

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