ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Blanc <Sebastien.Bl...@alcatel.com>
Subject Re: fileset with multiple source directories?
Date Mon, 12 May 2003 21:50:29 GMT
u can look at Dominique Devienne 's answer on 'project management w/ ANT' thread' for
xml/xslt. no easy way to go but result is efficient.
seb.

DD wrote: "What you describe seems similar in some ways to what I've been doing around
my <subant> task, but it seems to me you still think the Makefile way rather
than the Ant way...

Anyhow, here's what I've done, so you can decide for yourself if you want to
take a similar approach. My goal was to build two dozens projects, all with
dependencies between them. Here's how I did it.

1) Defined an XML file gathering all the information about the projects,
detailed enough to be able to generate a build file for each. The XML file
contains the static dependency information between the projects. Also
defined a schema for that file to validate it before using it.

  <target name="validate" depends="init"
          description="Ensures dependencies.xml's is correct
(schema-valid)">
    <schemavalid file="dependencies.xml"
                 externalNoNamespaceSchema="dependencies.xsd" />
    <echo message="${dependencies} is schema-valid" />
  </target>

2) XSLT this file into one build.xml per project (using the Xalan redirect
extension, similarly to the junit-frames.xsl of Ant).

  <target name="buildfiles" depends="init, validate"
          description="Builds all the modules directories and build files">
    <style in="dependencies.xml"
           out="build/dependencies-out.xml"
           style="dependencies2build.xsl"
           processor="trax" />

    <style in="dependencies.xml"
           out="build/dependencies-bat-out.xml"
           style="dependencies2build-bat.xsl"
           processor="trax" />
  </target>

3) Use my <subant> task to call all the sub-projects build in the right
build/dependency order. The build order is inferred from the XML file
defined in (1) and a specific build path resolver (the <subant> posted in
BugZilla doesn't have this resolver extension I added later, and just builds
in the statically specified <buildpath> order).

    <buildpath ident="buildpath"
         resolverClassname="com.lgc.buildmagic.TahoeBuildPathResolver">
      <param name="destdir" value="${destdir}" />
      <param name="dependencies" value="${dependencies}" />
    </buildpath>
    <property name="buildpath" refid="buildpath" />

4) I have a master build.xml file which re-generates the sub-projects
build.xml files using regular Ant tasks like <uptodate> and normal
dependencies between targets (see dependency on buildfiles target below).
Targets that recurse to the subprojects simply look like this:

  <target name="build" depends="buildfiles"
          description="Builds all the modules">
    <subant buildpathref="buildpath" />
  </target>

  <target name="jar" depends="buildfiles"
          description="Builds the JARs of all modules">
    <subant buildpathref="buildpath" />
  </target>

In a nutshell, that's it. Note that recursion is limited to one level, and
I'm not trying to decide when to build and where to go (no multi-level
recursion). Everything is statically defined in the main XML file (called
dependencies.xml in my case).

This whole thing took me a long time to build, and evolves a few custom
tasks, but in the end it worked, and is fully Ant (1.5.1) driven. But this
is definitely not for the fainted of heart. My real purpose for building
this monster was to keep internal dependencies between the various 'modules'
of the same (huge) code base in check (too many developer writing too much
code too fast), but it sounds similar enough to your approach that I'm
taking the time to explain it here, in the hope that it might help you
decide how to proceed in your case. Cheers, --DD"

Sebastien Blanc wrote:

> my bad, I thought this list could be computed through a dirset or fileset.
> in such a case, I wd personnally use contrib foreach so I'd let other people try to
> answer ur question.
>
> however:
> - one ANT way you could go for is to define ur build dependencies into an XML file
> and then use xslt to generate ur build.xml file (for instance): this is usefull to
> me to re-use these dependencies for javac, EJB deploy, clean in the correct order,
> bean verify and so on.
> - heaviest and simplest solution beeing to define one property for each subdir - I
> know, not much help but looks like this list is a harcoded one and does not rely on
> any logic but build dependencies: maybe this could be outputed by a tool that
> compiles build depencies (jdepend for instance) and then re-used.
>
> just to be sure, is there really no way for u to compute dynamically this
> src.contrib.projects proprety, i.e. isn't this list the list of subdirectories
> under ${contrib.path} ? maybe ur pb is the order of the resulting dirset for
> compilation dependency so in such a case I understand.
>
> seb.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message