ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/launch Launcher.java
Date Mon, 06 Sep 2004 09:14:42 GMT
peterreilly    2004/09/06 02:14:42

  Modified:    .        WHATSNEW
               src/script ant ant.bat
               src/main/org/apache/tools/ant/launch Launcher.java
  Log:
  add a -cp option to Launcher.java to cause it to
  treat CLASSPATH different from -lib options.
  PR: 28046
  
  Revision  Changes    Path
  1.657     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.656
  retrieving revision 1.657
  diff -u -r1.656 -r1.657
  --- WHATSNEW	31 Aug 2004 22:32:51 -0000	1.656
  +++ WHATSNEW	6 Sep 2004 09:14:41 -0000	1.657
  @@ -88,6 +88,8 @@
   
   * Zip task was not zipping when only empty directories were found. Bugzilla 30365.
   
  +* Classpath was treated in the same way as -lib options. Bugzilla 28046.
  +
   Changes from Ant 1.6.1 to Ant 1.6.2
   ===================================
   
  
  
  
  1.50      +2 -2      ant/src/script/ant
  
  Index: ant
  ===================================================================
  RCS file: /home/cvs/ant/src/script/ant,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- ant	6 May 2004 19:43:19 -0000	1.49
  +++ ant	6 Sep 2004 09:14:41 -0000	1.50
  @@ -192,7 +192,7 @@
         LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
       fi
   
  -    # remove class path from launcher -lib option
  +    # remove class path from launcher -cp option
       CLASSPATH=""
     fi
   else
  @@ -295,7 +295,7 @@
       ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
     fi
   fi
  -ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\"
-Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS
-lib \"$CLASSPATH\" $ant_exec_args"
  +ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\"
-Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS
-cp \"$CLASSPATH\" $ant_exec_args"
   if $ant_exec_debug ; then
       echo $ant_exec_command
   fi
  
  
  
  1.38      +2 -2      ant/src/script/ant.bat
  
  Index: ant.bat
  ===================================================================
  RCS file: /home/cvs/ant/src/script/ant.bat,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- ant.bat	28 Jul 2004 19:55:37 -0000	1.37
  +++ ant.bat	6 Sep 2004 09:14:41 -0000	1.38
  @@ -84,7 +84,7 @@
   goto end
   
   :runAntWithClasspath
  -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%"
org.apache.tools.ant.launch.Launcher %ANT_ARGS% -lib "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
  +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%"
org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
   goto end
   
   :runAntWithJikes
  @@ -93,7 +93,7 @@
   goto end
   
   :runAntWithJikesAndClasspath
  -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%"
"-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS%  -lib "%CLASSPATH%"
%ANT_CMD_LINE_ARGS%
  +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%"
"-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS%  -cp "%CLASSPATH%"
%ANT_CMD_LINE_ARGS%
   goto end
   
   :end
  
  
  
  1.19      +46 -19    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Launcher.java	12 Aug 2004 14:44:00 -0000	1.18
  +++ Launcher.java	6 Sep 2004 09:14:42 -0000	1.19
  @@ -60,6 +60,34 @@
           }
       }
   
  +    /**
  +      * Add a CLASSPATH or -lib to lib path urls.
  +      * @param path        the classpath or lib path to add to the libPathULRLs
  +      * @param getJars     if true and a path is a directory, add the jars in
  +      *                    the directory to the path urls
  +      * @param libPathURLS the list of paths to add to
  +      */
  +    private void addPath(String path, boolean getJars, List libPathURLs)
  +        throws MalformedURLException {
  +        StringTokenizer myTokenizer
  +            = new StringTokenizer(path, System.getProperty("path.separator"));
  +        while (myTokenizer.hasMoreElements()) {
  +            String elementName = myTokenizer.nextToken();
  +            File element = new File(elementName);
  +            if (elementName.indexOf("%") != -1 && !element.exists()) {
  +                continue;
  +            }
  +            if (getJars && 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());
  +        }
  +    }
   
       /**
        * Run the launcher to launch Ant
  @@ -91,6 +119,7 @@
           }
   
           List libPaths = new ArrayList();
  +        String cpString = null;
           List argList = new ArrayList();
           String[] newArgs;
   
  @@ -101,38 +130,36 @@
                           + "be followed by a library location");
                   }
                   libPaths.add(args[++i]);
  +            } else if (args[i].equals("-cp")) {
  +                if (i == args.length - 1) {
  +                    throw new LaunchException("The -cp argument must "
  +                        + "be followed by a classpath expression");
  +                }
  +                if (cpString != null) {
  +                    throw new LaunchException("The -cp argument must "
  +                        + "not be repeated");
  +                }
  +                cpString = args[++i];
               } else {
                   argList.add(args[i]);
               }
           }
   
  -        if (libPaths.size() == 0) {
  +        if (libPaths.size() == 0 && cpString == null) {
               newArgs = args;
           } else {
               newArgs = (String[]) argList.toArray(new String[0]);
           }
   
           List libPathURLs = new ArrayList();
  +
  +        if (cpString != null) {
  +            addPath(cpString, false, libPathURLs);
  +        }
  +
           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 elementName = myTokenizer.nextToken();
  -                File element = new File(elementName);
  -                if (elementName.indexOf("%") != -1 && !element.exists()) {
  -                    continue;
  -                }
  -                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());
  -            }
  +            addPath(libPath, true, libPathURLs);
           }
   
           URL[] libJars = (URL[]) libPathURLs.toArray(new URL[0]);
  
  
  

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


Mime
View raw message