Browse Source

Adding property storing the ant core library.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@388848 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 19 years ago
parent
commit
1e6540e597
4 changed files with 42 additions and 5 deletions
  1. +15
    -0
      src/main/org/apache/tools/ant/Diagnostics.java
  2. +8
    -0
      src/main/org/apache/tools/ant/MagicNames.java
  3. +1
    -2
      src/main/org/apache/tools/ant/Main.java
  4. +18
    -3
      src/main/org/apache/tools/ant/Project.java

+ 15
- 0
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -263,6 +263,9 @@ public final class Diagnostics {
ignoreThrowable(e);
out.println("optional tasks : not available");
}
header(out, "ANT PROPERTIES");
doReportAntProperties(out);

header(out, "ANT_HOME/lib jar listing");
doReportAntHomeLibraries(out);
@@ -328,6 +331,18 @@ public final class Diagnostics {
}
}

/**
* Report the content of ANT_HOME/lib directory
* @param out the stream to print the content to
*/
private static void doReportAntProperties(PrintStream out) {
Project p = new Project();
p.initProperties();
out.println(MagicNames.ANT_VERSION + ": " + p.getProperty(MagicNames.ANT_VERSION));
out.println(MagicNames.ANT_JAVA_VERSION + ": " + p.getProperty(MagicNames.ANT_JAVA_VERSION));
out.println(MagicNames.ANT_LIB + ": " + p.getProperty(MagicNames.ANT_LIB));
out.println(MagicNames.ANT_HOME + ": " + p.getProperty(MagicNames.ANT_HOME));
}

/**
* Report the content of ANT_HOME/lib directory


+ 8
- 0
src/main/org/apache/tools/ant/MagicNames.java View File

@@ -106,14 +106,22 @@ public final class MagicNames {

/**
* Property used to store the java version ant is running in.
* @since Ant 1.7
*/
public static final String ANT_JAVA_VERSION = "ant.java.version";

/**
* Property used to store the location of ant.
* @since Ant 1.7
*/
public static final String ANT_HOME = "ant.home";

/**
* Property used to store the location of the ant library (typically the ant.jar file.)
* @since Ant 1.7
*/
public static final String ANT_LIB = "ant.core.lib";

/**
* property for regular expression implementation.
* Value: {@value}


+ 1
- 2
src/main/org/apache/tools/ant/Main.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2005 The Apache Software Foundation
* Copyright 2000-2006 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.
@@ -638,7 +638,6 @@ public class Main implements AntMain {


project.init();
project.setUserProperty(MagicNames.ANT_VERSION, getAntVersion());

// set user-define properties
Enumeration e = definedProps.keys();


+ 18
- 3
src/main/org/apache/tools/ant/Project.java View File

@@ -193,7 +193,7 @@ public class Project implements ResourceFactory {
* @deprecated
*/
public static final String ANT_JAVA_VERSION = MagicNames.ANT_JAVA_VERSION;
/**
* Set the input handler.
*
@@ -282,14 +282,29 @@ public class Project implements ResourceFactory {
* @exception BuildException if the default task list cannot be loaded.
*/
public void init() throws BuildException {
setJavaVersionProperty();
initProperties();

ComponentHelper.getComponentHelper(this).initDefaultDefinitions();
}

/**
* Initializes the properties.
* @exception BuildException if an vital property could not be set.
* @since Ant 1.7
*/
public void initProperties() throws BuildException {
setJavaVersionProperty();
setSystemProperties();
setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion());
setAntLib();
}


private void setAntLib() {
File antlib = org.apache.tools.ant.launch.Locator.getClassSource(Project.class);
if (antlib != null) {
setPropertyInternal(MagicNames.ANT_LIB, antlib.getAbsolutePath());
}
}
/**
* Factory method to create a class loader for loading classes from
* a given path.


Loading…
Cancel
Save