ivy simple shared repository
Asked Answered
M

1

1

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 to download the latest jars from a shared repository.

ivy seems to be the solution for our problem, because ivy says that it integrates with ant (out build system) very well. But I cant get through the tutorials, they are all somehow more confusing than helpful.

All I want to achieve for the beginning is to have two small Projects. The first one has one class with one method, the second one is just calling this method. The fist project should compile into a jar that is then downloaded by the second project from the shared repository.

Thanks for your help.

Meissen answered 5/11, 2010 at 13:15 Comment(0)
N
3

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>
Nikolai answered 5/11, 2010 at 21:22 Comment(2)
I do know the tutorials from the ivy homepage, but they are strange. somehow I can't extract useful information out of them. There are so many xml-files with many strange entries which are not described anywhere. I hoped that I can get a simpler smaller project to start with.Meissen
I've added some extra explanation. Multi-module builds are not easy. You'll discover they're not fun in Maven either :-)Keane

© 2022 - 2024 — McMap. All rights reserved.