|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.Project net.sf.fikin.ant.EmbeddedAntProject
public class EmbeddedAntProject
Some times one would like to have an Ant Project (backed by some build.xml file) available into a custom java application. Embedding Ant is not strainght formward if one would like to take into account logging and build.xml initialization. For all such cases this class was made for.
This class provides:
Example:
ClassLoader cl = this.getClass().getClassLoader();
InputStream in = cl.getResourceAsStream( "some build.xml in classpath" );
EmbeddedAntProject prj = new EmbeddedAntProject( binFile, "build-1.xml", in );
prj.init();
prj.executeTarget( prj.getDefaultTarget() );
prj.setMessageLevel( Project.MSG_DEBUG );
prj.executeTarget( "new-target" );
String[][] params = new String[][] {
{ "property1", "value1" },
{ "property2", "value2" }
};
prj.executeTarget( "target2", params );
...
created on Aug 9, 2006
Nested Class Summary | |
---|---|
class |
EmbeddedAntProject.NonClosingPS
this is a print stream but non-closing handy when playing with tasks which happen to close stdout. |
Field Summary |
---|
Fields inherited from class org.apache.tools.ant.Project |
---|
JAVA_1_0, JAVA_1_1, JAVA_1_2, JAVA_1_3, JAVA_1_4, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, TOKEN_END, TOKEN_START |
Constructor Summary | |
---|---|
EmbeddedAntProject(java.io.File buildFile)
Instantiate a new Ant project with given build file |
|
EmbeddedAntProject(java.io.File baseDir,
java.lang.String buildFileName,
java.io.InputStream buildFileContent)
Instantiate a new Ant project with given file name and content |
Method Summary | |
---|---|
void |
executeTarget(java.lang.String target)
execute given target |
void |
executeTarget(java.lang.String target,
java.lang.String[][] params)
new method execute given target with supplied properties |
void |
init()
Initialize Ant project and make it ready for execution of targets. |
protected java.io.File |
makeItARealFile(java.io.InputStream in)
copy the stream to a temp file this is a hack until more time avail for a diff solution |
void |
setMessageLevel(int level)
set logging level for the default logger |
Methods inherited from class org.apache.tools.ant.Project |
---|
addBuildListener, addDataTypeDefinition, addFilter, addOrReplaceTarget, addOrReplaceTarget, addReference, addTarget, addTarget, addTaskDefinition, checkTaskClass, copyFile, copyFile, copyFile, copyFile, copyFile, copyFile, copyFile, copyFile, copyInheritedProperties, copyUserProperties, createClassLoader, createDataType, createTask, defaultInput, demuxFlush, demuxInput, demuxOutput, executeSortedTargets, executeTargets, fireBuildFinished, fireBuildStarted, fireMessageLogged, fireMessageLogged, fireMessageLogged, fireSubBuildFinished, fireSubBuildStarted, fireTargetFinished, fireTargetStarted, fireTaskFinished, fireTaskStarted, getBaseDir, getBuildListeners, getCoreLoader, getDataTypeDefinitions, getDefaultInputStream, getDefaultTarget, getDescription, getElementName, getExecutor, getFilters, getGlobalFilterSet, getInputHandler, getJavaVersion, getName, getProperties, getProperty, getReference, getReferences, getTargets, getTaskDefinitions, getThreadTask, getUserProperties, getUserProperty, initSubProject, isKeepGoingMode, log, log, log, log, registerThreadTask, removeBuildListener, replaceProperties, resolveFile, resolveFile, setBaseDir, setBasedir, setCoreLoader, setDefault, setDefaultInputStream, setDefaultTarget, setDescription, setExecutor, setFileLastModified, setInheritedProperty, setInputHandler, setJavaVersionProperty, setKeepGoingMode, setName, setNewProperty, setProjectReference, setProperty, setSystemProperties, setUserProperty, toBoolean, topoSort, topoSort, topoSort, translatePath |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EmbeddedAntProject(java.io.File buildFile) throws org.apache.tools.ant.BuildException
buildFile
-
org.apache.tools.ant.BuildException
public EmbeddedAntProject(java.io.File baseDir, java.lang.String buildFileName, java.io.InputStream buildFileContent) throws org.apache.tools.ant.BuildException
baseDir
- buildFileName
- buildFileContent
-
org.apache.tools.ant.BuildException
Method Detail |
---|
public void init() throws org.apache.tools.ant.BuildException
init
in class org.apache.tools.ant.Project
org.apache.tools.ant.BuildException
protected java.io.File makeItARealFile(java.io.InputStream in) throws org.apache.tools.ant.BuildException
in
-
java.io.IOException
org.apache.tools.ant.BuildException
public void setMessageLevel(int level)
level
- as defined by Project.MSG_? constantspublic void executeTarget(java.lang.String target) throws org.apache.tools.ant.BuildException
executeTarget
in class org.apache.tools.ant.Project
java.io.FileNotFoundException
org.apache.tools.ant.BuildException
public void executeTarget(java.lang.String target, java.lang.String[][] params) throws org.apache.tools.ant.BuildException
java.io.FileNotFoundException
org.apache.tools.ant.BuildException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |