AntClassLoader and IntrospectionHelper after the build has finished. This helps applications that run Ant in the same VM over and over again like CruiseControl or wrappers that run Ant in incremental mode. PR: 2568 Submitted by: robert.watkins@qsipayments.com (Robert Watkins) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269316 13f79535-47bb-0310-9956-ffa450edef68master
@@ -70,7 +70,7 @@ import org.apache.tools.ant.types.Path; | |||||
* @author <a href="mailto:conor@cortexebusiness.com.au">Conor MacNeill</a> | * @author <a href="mailto:conor@cortexebusiness.com.au">Conor MacNeill</a> | ||||
* @author <a href="mailto:Jesse.Glick@netbeans.com">Jesse Glick</a> | * @author <a href="mailto:Jesse.Glick@netbeans.com">Jesse Glick</a> | ||||
*/ | */ | ||||
public class AntClassLoader extends ClassLoader { | |||||
public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
/** | /** | ||||
* An enumeration of all resources of a given name found within the | * An enumeration of all resources of a given name found within the | ||||
@@ -228,6 +228,7 @@ public class AntClassLoader extends ClassLoader { | |||||
*/ | */ | ||||
public AntClassLoader(Project project, Path classpath) { | public AntClassLoader(Project project, Path classpath) { | ||||
this.project = project; | this.project = project; | ||||
this.project.addBuildListener(this); | |||||
this.classpath = classpath.concatSystemClasspath("ignore"); | this.classpath = classpath.concatSystemClasspath("ignore"); | ||||
} | } | ||||
@@ -839,4 +840,26 @@ public class AntClassLoader extends ClassLoader { | |||||
return base.loadClass(name); | return base.loadClass(name); | ||||
} | } | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) { | |||||
classpath = null; | |||||
project = null; | |||||
} | |||||
public void targetStarted(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
} | } |
@@ -68,7 +68,7 @@ import java.util.*; | |||||
* | * | ||||
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
*/ | */ | ||||
public class IntrospectionHelper { | |||||
public class IntrospectionHelper implements BuildListener { | |||||
/** | /** | ||||
* holds the types of the attributes that could be set. | * holds the types of the attributes that could be set. | ||||
@@ -552,4 +552,20 @@ public class IntrospectionHelper { | |||||
throws InvocationTargetException, IllegalAccessException, | throws InvocationTargetException, IllegalAccessException, | ||||
BuildException; | BuildException; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) { | |||||
attributeTypes.clear(); | |||||
attributeSetters.clear(); | |||||
nestedTypes.clear(); | |||||
nestedCreators.clear(); | |||||
addText = null; | |||||
helpers.clear(); | |||||
} | |||||
public void targetStarted(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event) {} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
} | } |
@@ -628,6 +628,8 @@ public class ProjectHelper { | |||||
IntrospectionHelper ih = | IntrospectionHelper ih = | ||||
IntrospectionHelper.getHelper(target.getClass()); | IntrospectionHelper.getHelper(target.getClass()); | ||||
project.addBuildListener(ih); | |||||
for (int i = 0; i < attrs.getLength(); i++) { | for (int i = 0; i < attrs.getLength(); i++) { | ||||
// reflect these into the target | // reflect these into the target | ||||
String value=replaceProperties(project, attrs.getValue(i), | String value=replaceProperties(project, attrs.getValue(i), | ||||