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:18:50 GMT
peterreilly    2004/09/06 02:18:50

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/script Tag: ANT_16_BRANCH ant ant.bat
               src/main/org/apache/tools/ant/launch Tag: ANT_16_BRANCH
                        Launcher.java
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.132 +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.131
  retrieving revision 1.503.2.132
  diff -u -r1.503.2.131 -r1.503.2.132
  --- WHATSNEW	31 Aug 2004 21:51:49 -0000	1.503.2.131
  +++ WHATSNEW	6 Sep 2004 09:18:50 -0000	1.503.2.132
  @@ -39,6 +39,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
   ===================================
   
  
  
  
  No                   revision
  No                   revision
  1.38.2.7  +2 -2      ant/src/script/ant
  
  Index: ant
  ===================================================================
  RCS file: /home/cvs/ant/src/script/ant,v
  retrieving revision 1.38.2.6
  retrieving revision 1.38.2.7
  diff -u -r1.38.2.6 -r1.38.2.7
  --- ant	11 Jun 2004 21:20:36 -0000	1.38.2.6
  +++ ant	6 Sep 2004 09:18:50 -0000	1.38.2.7
  @@ -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.32.2.5  +2 -2      ant/src/script/ant.bat
  
  Index: ant.bat
  ===================================================================
  RCS file: /home/cvs/ant/src/script/ant.bat,v
  retrieving revision 1.32.2.4
  retrieving revision 1.32.2.5
  diff -u -r1.32.2.4 -r1.32.2.5
  --- ant.bat	9 Feb 2004 22:12:46 -0000	1.32.2.4
  +++ ant.bat	6 Sep 2004 09:18:50 -0000	1.32.2.5
  @@ -83,7 +83,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
  @@ -92,7 +92,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
  
  
  
  No                   revision
  No                   revision
  1.5.2.14  +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.5.2.13
  retrieving revision 1.5.2.14
  diff -u -r1.5.2.13 -r1.5.2.14
  --- Launcher.java	12 Aug 2004 14:32:50 -0000	1.5.2.13
  +++ Launcher.java	6 Sep 2004 09:18:50 -0000	1.5.2.14
  @@ -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