You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Robert 'Bobby' Zenz <Ro...@bonsaimind.org> on 2020/11/28 15:57:16 UTC

Quick rundown for using Ivy with multiple projects?

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?

Re: Quick rundown for using Ivy with multiple projects?

Posted by Robert 'Bobby' Zenz <Ro...@bonsaimind.org>.
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 <Ro...@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 <ja...@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?    
> 


Re: Quick rundown for using Ivy with multiple projects?

Posted by Robert 'Bobby' Zenz <Ro...@bonsaimind.org>.
 > I believe I now better understand the provided only adds jars if not
 > already  there??

Yes. What I was looking for was some way to specify "B depends on the
*source* of A located over *there*". I've now so far managed to tell
Ivy "B depends on the *jar* of A located over there".

As it comes to building, I guess I could mimic that behavior through
the Ant files, but it feels a little bit clunky because the top-level
Ant tasks would then work differently. For example, a resolve would
always need to compile A instead of simply doing a resolve.
Additionally, I have the odd feeling that I missed the easy solution
completely, because I can't be the first one trying to do a
multi-module structure like this in Ivy.


On Tue, 29 Dec 2020 23:13:58 -0500
Rob Silver <rs...@gmail.com> wrote:

> Hello  Robert 'Bobby' Zenz,
> 
> I too have been slow to respond for good reason. I had a family
> crisis that prevented me from responding.
> I believe I now better understand the provided only adds jars if not
> already  there??
> 
> 
> 
> On Sat, Dec 5, 2020 at 11:13 AM Robert 'Bobby' Zenz <
> Robert.Zenz@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 <ja...@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?  
> >
> >  


Re: Quick rundown for using Ivy with multiple projects?

Posted by Rob Silver <rs...@gmail.com>.
Hello  Robert 'Bobby' Zenz,

I too have been slow to respond for good reason. I had a family crisis that
prevented me from responding.
I believe I now better understand the provided only adds jars if not
already  there??



On Sat, Dec 5, 2020 at 11:13 AM Robert 'Bobby' Zenz <
Robert.Zenz@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 <ja...@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?
>
>

Re: Quick rundown for using Ivy with multiple projects?

Posted by Robert 'Bobby' Zenz <Ro...@bonsaimind.org>.
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 <ja...@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?  


Re: Quick rundown for using Ivy with multiple projects?

Posted by Jaikiran Pai <ja...@gmail.com>.
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?

Re: Quick rundown for using Ivy with multiple projects?

Posted by Jaikiran Pai <ja...@gmail.com>.
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?