I think I figured it out in a half-way sane way.

What I have now is a project looking like this:

    Project
     |-modules
     |  |-ModuleA
     |  |  |-build.xml
     |  |  \-ivy.xml
     |  \-ModuleB
     |     |-build.xml
     |     \-ivy.xml
     |-build.xml
     |-build-module.xml
     \-ivysettings.xml

build.xml is basically only forwarding to each module, as you've shown
me. build-module.xml is the common build.xml for every module which is
imported by every module.

The ivysettings.xml contains a custom resolver chain which checks the
other modules for artifacts, before asking ibiblio for them:

    <ivysettings>
        <settings defaultResolver="default"/>
        
        <resolvers>
            <chain name="default">
                <filesystem name="local" checkmodified="true">
                    <ivy 
pattern="${modulesdir}/[artifact]/target/routing-[artifact]-[revision].[ext]" />
                    <artifact 
pattern="${modulesdir}/[artifact]/target/routing-[artifact]-[revision].[ext]" />
                </filesystem>
                <ibiblio name="central" m2compatible="true"/>
            </chain>
        </resolvers>
    </ivysettings>

"modulesdir" in this case is a variable pointing to my "modules"
directory. That means that if B depends on A, ivy will copy the build
artifact from A to B when resolving the dependencies.

So far this seems to work well enough, but obviously requires A to be
build before B can be resolve it, which might or might not turn out to
be a problem. Any comments? Did I miss or violate something?


On Sat, 5 Dec 2020 17:12:42 +0100
Robert 'Bobby' Zenz <robert.z...@bonsaimind.org> wrote:

> Thanks for the fast response, sorry for my slow response.
> 
> This is what I needed on the top-level, but how do I reference
> correctly project A in project B? Assuming that B depends on A?
> 
> I guess I need to set up a resolver, but so far I have a hard time
> understanding what exactly I need to do.
> 
> 
> On Sat, 28 Nov 2020 21:36:47 +0530
> Jaikiran Pai <jai.forums2...@gmail.com> wrote:
> 
> > And of course, you then just do:
> > 
> > ant clean deploy
> > 
> > from the top level directory and that will then run those targets
> > for all sub-projects.
> > 
> > -Jaikiran
> > 
> > On 28/11/20 9:34 pm, Jaikiran Pai wrote:  
> > > It's a bit too late here, so I'll keep this short for now. In one
> > > of the projects that we have, which has a similar structure, we
> > > use Ivy's buildlist task[1] to first create the ordered list of
> > > projects that need to be built and then invoke on that ordered
> > > list. So the top level build.xml will have something like ("clean"
> > > and "deploy" are just example common targets in all these
> > > projects):
> > >
> > > <target name="build-modules-list">
> > >     <ivy:buildlist reference="modules">
> > >         <fileset dir="${basedir}" includes="*/**/build.xml"/>
> > >     </ivy:buildlist>
> > > </target>
> > >
> > > <target name="clean" depends="build-modules-list">
> > > </target>
> > >
> > > <target name="deploy" depends="build-modules-list">
> > >     <!-- invoke on each sub-project, in the "modules" reference
> > > --> <subant buildpathref="modules">
> > >         <target name="clean"/>
> > >         <target name="deploy"/>
> > >     </subant>
> > > </target>
> > >
> > >
> > > [1] https://ant.apache.org/ivy/history/2.5.0/use/buildlist.html
> > >
> > > -Jaikiran
> > >
> > > On 28/11/20 9:27 pm, Robert 'Bobby' Zenz wrote:    
> > >> Can somebody give me a quick rundown regarding the usage of
> > >> Ant+Icy when having multiple projects in the same repository.
> > >> I'm a little bit confusing regarding how to define the
> > >> dependency.
> > >>
> > >> Let's assume that Project AB has the two modules A and B:
> > >>
> > >>      Parent AB
> > >>       |-Project A
> > >>       |  |-src
> > >>       |  |-build.xml
> > >>       |  \-ivy.xml
> > >>       |-Project B
> > >>       |  |-src
> > >>       |  |-build.xml
> > >>       |  \-ivy.xml
> > >>       \-build.xml
> > >>
> > >> I'm unsure how to make B depending on A, and how to correctly
> > >> declare that dependency in the ivy.xml of B. Do I need to define
> > >> a custom resolver which is checking the other project? Can
> > >> somebody give me a quick rundown on what is the best way to do
> > >> this? Or should I structure my project differently?    
> 

Reply via email to