peterreilly 2005/02/25 10:57:35
Modified: src/main/org/apache/tools/ant Tag: ANT_16_BRANCH Main.java
src/main/org/apache/tools/ant/launch Tag: ANT_16_BRANCH
Launcher.java
Log:
sync up support for -noclasspath and -nouserlib
Revision Changes Path
No revision
No revision
1.95.2.9 +25 -22 ant/src/main/org/apache/tools/ant/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v
retrieving revision 1.95.2.8
retrieving revision 1.95.2.9
diff -u -r1.95.2.8 -r1.95.2.9
--- Main.java 21 Jun 2004 22:15:05 -0000 1.95.2.8
+++ Main.java 25 Feb 2005 18:57:35 -0000 1.95.2.9
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation
+ * Copyright 2000-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
import java.util.Vector;
import org.apache.tools.ant.input.DefaultInputHandler;
import org.apache.tools.ant.input.InputHandler;
-import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.launch.AntMain;
@@ -117,7 +116,7 @@
/**
* optional thread priority
*/
- private Integer threadPriority=null;
+ private Integer threadPriority = null;
/**
* Prints the message of the Throwable if it (the message) is not
@@ -410,18 +409,18 @@
keepGoingMode = true;
} else if (arg.equals("-nice")) {
try {
- threadPriority=Integer.decode(args[i + 1]);
+ threadPriority = Integer.decode(args[i + 1]);
} catch (ArrayIndexOutOfBoundsException aioobe) {
throw new BuildException(
- "You must supply a niceness value (1-10)"+
- " after the -nice option");
+ "You must supply a niceness value (1-10)"
+ + " after the -nice option");
} catch (NumberFormatException e) {
- throw new BuildException("Unrecognized niceness value: "
+
- args[i + 1]);
+ throw new BuildException("Unrecognized niceness value: "
+ + args[i + 1]);
}
i++;
- if(threadPriority.intValue()<Thread.MIN_PRIORITY ||
- threadPriority.intValue()>Thread.MAX_PRIORITY) {
+ if (threadPriority.intValue() < Thread.MIN_PRIORITY
+ || threadPriority.intValue() > Thread.MAX_PRIORITY) {
throw new BuildException(
"Niceness value is out of the range 1-10");
}
@@ -603,17 +602,13 @@
InputStream in = System.in;
// use a system manager that prevents from System.exit()
- // only in JDK > 1.1
SecurityManager oldsm = null;
- if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)
- && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
- oldsm = System.getSecurityManager();
+ oldsm = System.getSecurityManager();
//SecurityManager can not be installed here for backwards
//compatibility reasons (PD). Needs to be loaded prior to
//ant class if we are going to implement it.
//System.setSecurityManager(new NoExitSecurityManager());
- }
try {
if (allowInput) {
project.setDefaultInputStream(System.in);
@@ -631,7 +626,7 @@
if (threadPriority != null) {
try {
project.log("Setting Ant's thread priority to "
- + threadPriority,Project.MSG_VERBOSE);
+ + threadPriority, Project.MSG_VERBOSE);
Thread.currentThread().setPriority(threadPriority.intValue());
} catch (SecurityException swallowed) {
//we cannot set the priority here.
@@ -814,12 +809,15 @@
msg.append(" -quiet, -q be extra quiet" + lSep);
msg.append(" -verbose, -v be extra verbose" + lSep);
msg.append(" -debug, -d print debugging information" +
lSep);
- msg.append(" -emacs, -e produce logging information
without adornments" + lSep);
- msg.append(" -lib <path> specifies a path to search for
jars and classes" + lSep);
+ msg.append(" -emacs, -e produce logging information
without adornments"
+ + lSep);
+ msg.append(" -lib <path> specifies a path to search for
jars and classes"
+ + lSep);
msg.append(" -logfile <file> use given file for log" + lSep);
msg.append(" -l <file> ''" + lSep);
msg.append(" -logger <classname> the class which is to perform
logging" + lSep);
- msg.append(" -listener <classname> add an instance of class as a
project listener" + lSep);
+ msg.append(" -listener <classname> add an instance of class as a
project listener"
+ + lSep);
msg.append(" -noinput do not allow interactive input"
+ lSep);
msg.append(" -buildfile <file> use given buildfile" + lSep);
msg.append(" -file <file> ''" + lSep);
@@ -832,8 +830,12 @@
msg.append(" -inputhandler <class> the class which will handle
input requests" + lSep);
msg.append(" -find <file> (s)earch for buildfile towards
the root of" + lSep);
msg.append(" -s <file> the filesystem and use it" +
lSep);
- msg.append(" -nice number A niceness value for the main
thread:" + lSep +
- " 1 (lowest) to 10 (highest); 5
is the default" + lSep);
+ msg.append(" -nice number A niceness value for the main
thread:" + lSep
+ + " 1 (lowest) to 10 (highest); 5
is the default"
+ + lSep);
+ msg.append(" -nouserlib Run ant without using the jar
files from" + lSep
+ + " ${user.home}/.ant/lib" +
lSep);
+ msg.append(" -noclasspath Run ant without using
CLASSPATH");
System.out.println(msg.toString());
}
@@ -1016,7 +1018,8 @@
msg.append(" ");
msg.append(names.elementAt(i));
if (descriptions != null) {
- msg.append(spaces.substring(0, maxlen - ((String)
names.elementAt(i)).length() + 2));
+ msg.append(
+ spaces.substring(0, maxlen - ((String)
names.elementAt(i)).length() + 2));
msg.append(descriptions.elementAt(i));
}
msg.append(lSep);
No revision
No revision
1.5.2.17 +29 -6 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.16
retrieving revision 1.5.2.17
diff -u -r1.5.2.16 -r1.5.2.17
--- Launcher.java 8 Sep 2004 11:26:00 -0000 1.5.2.16
+++ Launcher.java 25 Feb 2005 18:57:35 -0000 1.5.2.17
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,11 +38,23 @@
/** The Ant Library Directory property */
public static final String ANTLIBDIR_PROPERTY = "ant.library.dir";
+ /** The directory name of the per-user ant directory */
+ public static final String ANT_PRIVATEDIR = ".ant";
+
+ /**
+ * The location of a per-user library directory
+ */
+ public static final String ANT_PRIVATELIB = "lib";
+
/** The location of a per-user library directory */
- public static final String USER_LIBDIR = ".ant/lib";
+ public static final String USER_LIBDIR = ANT_PRIVATEDIR + "/" +
ANT_PRIVATELIB;
/** The startup class that is to be run */
public static final String MAIN_CLASS = "org.apache.tools.ant.Main";
+ /**
+ * system property with user home directory
+ */
+ public static final String USER_HOMEDIR = "user.home";
/**
* Entry point for starting command line Ant
@@ -65,7 +77,7 @@
* @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
+ * @param libPathURLs the list of paths to add to
*/
private void addPath(String path, boolean getJars, List libPathURLs)
throws MalformedURLException {
@@ -122,6 +134,8 @@
String cpString = null;
List argList = new ArrayList();
String[] newArgs;
+ boolean noUserLib = false;
+ boolean noClassPath = false;
for (int i = 0; i < args.length; ++i) {
if (args[i].equals("-lib")) {
@@ -140,11 +154,19 @@
+ "not be repeated");
}
cpString = args[++i];
+ } else if (args[i].equals("--nouserlib") ||
args[i].equals("-nouserlib")) {
+ noUserLib = true;
+ } else if (args[i].equals("--noclasspath") ||
args[i].equals("-noclasspath")) {
+ noClassPath = true;
} else {
argList.add(args[i]);
}
}
+ //decide whether to copy the existing arg set, or
+ //build a new one from the list of all args excluding the special
+ //operations that only we handle
+
if (libPaths.size() == 0 && cpString == null) {
newArgs = args;
} else {
@@ -153,7 +175,7 @@
List libPathURLs = new ArrayList();
- if (cpString != null) {
+ if (cpString != null && !noClassPath) {
addPath(cpString, false, libPathURLs);
}
@@ -181,9 +203,10 @@
URL[] systemJars = Locator.getLocationURLs(antLibDir);
File userLibDir
- = new File(System.getProperty("user.home"), USER_LIBDIR);
- URL[] userJars = Locator.getLocationURLs(userLibDir);
+ = new File(System.getProperty(USER_HOMEDIR),
+ ANT_PRIVATEDIR + File.separatorChar + ANT_PRIVATELIB);
+ URL[] userJars = noUserLib ? new URL[0] :
Locator.getLocationURLs(userLibDir);
int numJars = libJars.length + userJars.length + systemJars.length;
if (toolsJar != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]