> Okay, I'll bite.  Why isn't this a good idea?  I would like to have
> a way that all common properties are set in a single build
> script so I don't have to modify all my build scripts if changes
> are made.   Can you suggest another method?

  I 've gone thro the same difficulty .. 

  Some sort of OOAD in ANT w.r.t reuse ?  Hmmm.. I use the following
technique ..

  I have one build file called *MasterBuild.xml* and one build file for
every-project *ProjectA1Build.xml* 

  In *Design Pattern* terminology .. the technique that I describe below may
be called as *Template Method*. You may consider "MasterBuild.xml" as
equivalent of base-class and "ProjectA1Build.xml" as derived-class
(approximately) .

MasterBuild.xml :

   # I put all the common properties here.
   # I define all the common tasks here .. like 
             init
             prepare
             clean
             compile
             makeJavaDoc
             package
             build
             rebuild
             emailBuildResults
   

ProjectA1Build.xml :

   # I customize the necessary properties (that are unique to this project).

   Example :

#################  ProjectA1.xml  STARTS
<project name="ProjectA1" default="defaultTarget" basedir="." >
    <property   name    ="projectName"  value   ="ProjectA1" />

    <!-- This property will be used while creating project jars -->
    <property name="projectMainClassInJar"
value="com.monsanto.xyz.ProjectA1"/>

      <!-- This property will be used for generating JavaDoc for appropriate
packages-->
        <property name="packagePrefix" value="com/monsanto/xyz/" />
        <patternset  id="javadoc_package_includes" >
          <include
name="${packagePrefix}${projectName}/ClientBusinessLogic/**" />
          <exclude name="${packagePrefix}${projectName}/test/**" />
        </patternset>

The *IMPORTANT* link :

        In addition to all the above *customization* for ProjectA1 .. "all
my ProjectA__" will contain the following two lines. [one can put this value
in environment-variable]

        <property name="masterBuildFilePath" value="./MasterBuild.xml" />
        <property name="execTarget" value="" />

"All my ProjectA__" will also contain this *singggggle* *VERY IMPORTANT*
task : 

        <target name="defaultTarget" depends="init" description="Create
directories that are missing" > 
          <echo message="Entering prepare ProjectA1Build.xml"/>
                <ant antfile="${masterBuildFilePath}" target="${execTarget}"
inheritAll="true" inheritrefs="true" />
          <echo message="Exiting prepare ProjectA1.xml"/>
        </target>
</project>
#################  ProjectA1.xml  ENDS 


HOW TO EXECUTE :

    OBJECTIVE : To *rebuild* ProjectA1 ..

    ant -buildfile ProjectA1Build.xml -DexecTarget=rebuild



Definition for *Template Method* Design Pattern :
  An application framework allows you to inherit from a class or set of
classes and create a new application, reusing most of the code in the
existing classes and overriding one or more methods in order to customize
the application to your needs. A fundamental concept in the application
framework is the Template Method which is typically hidden beneath the
covers and drives the application by calling the various methods in the base
class (some of which you have overridden in order to create the
application).



Hope this helps to solve your prob ..

Thanks,
Premkumar.N



Sr.Programmer Analyst( Bioinformatics)
Monsnato Enterprises
Bangalore, INDIA.
[EMAIL PROTECTED], [EMAIL PROTECTED]








-----Original Message-----
From: Dave Rathnow [mailto:[EMAIL PROTECTED]]
Sent: Friday, 15 November 2002 8:51 PM
To: 'Ant Users List'
Subject: RE: Can properties be returned to a calling ant script?


> > 2. Can you have a called Ant script define properties which 
> > can be picked up by the calling Ant script.
> 
> Write them to a file that gets read back in by the parent build
> process.  Most of the time, you don't want to do this 8-)

Okay, I'll bite.  Why isn't this a good idea?  I would like to have
a way that all common properties are set in a single build
script so I don't have to modify all my build scripts if changes
are made.   Can you suggest another method?

Thanks,
Dave.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to