DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19006>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19006

Better support of the 'path' element, in particular in the 'fileset' element'

           Summary: Better support of the 'path' element, in particular in
                    the 'fileset' element'
           Product: Ant
           Version: 1.5.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


By now, most ANT tasks, elements and attributes (for example 'fileset' and 
'webxml') are used easily only if all files to process are in the same 
'WorkArea'.

But for big projects, the fact that each developper has all files in its own 
'WorkArea' has drawbacks :
-  Each WorkArea contains too many files (several thousands) to be correcly 
managed by a human being.
-  Whenever a developper modifies the interface of a low level API, he has to 
deliver it to all other developpers, and this manual delivery process NEVER 
works correctly.

So we use following concepts and methods :
-  At one time, the project manager creates a 'Baseline', which is a 'WorkArea' 
corresponding to a project version, containing a coherent set of versions of 
all 
files, builds it with classpath=Baseline, the publishes it read-only for all 
developpers.
-  Each developper then creates his own 'WorkArea' pointing to the common 
'Baseline' :
   -  At the beginning, the WorkArea contains only empty folders, but NO file.
   -  The developper puts in his WorkArea only NEW and MODIFIED files.
   -  For compilation, the classpath is 'WorkArea;Baseline'.
-  That permits all developpers to easily handle a sparse WorkArea with a 
limited number of files, and automatically use the SAME low level APIs delived 
in the Baseline.

When needed, the project manager can also create an 'Incremental Baseline' by 
building it as a WorkArea pointing to an existing 'Baseline', then publishing 
it 
read-only.
Each developer can then create his own new WorkArea pointing to the incremental 
Baseline, and the classpath is then 'WorkArea;Incremental Baseline;Full 
Baseline'.

We also sometimes use more than 3 levels.

So, the (class)path to search for files can be any one of these ones:
1)  'WorkArea'
2)  'WorkArea:Full Baseline'
3)  'WorkArea;Incremental Baseline;Full Baseline
4)  ...

In my wrapper script (written in perl), I follow the 'WorkArea' to 'Baseline' 
links to get the full PATH, and I call ant with the corresponding options :
1)  '-Dbasedir=WorkArea'
2)  '-Dbasedir=WorkArea'  '-Dsp1=Full Baseline'
3)  '-Dbasedir=WorkArea'  '-Dsp1=Incremental Baseline'  '-Dsp2=Full Baseline'
4)  ...

So ANT is aware of the full PATH.

But this is NOT easily handled in the 'build.xml' file, mainly because the 
'fileset' element requires an EXISTING 'dir' attribute.

So, if I want to manage n levels of WorkArea, I have to n-plicate each task, 
with 'if' and 'unless' attributes (see example with 3 levels at the bottom).


Below are my enhancement requests, that I hope can be implemented in ANT 1.6 :

A)  fileset
-----------
My main enhancement request is that the 'fileset' element accepts the 'path' 
and 
'pathref' attributes similar respectively to the 'classpath' and 'classpathref' 
attributes of the 'javac' task.

B)  war
-------
Similarly, the 'war' task should accept the 'webxmlpath' and 'webxmlpathref' 
attributes to search for the file specified by the 'webxml' attribute.

C)  property
------------
Similarly, when the 'location' attribute is specified and the value of 
'location' is NOT an absolute path, the 'property' element should accept the 
'path' and 'pathref' attributes to search for the file specified by the 
'location' attribute there, and NOT in the project's 'basedir'.

D)  fileset
-----------
When the 'dir' attribute is specified, the 'fileset' element should accept the 
'mandatory' attribute, with default value 'true'.  When its value is 'false', 
the task should NOT fail, but the 'fileset' element should be simply ignored.



<?xml version="1.0" encoding="UTF-8"?>


