forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject cvs commit: xml-forrest/tools/ant/bin ant ant.bat antRun antRun.bat antRun.pl build.xml complete-ant-cmd.pl lcp.bat runant.pl runant.py
Date Wed, 30 Oct 2002 09:08:27 GMT
jefft       2002/10/30 01:08:27

  Added:       tools/ant/bin ant ant.bat antRun antRun.bat antRun.pl
                        build.xml complete-ant-cmd.pl lcp.bat runant.pl
                        runant.py
  Log:
  Ant 1.6-dev (2002-10-29) scripts
  
  Revision  Changes    Path
  1.3       +130 -50   xml-forrest/tools/ant/bin/ant
  
  
  
  
  1.3       +96 -97    xml-forrest/tools/ant/bin/ant.bat
  
  
  
  
  1.3       +4 -1      xml-forrest/tools/ant/bin/antRun
  
  
  
  
  1.3       +31 -20    xml-forrest/tools/ant/bin/antRun.bat
  
  
  
  
  1.1                  xml-forrest/tools/ant/bin/antRun.pl
  
  Index: antRun.pl
  ===================================================================
  #!/usr/bin/perl
  #######################################################################
  #
  # antRun.pl
  #
  # wrapper script for invoking commands on a platform with Perl installed
  # this is akin to antRun.bat, and antRun the SH script 
  #
  # created:         2001-10-18
  # last modified:   2001-11-13
  # author:          Jeff Tulley jtulley@novell.com 
  #######################################################################
  #be fussy about variables
  use strict;
  
  #turn warnings on during dev; generates a few spurious uninitialised var access warnings
  #use warnings;
  
  #and set $debug to 1 to turn on trace info (currently unused)
  my $debug=1;
  
  #######################################################################
  # change drive and directory to "%1"
  my $ANT_RUN_CMD = @ARGV[0];
  
  # assign current run command to "%2"
  chdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n";
  if ($^O eq "NetWare") {
      # There is a bug in Perl 5 on NetWare, where chdir does not
      # do anything.  On NetWare, the following path-prefixed form should 
      # always work. (afaict)
      $ANT_RUN_CMD .= "/".@ARGV[1];
  }
  else {
      $ANT_RUN_CMD = @ARGV[1];
  }
  
  # dispose of the first two arguments, leaving only the command's args.
  shift;
  shift;
  
  # run the command
  my $returnValue = system $ANT_RUN_CMD, @ARGV;
  if ($returnValue eq 0) {
      exit 0;
  }
  else {
      # only 0 and 1 are widely recognized as exit values
      # so change the exit value to 1
      exit 1;
  }
  
  
  
  1.1                  xml-forrest/tools/ant/bin/build.xml
  
  Index: build.xml
  ===================================================================
  <project default="validate-v11" basedir="." name="Doc Transition Trial: validate v1.1">
  
    <target name="validate-v11">
  
      <property name="resources.dir" value="/home/jeff/apache/xml/xml-forrest/src/resources"/>
      <property name="v11.dir" value="/home/jeff/apache/xml/xml-forrest/src/documentation/content/xdocs"/>
  
      <echo message="Validating v11 xdocs ..."/>
      <xmlvalidate failonerror="yes" 
        lenient="no" 
        warn="yes"
  	  >
  	  <!--
  	  classname="org.apache.xerces.parsers.SAXParser" 
  	  -->
        <fileset dir="${v11.dir}" includes="*.xml" excludes="book.xml"/>
        <xmlcatalog>
          <catalogfiles dir="${resources.dir}/schema">
              <include name="catalog" />
          </catalogfiles>
        </xmlcatalog>
      </xmlvalidate>
  
    </target>
  </project>
  
  <!-- End of file -->
  
  
  
  1.1                  xml-forrest/tools/ant/bin/complete-ant-cmd.pl
  
  Index: complete-ant-cmd.pl
  ===================================================================
  #!/usr/bin/perl
  #
  #   Copyright (c) 2001 The Apache Software Foundation.  All rights
  #   reserved.
  #
  # A script to allow Bash or Z-Shell to complete an Ant command-line.  
  #
  # To install for Bash 2.0 or better, add the following to ~/.bashrc:
  # 
  #     $ complete -C complete-ant-cmd ant build.sh
  #
  # To install for Z-Shell 2.5 or better, add the following to ~/.zshrc:
  #
  #     function ant_complete () {
  #         local args_line args
  #         read -l args_line
  #         set -A args $args_line
  #         set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1)
  #     }
  #     compctl -K ant_complete ant build.sh
  #     
  # @author Mike Williams <mikew@cortexebusiness.com.au>
  
  my $cmdLine = $ENV{'COMP_LINE'};
  my $antCmd = $ARGV[0];
  my $word = $ARGV[1];
  
  my @completions;
  if ($word =~ /^-/) {
      list( restrict( $word, getArguments() ));
  } elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) {
      list( getBuildFiles($word) );
  } else {
      list( restrict( $word, getTargets() ));
  }
  
  exit(0);
  
  sub list {
      for (@_) {
          print "$_\n";
      }
  }
  
  sub restrict {
      my ($word, @completions) = @_;
      grep( /^\Q$word\E/, @completions );
  }
  
  sub getArguments {
      qw(-buildfile -debug -emacs -f -find -help -listener -logfile 
         -logger -projecthelp -quiet -verbose -version); 
  }
  
  
  sub getBuildFiles {
      my ($word) = @_;
      grep( /\.xml$/, glob( "$word*" ));
  }
  
  sub getTargets {
  
      # Look for build-file
      my $buildFile = 'build.xml';
      if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) {
          $buildFile = $2;
      }
      return () unless (-f $buildFile);
  
      # Run "ant -projecthelp" to list targets.  Keep a cache of results in a
      # cache-file.
      my $cacheFile = $buildFile;
      $cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
      if ((!-e $cacheFile) || (-M $buildFile) < (-M $cacheFile)) {
          open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
          open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return(); 
          my %targets;
          while( <HELP> ) {
              if (/^\s+(\S+)/) {
                  $targets{$1}++;
              }
          }
          my @targets = sort keys %targets;
          for (@targets) { print CACHE "$_\n"; }
          return @targets;
      }
      
      # Read the target-cache
      open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n";
      my @targets;
      while (<CACHE>) {
          chop;
          s/\r$//;  # for Cygwin
          push( @targets, $_ );
      }
      close( CACHE );
      @targets;
  
  }
  
  
  
  
  
  
  1.3       +16 -2     xml-forrest/tools/ant/bin/lcp.bat
  
  
  
  
  1.3       +37 -6     xml-forrest/tools/ant/bin/runant.pl
  
  
  
  
  1.1                  xml-forrest/tools/ant/bin/runant.py
  
  Index: runant.py
  ===================================================================
  #!/usr/bin/python
  """
  
   runant.py
  
  	This script is a translation of the runant.pl written by Steve Loughran.
  	It runs ant with/out arguments, it should be quite portable (thanks to
  	the python os library)
  	This script has been tested with Python2.0/Win2K
  
          Copyright (c) 2001 The Apache Software Foundation.  All rights
          reserved.
  
   created:         2001-04-11
   author:          Pierre Dittgen pierre.dittgen@criltelecom.com
  
   Assumptions:
  
   - the "java" executable/script is on the command path
   - ANT_HOME has been set
  """
  import os, os.path, string, sys
  
  # Change it to 1 to get extra debug information
  debug = 0
  
  #######################################################################
  #
  # check to make sure environment is setup
  #
  if not os.environ.has_key('ANT_HOME'):
  	print '\n\nANT_HOME *MUST* be set!\n\n'
  	sys.exit(1)
  else:
  	ANT_HOME = os.environ['ANT_HOME']
  
  if not os.environ.has_key('JAVACMD'):
  	JAVACMD = 'java'
  else:
  	JAVACMD = os.environ['JAVACMD']
  
  # Sets the separator char for CLASSPATH
  SEPARATOR = ':'
  if os.name == 'dos' or os.name == 'nt':
  	SEPARATOR = ';'
  
  # Build up standard classpath
  localpath = ''
  if os.environ.has_key('CLASSPATH'):
  	localpath = os.environ['CLASSPATH']
  else:
  	if debug:
  		print 'Warning: no initial classpath\n'
  
  # Add jar files
  LIBDIR = os.path.join(ANT_HOME, 'lib')
  jarfiles = []
  for file in os.listdir(LIBDIR):
  	if file[-4:] == '.jar':
  		jarfiles.append(os.path.join(LIBDIR,file))
  if debug:
  	print 'Jar files:'
  	for jar in jarfiles:
  		print jar
  localpath = localpath + SEPARATOR + string.join(jarfiles, SEPARATOR)
  
  # If JAVA_HOME is defined, look for tools.jar & classes.zip
  # and add to classpath
  if os.environ.has_key('JAVA_HOME') and os.environ['JAVA_HOME'] != '':
  	JAVA_HOME = os.environ['JAVA_HOME']
  	TOOLS = os.path.join(JAVA_HOME, os.path.join('lib', 'tools.jar'))
  	if os.path.exists(TOOLS):
  		localpath = localpath + SEPARATOR + TOOLS
  	CLASSES = os.path.join(JAVA_HOME, os.path.join('lib', 'classes.zip'))
  	if os.path.exists(CLASSES):
  		localpath = localpath + SEPARATOR + CLASSES
  else:
  	print '\n\nWarning: JAVA_HOME environment variable is not set.\n', \
  		'If the build fails because sun.* classes could not be found\n', \
  		'you will need to set the JAVA_HOME environment variable\n', \
  		'to the installation directory of java\n'
  
  # Jikes
  ANT_OPTS = []
  if os.environ.has_key('ANT_OPTS'):
  	ANT_OPTS = string.split(os.environ['ANT_OPTS'])
  if os.environ.has_key('JIKESPATH'):
  	ANT_OPTS.append('-Djikes.class.path=' + os.environ['JIKESPATH'])
  
  # Builds the commandline
  cmdline = '%s -classpath %s -Dant.home=%s %s org.apache.tools.ant.Main %s' \
  	 % (JAVACMD, localpath, ANT_HOME, string.join(ANT_OPTS,' '), \
  	 	string.join(sys.argv[1:], ' '))
  
  if debug:
  	print '\n%s\n\n' % (cmdline)
  
  # Run the biniou!
  os.system(cmdline)
  
  
  

Mime
View raw message