git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272535 13f79535-47bb-0310-9956-ffa450edef68master
@@ -565,21 +565,7 @@ public class Main { | |||||
project.setUserProperty("ant.file", | project.setUserProperty("ant.file", | ||||
buildFile.getAbsolutePath()); | buildFile.getAbsolutePath()); | ||||
// first use the ProjectHelper to create the project object | |||||
// from the given build file. | |||||
String noParserMessage = "No JAXP compliant XML parser found. " | |||||
+ "Please visit http://xml.apache.org " | |||||
+ "for a suitable parser"; | |||||
try { | |||||
Class.forName("javax.xml.parsers.SAXParserFactory"); | |||||
ProjectHelper.configureProject(project, buildFile); | |||||
} catch (NoClassDefFoundError ncdfe) { | |||||
throw new BuildException(noParserMessage, ncdfe); | |||||
} catch (ClassNotFoundException cnfe) { | |||||
throw new BuildException(noParserMessage, cnfe); | |||||
} catch (NullPointerException npe) { | |||||
throw new BuildException(noParserMessage, npe); | |||||
} | |||||
ProjectHelper.configureProject(project, buildFile); | |||||
if (projectHelp) { | if (projectHelp) { | ||||
printDescription(project); | printDescription(project); | ||||
@@ -139,7 +139,7 @@ public class ProjectHelper { | |||||
+ "in a helper plugin " + this.getClass().getName()); | + "in a helper plugin " + this.getClass().getName()); | ||||
} | } | ||||
/** | /** | ||||
* Discovers a project helper instance. Uses the same patterns | * Discovers a project helper instance. Uses the same patterns | ||||
* as JAXP, commons-logging, etc: a system property, a JDK1.3 | * as JAXP, commons-logging, etc: a system property, a JDK1.3 | ||||
@@ -159,14 +159,15 @@ public class ProjectHelper { | |||||
ProjectHelper helper = null; | ProjectHelper helper = null; | ||||
// First, try the system property | // First, try the system property | ||||
String helperClass = System.getProperty(HELPER_PROPERTY); | |||||
try { | try { | ||||
String helperClass = System.getProperty(HELPER_PROPERTY); | |||||
if (helperClass != null) { | if (helperClass != null) { | ||||
helper = newHelper(helperClass); | helper = newHelper(helperClass); | ||||
} | } | ||||
} catch (SecurityException e) { | } catch (SecurityException e) { | ||||
// It's ok, we'll try next option | |||||
; | |||||
System.out.println("Unable to load ProjectHelper class \"" | |||||
+ helperClass + " specified in system property " | |||||
+ HELPER_PROPERTY); | |||||
} | } | ||||
// A JDK1.3 'service' ( like in JAXP ). That will plug a helper | // A JDK1.3 'service' ( like in JAXP ). That will plug a helper | ||||
@@ -203,15 +204,22 @@ public class ProjectHelper { | |||||
} | } | ||||
} | } | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
; | |||||
System.out.println("Unable to load ProjectHelper " | |||||
+ "from service \"" + SERVICE_ID); | |||||
} | } | ||||
} | } | ||||
if (helper != null) { | if (helper != null) { | ||||
return helper; | return helper; | ||||
} else { | } else { | ||||
// Default | |||||
return new ProjectHelperImpl(); | |||||
try { | |||||
// Default | |||||
return new ProjectHelperImpl(); | |||||
} catch (Throwable e) { | |||||
String message = "Unable to load default ProjectHelper due to " | |||||
+ e.getClass().getName() + ": " + e.getMessage(); | |||||
throw new BuildException(message, e); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -71,7 +71,7 @@ import org.xml.sax.helpers.XMLReaderAdapter; | |||||
import javax.xml.parsers.SAXParserFactory; | import javax.xml.parsers.SAXParserFactory; | ||||
import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
import javax.xml.parsers.ParserConfigurationException; | import javax.xml.parsers.ParserConfigurationException; | ||||
import javax.xml.parsers.FactoryConfigurationError; | |||||
import org.apache.tools.ant.ProjectHelper; | import org.apache.tools.ant.ProjectHelper; | ||||
import org.apache.tools.ant.UnknownElement; | import org.apache.tools.ant.UnknownElement; | ||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
@@ -165,6 +165,9 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
parser.parse(inputSource); | parser.parse(inputSource); | ||||
} catch (ParserConfigurationException exc) { | } catch (ParserConfigurationException exc) { | ||||
throw new BuildException("Parser has not been configured correctly", exc); | throw new BuildException("Parser has not been configured correctly", exc); | ||||
} catch (FactoryConfigurationError e) { | |||||
throw new BuildException("XML parser has not been configured " | |||||
+ "correctly: " + e.getMessage(), e); | |||||
} catch (SAXParseException exc) { | } catch (SAXParseException exc) { | ||||
Location location = | Location location = | ||||
new Location(buildFile.toString(), exc.getLineNumber(), | new Location(buildFile.toString(), exc.getLineNumber(), | ||||