ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: Fwd: Re: Patternsets, Filesets, and Mapper
Date Wed, 06 Mar 2002 02:10:05 GMT
--- eoti@mind.net wrote:
> If the scripting is clean, easy, and effecient -- then I am open to
> it...  Otherwise, it would be hard to push Ant as a better solution.

Sorry for the delay -- needed to find a few minutes to work on it.

Anyway, hopefully this is all three of your "ifs", and we can finally put
this puppy to rest:
<project name="malachi" default="genLists">

  <fileset dir="src" id="srcfiles">
    <include name="com/mycompany/util/class1.java"/>
    <include name="com/mycompany/io/class2.java"/>
  </fileset>

  <target name="genLists" depends="setClassList,setPkgList">
    <echo message="classfiles = ${classfiles}"/>
    <echo message="pkglist = ${pkglist}"/>
  </target>

  <target name="setPkgList">
    <pathconvert pathsep="," dirsep="." property="pkgs" refid="srcfiles">
      <map from="${basedir}" to=""/>
    </pathconvert>
    <script language="javascript"> <![CDATA[
      importClass(java.util.StringTokenizer);
      var pkgname;
      var pkglist;
      var pkgnames = malachi.getProperty("pkgs");
      pkgnames = new StringTokenizer(pkgnames, " ,");
      while (pkgnames.hasMoreTokens()) {
        pkg = pkgnames.nextToken();
        pkgname = pkg.substring(0, pkg.indexOf(".java"));
        if(pkgname.startsWith(".src.")) {
          pkgname = pkgname.substring(5);
        }
        if(pkglist == null) {
          pkglist = pkgname;
        } else {
          pkglist = pkglist + pkgname;
        }
        if(pkgnames.hasMoreTokens()) {
          pkglist = pkglist.concat(',');
        }
      }
      malachi.setProperty("pkglist", pkglist);
    ]]></script>
  </target>

  <target name="setClassList">
    <pathconvert pathsep="," property="classes" refid="srcfiles">
      <map from="${basedir}${file.separator}src"
           to="${basedir}${file.separator}build${file.separator}classes"/>
    </pathconvert>
    <script language="javascript"> <![CDATA[
      importClass(java.util.StringTokenizer);
      var classfiles;
      var filename;
      var filenames = malachi.getProperty("classes");
      filenames = new StringTokenizer(filenames, " ,");
      while (filenames.hasMoreTokens()) {
        file = filenames.nextToken();
        filename = file.substring(0, file.indexOf(".java"));
        filename = filename.concat(".class");
        if(classfiles == null) {
          classfiles = filename;
        } else {
          classfiles = classfiles + filename;
        }
        if(filenames.hasMoreTokens()) {
          classfiles = classfiles.concat(',');
        }
      }
      malachi.setProperty("classfiles", classfiles);
    ]]></script>
  </target>

</project>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message