Refactored the constants in the launcher for better sharing. I worry about the hard coded file separator there (/), so replaced in the code, but left the constant in, in case someone was using it. Updated WHATSNEW. Added which.jar to the fetchables. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277559 13f79535-47bb-0310-9956-ffa450edef68master
@@ -60,7 +60,7 @@ Other changes: | |||
Bugzilla Report 16539. | |||
* Added -nouserlib option to allow running ant without automatically loading | |||
up ${user.dir}/.lib/ant. This is useful when compiling ant, and antlibs. | |||
up ${user.home}/.lib/ant. This is useful when compiling ant, and antlibs. | |||
Modified the build.sh and build.bat to use the option. | |||
* Added -noclasspath option to allow running ant WITHOUT using CLASSPATH env | |||
@@ -90,6 +90,14 @@ Other changes: | |||
* Add else attribute to the condition task, which specifies an | |||
optional alternate value to set the property to if the nested | |||
condition evaluates to false. Bugzilla report 33074. | |||
* Added <scriptcondition> condition, for inline scripted conditions | |||
* Added <xor> condition for exclusive-or combining of nested conditions. | |||
* Added <scriptselector> selector for scripted file selection | |||
* ant -diagnostics lists contents of ${user.home}/.ant/lib | |||
Changes from Ant 1.6.2 to current Ant 1.6 CVS version | |||
===================================================== | |||
@@ -16,8 +16,8 @@ | |||
and installs them in a location that is accessible the next time Ant runs. | |||
You can choose three locations, by going -Ddest=LOCATION on the command line | |||
-Ddest=user user lib dir ${user.home}/.ant/lib --Default-- | |||
-Ddest=system ant lib dir ${ant.home}/lib | |||
-Ddest=user user lib dir ${user.home}/.ant/lib | |||
-Ddest=system ant lib dir ${ant.home}/lib --Default-- | |||
-Ddest=optional optional dir ${ant.home}/lib/optional (for Ant developers) | |||
You may also need to set proxy settings. This can be done on the command line, | |||
@@ -60,7 +60,10 @@ | |||
<target name="pick-dest"> | |||
<condition property="dest.dir" | |||
value="${lib.dir}"> | |||
<equals arg1="${dest}" arg2="system" /> | |||
<or> | |||
<equals arg1="${dest}" arg2="system" /> | |||
<not><isset property="dest"/></not> | |||
</or> | |||
</condition> | |||
<condition property="dest.dir" | |||
value="${optional.dir}"> | |||
@@ -68,10 +71,7 @@ | |||
</condition> | |||
<condition property="dest.dir" | |||
value="${userlib.dir}"> | |||
<or> | |||
<equals arg1="${dest}" arg2="user" /> | |||
<not><isset property="dest"/></not> | |||
</or> | |||
<equals arg1="${dest}" arg2="user" /> | |||
</condition> | |||
<fail> | |||
Unknown destination : ${dest} | |||
@@ -183,10 +183,16 @@ | |||
description="load bsf libraries" | |||
depends="init"> | |||
<f project="bsf" /> | |||
</target> | |||
</target> | |||
<target name="debugging" | |||
description="internal ant debugging" | |||
depends="init"> | |||
<f project="which" /> | |||
</target> | |||
<target name="all" | |||
description="load all the libraries" | |||
depends="logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf" /> | |||
depends="logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging" /> | |||
</project> |
@@ -15,6 +15,7 @@ log4j.version=1.2.8 | |||
#rhino.version=1.5R5 | |||
oro.version=2.0.8 | |||
regexp.version=1.3 | |||
which.version=1.0 | |||
xerces.version=2.6.2 | |||
xalan.version=2.5.1 | |||
xml-resolver.version=1.1 | |||
@@ -17,6 +17,7 @@ | |||
package org.apache.tools.ant; | |||
import org.apache.tools.ant.util.LoaderUtils; | |||
import org.apache.tools.ant.launch.Launcher; | |||
import javax.xml.parsers.SAXParserFactory; | |||
import javax.xml.parsers.SAXParser; | |||
@@ -95,20 +96,23 @@ public final class Diagnostics { | |||
return null; | |||
} | |||
File libDir = new File(home, "lib"); | |||
return listJarFiles(libDir); | |||
} | |||
/** | |||
* get a list of all JAR files in a directory | |||
* @param libDir directory | |||
* @return array of files (or null for no such directory) | |||
*/ | |||
private static File[] listJarFiles(File libDir) { | |||
FilenameFilter filter = new FilenameFilter() { | |||
public boolean accept(File dir, String name) { | |||
return name.endsWith(".jar"); | |||
} | |||
}; | |||
// listFiles is JDK 1.2+ method... | |||
String[] filenames = libDir.list(filter); | |||
if (filenames == null) { | |||
return null; | |||
} | |||
File[] files = new File[filenames.length]; | |||
for (int i = 0; i < filenames.length; i++) { | |||
files[i] = new File(libDir, filenames[i]); | |||
} | |||
File[] files = libDir.listFiles(filter); | |||
return files; | |||
} | |||
@@ -128,21 +132,8 @@ public final class Diagnostics { | |||
* '?.?' for JDK 1.0 or 1.1. | |||
*/ | |||
private static String getImplementationVersion(Class clazz) { | |||
try { | |||
// Package pkg = clazz.getPackage(); | |||
Method method = Class.class.getMethod("getPackage", new Class[0]); | |||
Object pkg = method.invoke(clazz, (Object[]) null); | |||
if (pkg != null) { | |||
// pkg.getImplementationVersion(); | |||
method = pkg.getClass().getMethod("getImplementationVersion", new Class[0]); | |||
Object version = method.invoke(pkg, (Object[]) null); | |||
return (String) version; | |||
} | |||
} catch (Exception e) { | |||
// JDK < 1.2 should land here because the methods above don't exist. | |||
return "?.?"; | |||
} | |||
return null; | |||
Package pkg = clazz.getPackage(); | |||
return pkg.getImplementationVersion(); | |||
} | |||
/** | |||
@@ -213,7 +204,7 @@ public final class Diagnostics { | |||
out.println(Main.getAntVersion()); | |||
out.println(); | |||
out.println("-------------------------------------------"); | |||
out.println(" Implementation Version (JDK1.2+ only)"); | |||
out.println(" Implementation Version "); | |||
out.println("-------------------------------------------"); | |||
out.println("core tasks : " + getImplementationVersion(Main.class)); | |||
@@ -231,7 +222,13 @@ public final class Diagnostics { | |||
out.println("-------------------------------------------"); | |||
out.println(" ANT_HOME/lib jar listing"); | |||
out.println("-------------------------------------------"); | |||
doReportLibraries(out); | |||
doReportAntHomeLibraries(out); | |||
out.println(); | |||
out.println("-------------------------------------------"); | |||
out.println(" USER_HOME/.ant/lib jar listing"); | |||
out.println("-------------------------------------------"); | |||
doReportUserHomeLibraries(out); | |||
out.println(); | |||
out.println("-------------------------------------------"); | |||
@@ -278,11 +275,34 @@ public final class Diagnostics { | |||
* Report the content of ANT_HOME/lib directory | |||
* @param out the stream to print the content to | |||
*/ | |||
private static void doReportLibraries(PrintStream out) { | |||
private static void doReportAntHomeLibraries(PrintStream out) { | |||
out.println("ant.home: " + System.getProperty("ant.home")); | |||
File[] libs = listLibraries(); | |||
printLibraries(libs, out); | |||
} | |||
/** | |||
* Report the content of ~/.ant/lib directory | |||
* | |||
* @param out the stream to print the content to | |||
*/ | |||
private static void doReportUserHomeLibraries(PrintStream out) { | |||
String home = System.getProperty(Launcher.USER_HOMEDIR); | |||
out.println("user.home: " + home); | |||
File libDir = new File(home, | |||
Launcher.ANT_PRIVATEDIR+File.separator+Launcher.ANT_PRIVATELIB); | |||
File[] libs=listJarFiles(libDir); | |||
printLibraries(libs, out); | |||
} | |||
/** | |||
* list the libraries | |||
* @param libs array of libraries (can be null) | |||
* @param out output stream | |||
*/ | |||
private static void printLibraries(File[] libs, PrintStream out) { | |||
if (libs == null) { | |||
out.println("Unable to list libraries."); | |||
out.println("No such directory."); | |||
return; | |||
} | |||
for (int i = 0; i < libs.length; i++) { | |||
@@ -38,11 +38,22 @@ public class Launcher { | |||
/** The Ant Library Directory property */ | |||
public static final String ANTLIBDIR_PROPERTY = "ant.library.dir"; | |||
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 | |||
@@ -191,7 +202,8 @@ public class Launcher { | |||
URL[] systemJars = Locator.getLocationURLs(antLibDir); | |||
File userLibDir | |||
= new File(System.getProperty("user.home"), USER_LIBDIR); | |||
= new File(System.getProperty(USER_HOMEDIR), | |||
ANT_PRIVATEDIR + File.separatorChar + ANT_PRIVATELIB); | |||
URL[] userJars = noUserLib ? new URL[0] : Locator.getLocationURLs(userLibDir); | |||