<project  name="exampleWar"  default="exampleWar">
  
  
  <description>ANT build file for example.war</description>
  
  
  <!--
      Verify that the destination folder exists.
      Define the destination file.
   -->
  <target  name="init">     
    
    <echo  level="verbose"  message="Project Name = ${ant.project.name}"/>
  
    <!-- Create the time stamp -->
    <tstamp/>
  
    <property   name="webapps"        value="tomcat/webapps"/>
    <available  property="webappsOK"  type="dir"  file="${webapps}"/>
    <fail  unless="webappsOK"
           message=" *****  Folder  '${webapps}'  NOT found  *****"/>
    <echo  level="verbose"  message="webapps      = ${webapps}"/>
    <property   name="destfile"    location="${webapps}/example.war"/>
    <echo  level="verbose"  message="destfile     = ${destfile}"/>
    
  </target>
  
  
  <!--
      -  Verify that the source folders of the WorkArea exist.
      -  Each path includes only a folder of the Workarea.
   -->
  <target  name="pathBasedir"  depends="init"  if="basedir">
    
    <property       name="config"    location="config"/>
    <available  property="configOK"  type="dir"  file="${config}"/>
    <fail  unless="configOK"
           message=" *****  Folder  '${config}'  NOT found  *****"/>
    <echo  level="verbose"  message="config     = ${config}"/>
    
    <property       name="appli"    location="${webapps}/myAppli"/>
    <available  property="appliOK"  type="dir"  file="${appli}"/>
    <fail  unless="appliOK"
           message=" *****  Folder  '${appli}'  NOT found  *****"/>
    <echo  level="verbose"  message="appli      = ${appli}"/>
    
    <path  id="configPath">
      <pathelement  location="${config}"/>
    </path>       
    
  </target>
  
  
  <!--
      Search 'WEB-INF/web.xml' in the Workarea.
   -->
  <target  name="webXmlBasedir"  if="basedir"
           depends="pathBasedir">
    
    <available  property="web.xml"  type="file"
                    file="${appli}/WEB-INF/web.xml"
                   value="${appli}/WEB-INF/web.xml"/>
    
  </target>
  
  
  <!--
      If the WorkArea points to a Baseline :
      -  Verify that the source folders of the Baseline exist.
      -  Each path includes a folder of the Workarea and the corresponding
         folder of the Baseline.
   -->
  <target  name="pathSp1"  depends="init"  if="sp1">
       
    <property       name="config1"    location="${sp1}/config"/>
    <available  property="config1OK"  type="dir"  file="${config1}"/>
    <fail  unless="config1OK"
           message=" *****  Folder  '${config1}'  NOT found  *****"/>
    <echo  level="verbose"  message="config1     = ${config1}"/>
    
    <property       name="appli1"  location="${sp1}/${webapps}/myAppli"/>
    <available  property="appli1OK"  type="dir"  file="${appli1}"/>
    <fail  unless="appli1OK"
           message=" *****  Folder  '${appli1}'  NOT found  *****"/>
    <echo  level="verbose"  message="appli1      = ${appli1}"/>
    
    <path  id="configPath">
      <pathelement  location="${config}"/>
      <pathelement  location="${config1}"/>
    </path>       
    
  </target>
  
  
  <!--
      If the WorkArea points to a Baseline and 'WEB-INF/web.xml'
      was NOT found in the WorkArea, search it in the Baseline.
   -->
  <target  name="webXmlSp1"  if="sp1"  unless="web.xml"
           depends="webXmlBasedir,pathSp1">
    
    <available  property="web.xml"  type="file"
                    file="${appli1}/WEB-INF/web.xml"
                   value="${appli1}/WEB-INF/web.xml"/>
    
  </target>
  
  
  <!--
      If the pointed Baseline points to another Baseline :
      -  Verify that the source folders of the other Baseline exist.
      -  Each path includes a folder of the Workarea and the corresponding
         folder of both Baselines.
   -->
  <target  name="pathSp2"  depends="init"  if="sp2">
       
    <property       name="config2"    location="${sp2}/config"/>
    <available  property="config2OK"  type="dir"  file="${config2}"/>
    <fail  unless="config2OK"
           message=" *****  Folder  '${config2}'  NOT found  *****"/>
    <echo  level="verbose"  message="config2     = ${config2}"/>
    
    <property       name="appli2"  location="${sp2}/${webapps}/myAppli"/>
    <available  property="appli2OK"  type="dir"  file="${appli2}"/>
    <fail  unless="appli2OK"
           message=" *****  Folder  '${appli2}'  NOT found  *****"/>
    <echo  level="verbose"  message="appli2      = ${appli2}"/>
    
    <path  id="configPath">
      <pathelement  location="${config}"/>
      <pathelement  location="${config1}"/>
      <pathelement  location="${config2}"/>
    </path>       
    
  </target>
  
  
  <!--
      If the pointed Baseline points to another Baseline and
      'WEB-INF/web.xml' was NOT found in the WorkArea or in the
      Baseline, search it in the other Baseline.
   -->
  <target  name="webXmlSp2"  if="sp2"  unless="web.xml"
           depends="webXmlBasedir,webXmlSp1,pathSp2">
    
    <available  property="web.xml"  type="file"
                 file="${appli2}/WEB-INF/web.xml"
                value="${appli2}/WEB-INF/web.xml"/>
    
  </target>
  
  
  <!--
      Verify that 'WEB-INF/web.xml', each required Java library and
      properties file exists in its precise folder
   -->
  <target  name="verifyFiles"
           depends="  pathBasedir,   pathSp1,   pathSp2,
                    webXmlBasedir, webXmlSp1, webXmlSp2">
    
    <fail  unless="web.xml"
           message=" *****  'web.xml' not found  *****"/>
    <echo  level="verbose"  message="web.xml = ${web.xml}"/>
    
    <available  property="client.properties"  file="client.properties">
      <filepath refid="configPath"/>
    </available>
    <fail  unless="client.properties"
           message=" *****  'client.properties' not found  *****"/>
    
  </target>
  
  
  <!--
      If the WorkArea does NOT point to a Baseline :
      Generation of the 'war' file from the WorkArea only
   -->
  <target  name="exampleBaseDir"  unless="sp1"
           depends="verifyFiles">
    
    <war  destfile="${destfile}"  duplicate="preserve"
          webxml="${web.xml}">
      <zipfileset  filemode="644"  prefix="WEB-INF"  dir="${config}">
        <include  name="client.properties"/>
      </zipfileset>
    </war>
    
  </target>
  
  
  <!--
      If the WorkArea points to a Baseline :
      Generation of the 'war' file from the WorkArea and the pointed Baseline
   -->
  <target  name="exampleSp1"  if="sp1"  unless="sp2"
           depends="verifyFiles">
    
    <war  destfile="${destfile}"  duplicate="preserve"
          webxml="${web.xml}">
      <zipfileset  filemode="644"  prefix="WEB-INF"  dir="${config}">
        <include  name="client.properties"/>
      </zipfileset>
      <zipfileset  filemode="644"  prefix="WEB-INF"  dir="${config1}">
        <include  name="client.properties"/>
      </zipfileset>
    </war>
    
  </target>
  
  
  <!--
      If the pointed Baseline points to another Baseline :
      Generation of the 'war' file from the WorkArea and both Baselines
   -->
  <target  name="exampleSp2"  if="sp2"
           depends="verifyFiles">
    
    <war  destfile="${destfile}"  duplicate="preserve"
          webxml="${web.xml}">
      
      <zipfileset  prefix="WEB-INF"  dir="${config}">
        <include  name="client.properties"/>
      </zipfileset>
      <zipfileset  prefix="WEB-INF"  dir="${config1}">
        <include  name="client.properties"/>
      </zipfileset>
      <zipfileset  prefix="WEB-INF"  dir="${config2}">
        <include  name="client.properties"/>
      </zipfileset>
    </war>
    
  </target>
  
  
  <!--
      Generation of the 'war' file
   -->
  <target  name="exampleWar"  depends="exampleBaseDir,
                                       exampleSp1,
                                       exampleSp2"/>
  
  
  <!--
      Deletion of the 'war' file
   -->
  <target  name="clean">
    <delete  file="${destfile}"/>
  </target>
  
  
</project>

Reply via email to