ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Clitheroe <g.clithe...@gmail.com>
Subject Re: Beginner question - Ivy depencency set --> ANT fileset/classpath?
Date Mon, 01 Jun 2009 20:18:12 GMT
Here's how we do it (below) to use with netbeans generated build
files.  The resolve does use per conf directories e.g., lib/compile
lib/test and I think it helps to try to use configurations as early as
possible.
After running 'ant ivy-resolve' we run 'ant
ivy-generate-nbproject-classpaths' and we're good to go from the IDE
or command line.  We did it this way because we need to support
several different IDE's and command line building and testing.  If
your only using Eclipse then the IvyDE is well worth a look.

If this looks useful (and/or your using netbeans) we add all the
targets we need by including a build-base.xml file (from a web
server).  I can post this if you're interested.

Cheers,
Geoff

<!--
Takes an ivy configuration attribute and computes it's relative
classpath (of jars), setting a property ivy.{conf}.computed.classpath
and ivy.{conf}.path.separator if any jars were found.
-->

<macrodef name="ivy-compute-classpath">
<attribute name="ivy.conf"/>

<sequential>

<pathconvert property="ivy.@{ivy.conf}.computed.classpath" setonempty="false">

<path>
<fileset dir="${ivy.lib.dir}/@{ivy.conf}" includes="*.jar"
erroronmissingdir="false"/>
</path>
<map from="${basedir}${file.separator}" to=""/>
</pathconvert>

<condition property="ivy.@{ivy.conf}.path.separator" value=":" else="">
<isset property="ivy.@{ivy.conf}.computed.classpath"/>
</condition>

<condition property="ivy.@{ivy.conf}.computed.classpath" value="">

<not>
<isset property="ivy.@{ivy.conf}.computed.classpath"/>
</not>
</condition>
</sequential>
</macrodef>
</target>

<target name="ivy-generate-nbproject-classpaths"
depends="-init-macrodef-ivy-compute-classpath" description="add
dependent jars resolved with ivy to nbproject/project.properties">

<!--
 Compute classpaths for each of our ivy configurations
-->
<ivy-compute-classpath ivy.conf="compile"/>
<ivy-compute-classpath ivy.conf="foride"/>
<ivy-compute-classpath ivy.conf="javadoc"/>
<ivy-compute-classpath ivy.conf="test"/>
<ivy-compute-classpath ivy.conf="optional"/>
<ivy-compute-classpath ivy.conf="runtime"/>

<propertyfile file="nbproject/project.properties">

<!--
 Default netbeans javac.classpath is (nothing!) just ivy's compile
configuration
-->
<entry operation="=" type="string" key="javac.classpath"
value="${ivy.compile.computed.classpath}"/>

<!--
 Plus some sources and/javadocs (if specified) for added power in the IDE
-->
<entry operation="+" type="string" key="javac.classpath"
value="${ivy.foride.path.separator}${ivy.foride.computed.classpath}"/>
<entry operation="+" type="string" key="javac.classpath"
value="${ivy.javadoc.path.separator}${ivy.javadoc.computed.classpath}"/>

<!--
 Default netbeans run.classpath is ${build.classes.dir}
-->
<entry operation="=" type="string" key="run.classpath"
value="$${build.classes.dir}"/>

<!--
 Plus some runtime (includes compile) and optional dependencies
-->
<entry operation="+" type="string" key="run.classpath"
value="${ivy.runtime.path.separator}${ivy.runtime.computed.classpath}"/>
<entry operation="+" type="string" key="run.classpath"
value="${ivy.optional.path.separator}${ivy.optional.computed.classpath}"/>

<!--
 Default netbeans javac.test.classpath is ${build.classes.dir}
-->
<entry operation="=" type="string" key="javac.test.classpath"
value="$${build.classes.dir}"/>

<!--
 Plus test (including runtime) dependencies (this will almost always
include junit and clover etc.)
-->
<entry operation="+" type="string" key="javac.test.classpath"
value="${ivy.test.path.separator}${ivy.test.computed.classpath}"/>

<!--
 Default netbeans run.test.classpath is
${build.classes.dir}:${build.test.classes.dir}
-->
<entry operation="=" key="run.test.classpath"
value="$${build.classes.dir}:$${build.test.classes.dir}"/>

<!--
 Plus test (including runtime) and optional dependencies.
-->
<entry operation="+" type="string" key="run.test.classpath"
value="${ivy.test.path.separator}${ivy.test.computed.classpath}"/>
<entry operation="+" type="string" key="run.test.classpath"
value="${ivy.optional.path.separator}${ivy.optional.computed.classpath}"/>
</propertyfile>
</target>


------

On Tue, Jun 2, 2009 at 5:54 AM, Joshua Tharp
<joshua-tharp@alumni.calpoly.edu> wrote:
> Alternatively, you can have your configurations extend one another and then
> just use a single directory. For example, you could have the configurations:
> <conf name="common" />
> <conf name="mod1" extends="common" />
> <conf name="mod2" extends="common" />
>
> Then in your dependencies, simply say which configuration they belong to
> (common, mod1, mod2, etc.) and on your build you can still use:
> <fileset id="mod1.classpath" dir="${lib.d}/mod1" includes="*.jar" />
>
> Josh
>
> On Mon, Jun 1, 2009 at 10:46 AM, Jim Garrison <Jim.Garrison@troux.com>wrote:
>
>>
>>
>> > -----Original Message-----
>> > From: joshua.tharp@gmail.com [mailto:joshua.tharp@gmail.com]
>> > On Behalf Of Joshua Tharp
>> > Sent: Monday, June 01, 2009 12:20 PM
>> > To: ivy-user@ant.apache.org
>> > Subject: Re: Beginner question - Ivy depencency set --> ANT
>> > fileset/classpath?
>> >
>> > The way I do it (and I'm not claiming to be either an expert
>> > or using the most elegant means) is I create different
>> > configurations for the different classpaths I need in a build
>> > (compile, test, deploy) and have a ivy pattern that includes
>> > the configuration ${lib.d}/[conf]/[artifact].[ext]. Then in
>> > my ant scripts I just use separate filesets like:
>> > <fileset id="test.classpath" dir="${lib.d}/test" />
>> >
>> > It works pretty well as I don' t have to adjust my classpaths
>> > when I add or remove dependencies, and I can treat more of my
>> > build generically.
>>
>> Hmmm.... I looked at <cachepath> and <cachefileset> and these don't
>> seem to do what I want.  I have, conceptually, a set of global
>> dependencies across my entire project, and then some additional sets
>> of dependencies within various modules I'm building.
>>
>> Using your approach, it sounds like I would need to build a resolved
>> lib structure like
>>
>> lib/common - dependencies used by all modules
>> lib/mod1 - dependencies specific to module 1
>> lib/mod2 - dependencies specific to module 2
>> etc
>>
>> and then define
>>
>> <fileset id="common" dir="lib/common">
>>   <include name="*"/>
>> </fileset>
>>
>> Sounds like we need an enhancement giving access to the set of dependencies
>> inside a single <ivy-module> as a list or path, instead of the entire
>> <resolve/> set.
>

Mime
View raw message