ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: ant/src/script ant
Date Tue, 23 Sep 2003 15:40:36 GMT
conor       2003/09/23 08:40:36

  Modified:    .        Tag: ANT_16_BRANCH build.sh
               src/main/org/apache/tools/ant/launch Tag: ANT_16_BRANCH
                        Launcher.java
               src/script Tag: ANT_16_BRANCH ant
  Log:
  Add support for multiple -lib options. Also allow -lib to specify
  a directory of jars rather than just the directory itself. Update
  build.sh to use this. Unix only for now. Windows later.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.35.2.1  +1 -26     ant/build.sh
  
  Index: build.sh
  ===================================================================
  RCS file: /home/cvs/ant/build.sh,v
  retrieving revision 1.35
  retrieving revision 1.35.2.1
  diff -u -w -u -r1.35 -r1.35.2.1
  --- build.sh	11 Aug 2003 13:18:19 -0000	1.35
  +++ build.sh	23 Sep 2003 15:40:36 -0000	1.35.2.1
  @@ -28,31 +28,6 @@
     exit
   fi
   
  -LOCALCLASSPATH=
  -# add in the dependency .jar files
  -DIRLIBS=lib/optional/*.jar
  -for i in ${DIRLIBS}
  -do
  -    if [ "$i" != "${DIRLIBS}" ] ; then
  -        LOCALCLASSPATH=$LOCALCLASSPATH:"$i"
  -    fi
  -done
  -
  -# make sure the classpath is in unix format
  -if $cygwin ; then
  -    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  -fi
  -
  -CLASSPATH=$LOCALCLASSPATH:$CLASSPATH
  -
  -# switch back to Windows format
  -if $cygwin ; then
  -    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  -fi
  -
  -export CLASSPATH
  -
  -
   if [ "$REALANTHOME" != "" ] ; then
     if $cygwin; then
        REALANTHOME=`cygpath --path --windows "$REALANTHOME"`
  @@ -62,5 +37,5 @@
     ANT_INSTALL="-emacs"
   fi
   
  -bootstrap/bin/ant "$ANT_INSTALL" $*
  +bootstrap/bin/ant -lib lib/optional "$ANT_INSTALL" $*
   
  
  
  
  No                   revision
  No                   revision
  1.5.2.2   +45 -30    ant/src/main/org/apache/tools/ant/launch/Launcher.java
  
  Index: Launcher.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/launch/Launcher.java,v
  retrieving revision 1.5.2.1
  retrieving revision 1.5.2.2
  diff -u -w -u -r1.5.2.1 -r1.5.2.2
  --- Launcher.java	22 Sep 2003 21:15:41 -0000	1.5.2.1
  +++ Launcher.java	23 Sep 2003 15:40:36 -0000	1.5.2.2
  @@ -58,6 +58,10 @@
   import java.net.MalformedURLException;
   import java.io.File;
   import java.util.StringTokenizer;
  +import java.util.List;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +
   
   /**
    *  This is a launcher for Ant.
  @@ -118,37 +122,48 @@
               throw new IllegalStateException("Ant home is set incorrectly or "
                   + "ant could not be located");
           }
  -        String libPath = "";
  -        String[] newargs = null;
  -        int argcount = -1;
  -        for (argcount = 0; argcount < args.length -1; argcount++) {
  -            if (args[argcount].equals("-lib")) {
  -                libPath = args[argcount + 1];
  -                break;
  -            }
  +
  +        List libPaths = new ArrayList();
  +        List argList = new ArrayList();
  +        String[] newArgs;
  +
  +        for (int i = 0; i < args.length; ++i) {
  +            if (args[i].equals("-lib")) {
  +                if (i == args.length - 1) {
  +                    throw new IllegalStateException("The -lib argument must "
  +                        + "be followed by a library location");
           }
  -        if (libPath.equals("")) {
  -           newargs = new String[args.length];
  -           System.arraycopy(args, 0, newargs, 0, args.length);
  +                libPaths.add(args[++i]);
           } else {
  -            newargs = new String[args.length - 2];
  -            // copy the beginning of the args array
  -            if (argcount > 0 ) {
  -                System.arraycopy(args, 0, newargs, 0 ,argcount);
  -            }
  -            // copy the end of the args array
  -            if ((argcount + 2 < args.length) && argcount > 0) {
  -                System.arraycopy(args, argcount + 2, newargs, argcount, args.length - (argcount
+ 2));
  +                argList.add(args[i]);
               }
           }
  -        StringTokenizer myTokenizer = new StringTokenizer(libPath, System.getProperty("path.separator"));
  -        URL[] classPathJars = new URL[myTokenizer.countTokens()];
  -        int classPathJarCount = 0;
  +
  +        if (libPaths.size() == 0) {
  +            newArgs = args;
  +        } else {
  +            newArgs = (String[]) argList.toArray(new String[0]);
  +        }
  +
  +        List libPathURLs = new ArrayList();
  +        for (Iterator i = libPaths.iterator(); i.hasNext();) {
  +            String libPath = (String) i.next();
  +            StringTokenizer myTokenizer
  +                = new StringTokenizer(libPath, System.getProperty("path.separator"));
           while (myTokenizer.hasMoreElements()) {
  -            String token = myTokenizer.nextToken();
  -            classPathJars[classPathJarCount++] = new File(token).toURL();
  +                File element = new File(myTokenizer.nextToken());
  +                if (element.isDirectory()) {
  +                    // add any jars in the directory
  +                    URL[] dirURLs = Locator.getLocationURLs(element);
  +                    for (int j = 0; j < dirURLs.length; ++j) {
  +                        libPathURLs.add(dirURLs[j]);
  +                    }
  +                }
  +                libPathURLs.add(element.toURL());
  +            }
           }
   
  +        URL[] libJars = (URL[])libPathURLs.toArray(new URL[0]);
   
           // Now try and find JAVA_HOME
           File toolsJar = Locator.getToolsJar();
  @@ -160,14 +175,14 @@
           URL[] userJars = Locator.getLocationURLs(userLibDir);
   
   
  -        int numJars = classPathJars.length + userJars.length + systemJars.length;
  +        int numJars = libJars.length + userJars.length + systemJars.length;
           if (toolsJar != null) {
               numJars++;
           }
           URL[] jars = new URL[numJars];
  -        System.arraycopy(classPathJars, 0, jars, 0, classPathJars.length);
  -        System.arraycopy(userJars, 0, jars, classPathJars.length, userJars.length);
  -        System.arraycopy(systemJars, 0, jars, userJars.length + classPathJars.length,
  +        System.arraycopy(libJars, 0, jars, 0, libJars.length);
  +        System.arraycopy(userJars, 0, jars, libJars.length, userJars.length);
  +        System.arraycopy(systemJars, 0, jars, userJars.length + libJars.length,
               systemJars.length);
   
           if (toolsJar != null) {
  @@ -191,7 +206,7 @@
           try {
               Class mainClass = loader.loadClass(MAIN_CLASS);
               AntMain main = (AntMain) mainClass.newInstance();
  -            main.startAnt(newargs, null, null);
  +            main.startAnt(newArgs, null, null);
           } catch (Throwable t) {
               t.printStackTrace();
           }
  
  
  
  No                   revision
  No                   revision
  1.38.2.2  +4 -7      ant/src/script/ant
  
  Index: ant
  ===================================================================
  RCS file: /home/cvs/ant/src/script/ant,v
  retrieving revision 1.38.2.1
  retrieving revision 1.38.2.2
  diff -u -w -u -r1.38.2.1 -r1.38.2.2
  --- ant	22 Sep 2003 21:15:41 -0000	1.38.2.1
  +++ ant	23 Sep 2003 15:40:36 -0000	1.38.2.2
  @@ -71,8 +71,6 @@
       ANT_HOME=`cygpath --unix "$ANT_HOME"`
     [ -n "$JAVA_HOME" ] &&
       JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  -  [ -n "$CLASSPATH" ] &&
  -    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
   fi
   
   # set ANT_LIB location
  @@ -145,21 +143,20 @@
   if $cygwin; then
     ANT_HOME=`cygpath --windows "$ANT_HOME"`
     JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
  -  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
     LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
     CYGHOME=`cygpath --windows "$HOME"`
   fi
   
   if [ -n "$CYGHOME" ]; then
     if [ -n "$JIKESPATH" ]; then
  -    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
-Dcygwin.user.home="$CYGHOME" org.apache.tools.ant.launch.Launcher $ANT_ARGS "$@" -lib "$CLASSPATH"
  +    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
-Dcygwin.user.home="$CYGHOME" org.apache.tools.ant.launch.Launcher $ANT_ARGS -lib "$CLASSPATH"
"$@"
     else
  -    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Dcygwin.user.home="$CYGHOME"
org.apache.tools.ant.launch.Launcher $ANT_ARGS "$@" -lib "$CLASSPATH"
  +    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Dcygwin.user.home="$CYGHOME"
org.apache.tools.ant.launch.Launcher $ANT_ARGS -lib "$CLASSPATH" "$@"
     fi
   else
     if [ -n "$JIKESPATH" ]; then
  -    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
org.apache.tools.ant.launch.Launcher $ANT_ARGS "$@" -lib "$CLASSPATH"
  +    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
org.apache.tools.ant.launch.Launcher $ANT_ARGS -lib "$CLASSPATH" "$@"
     else
  -    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" org.apache.tools.ant.launch.Launcher
$ANT_ARGS "$@" -lib "$CLASSPATH"
  +    exec "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" org.apache.tools.ant.launch.Launcher
$ANT_ARGS -lib "$CLASSPATH" "$@"
     fi
   fi
  
  
  

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


Mime
View raw message