Top Description Fields Constructors Methods
org.apache.tools.ant.launch

public Class Launcher

extends Object
Class Inheritance
Imports
java.io.File, java.net.MalformedURLException, .URL, .URLClassLoader, java.util.ArrayList, .List, .StringTokenizer

This is a launcher for Ant.
Since
Ant 1.6

Field Summary

Modifier and TypeField and Description
public static final String
ANT_PRIVATEDIR

The directory name of the per-user ant directory.

public static final String
ANT_PRIVATELIB

The name of a per-user library directory.

public static final String
ANTHOME_PROPERTY

The Ant Home (installation) Directory property.

public static final String
ANTLIBDIR_PROPERTY

The Ant Library Directory property.

protected static final int
EXIT_CODE_ERROR

Exit code on trouble

private static final String
JAVA_CLASS_PATH

System property with application classpath.

public boolean
launchDiag

launch diagnostics flag; for debugging trouble at launch time.

public static final String
MAIN_CLASS

The startup class that is to be run.

public static final String
USER_HOMEDIR

System property with user home directory.

public static final String
USER_LIBDIR

The location of a per-user library directory.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
addPath(final String
the classpath or lib path to add to the libPathULRLs
path
,
final boolean
if true and a path is a directory, add the jars in the directory to the path urls
getJars
,
final List<URL>
the list of paths to add to
libPathURLs
)

Add a CLASSPATH or -lib to lib path urls.

private URL[]

Returns:

a combined array
getJarArray
(final URL[]
the jars specified in -lib command line options
libJars
,
final URL[]
the jars in ~/.ant/lib
userJars
,
final URL[]
the jars in $ANT_HOME/lib
systemJars
,
final File
the tools.jar file
toolsJar
)

Combine the various jar sources into a single array of jars.

private URL[]

Returns:

an array of URLs.
getLibPathURLs
(final String
the classpath string
cpString
,
final List<String>
the list of -lib entries.
libPaths
)

Get the list of -lib entries and -cp entry into a URL array.

private URL[]

Returns:

the URLs
getSystemURLs
(final File
the dir that ant-launcher ran from
antLauncherDir
)

Get the jar files in ANT_HOME/lib.

private URL[]

Returns:

the URLS from the user's lib dir
getUserURLs
()

Get the jar files in user.home/.ant/lib

private void
logPath(final String name, final File path)

public static void
main(final String[]
commandline arguments
args
)

Entry point for starting command line Ant.

private int

Returns:

an exit code. As the normal ant main calls exit when it ends, this is for handling failures at bind-time
run
(final String[]
the command line arguments
args
)

Run the launcher to launch Ant.

private void
setProperty(final String
property name
name
,
final String
value
value
)

set a system property, optionally log what is going on

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ANT_PRIVATEDIRback to summary
public static final String ANT_PRIVATEDIR

The directory name of the per-user ant directory. .ant

ANT_PRIVATELIBback to summary
public static final String ANT_PRIVATELIB

The name of a per-user library directory. lib

ANTHOME_PROPERTYback to summary
public static final String ANTHOME_PROPERTY

The Ant Home (installation) Directory property. ant.home

ANTLIBDIR_PROPERTYback to summary
public static final String ANTLIBDIR_PROPERTY

The Ant Library Directory property. ant.library.dir

EXIT_CODE_ERRORback to summary
protected static final int EXIT_CODE_ERROR

Exit code on trouble

JAVA_CLASS_PATHback to summary
private static final String JAVA_CLASS_PATH

System property with application classpath. java.class.path

launchDiagback to summary
public boolean launchDiag

launch diagnostics flag; for debugging trouble at launch time.

MAIN_CLASSback to summary
public static final String MAIN_CLASS

The startup class that is to be run. org.apache.tools.ant.Main

USER_HOMEDIRback to summary
public static final String USER_HOMEDIR

System property with user home directory. user.home

USER_LIBDIRback to summary
public static final String USER_LIBDIR

The location of a per-user library directory.

It's value is the concatenation of ANT_PRIVATEDIR with ANT_PRIVATELIB, with an appropriate file separator in between. For example, on Unix, it's .ant/lib.

Constructor Detail

Launcherback to summary
private Launcher()

Method Detail

addPathback to summary
private void addPath(final String path, final boolean getJars, final List<URL> libPathURLs) throws MalformedURLException

Add a CLASSPATH or -lib to lib path urls. Only filesystem resources are supported.

Parameters
path:String

the classpath or lib path to add to the libPathULRLs

getJars:boolean

if true and a path is a directory, add the jars in the directory to the path urls

libPathURLs:List<URL>

the list of paths to add to

Exceptions
MalformedURLException:
if we can't create a URL
getJarArrayback to summary
private URL[] getJarArray(final URL[] libJars, final URL[] userJars, final URL[] systemJars, final File toolsJar) throws MalformedURLException

Combine the various jar sources into a single array of jars.

Parameters
libJars:URL[]

the jars specified in -lib command line options

userJars:URL[]

the jars in ~/.ant/lib

systemJars:URL[]

the jars in $ANT_HOME/lib

toolsJar:File

the tools.jar file

Returns:URL[]

a combined array

Exceptions
MalformedURLException:
if there is a problem.
getLibPathURLsback to summary
private URL[] getLibPathURLs(final String cpString, final List<String> libPaths) throws MalformedURLException

Get the list of -lib entries and -cp entry into a URL array.

Parameters
cpString:String

the classpath string

libPaths:List<String>

the list of -lib entries.

Returns:URL[]

an array of URLs.

Exceptions
MalformedURLException:
if the URLs cannot be created.
getSystemURLsback to summary
private URL[] getSystemURLs(final File antLauncherDir) throws MalformedURLException

Get the jar files in ANT_HOME/lib. determine ant library directory for system jars: use property or default using location of ant-launcher.jar

Parameters
antLauncherDir:File

the dir that ant-launcher ran from

Returns:URL[]

the URLs

Exceptions
MalformedURLException:
if the URLs cannot be created.
getUserURLsback to summary
private URL[] getUserURLs() throws MalformedURLException

Get the jar files in user.home/.ant/lib

Returns:URL[]

the URLS from the user's lib dir

Exceptions
MalformedURLException:
if the URLs cannot be created.
logPathback to summary
private void logPath(final String name, final File path)
mainback to summary
public static void main(final String[] args)

Entry point for starting command line Ant.

Parameters
args:String[]

commandline arguments

runback to summary
private int run(final String[] args) throws LaunchException, MalformedURLException

Run the launcher to launch Ant.

Parameters
args:String[]

the command line arguments

Returns:int

an exit code. As the normal ant main calls exit when it ends, this is for handling failures at bind-time

Exceptions
LaunchException:
for launching problems
MalformedURLException:
if the URLs required for the classloader cannot be created.
setPropertyback to summary
private void setProperty(final String name, final String value)

set a system property, optionally log what is going on

Parameters
name:String

property name

value:String

value