ivy simple shared repository

后端 未结 1 1535
小蘑菇
小蘑菇 2020-12-04 01:09

I am trying to compile all sub projects of one big project at my company into many jars with managed dependencies, so that not everybody who works at one project only needs

相关标签:
1条回答
  • 2020-12-04 01:44

    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>
    
    0 讨论(0)
提交回复
热议问题