Bloc-Note dédia à Apache ANT.
Un classloader dédié à une tâche ANT
public class TestTask extends Task
{
/** loader class name. */
private String loaderClassName
;
/** classpathref property internal field. */
/** loader instance. */
private DatabaseModelLoader loader;
/**
* getter for the classpathref property.
* @return Returns the classpathref property value.
*/
{
return classpathref;
}
/**
* setter for the classpathref property.
* @param classpathref The classpathref to set.
*/
public void setClasspathRef
(Reference classpathref
)
{
this.classpathref = classpathref;
}
public void execute()
{
loadModules();
try
{
(....)
}
{
e.printStackTrace();
throw new BuildException(e);
}
}
private void loadModules()
{
loader = null;
if (loaderClassName == null)
throw new BuildException("loader can't be null");
try
{
ClassLoader classLoader
= this.
getClass().
getClassLoader();
Class loaderClass = classLoader.loadClass(loaderClassName);
loader = (DatabaseModelLoader) loaderClass.newInstance();
}
{
throw new BuildException(e);
}
}
/**
* setter for the loader class name property.
* @param dialect The dialect to set.
*/
public void setLoader
(String loader
)
{
this.loaderClassName = loader;
}
}
Classpath definition
<!-- Replace "value" with your installation's directory -->
<property name="dependencyfinder.home" value="C:/DependencyFinder"/>
<path id="dependencyfinder">
<pathelement location="${dependencyfinder.home}/classes"/>
<pathelement location="${dependencyfinder.home}/lib/DependencyFinder.jar"/>
<pathelement location="${dependencyfinder.home}/lib/jakarta-oro.jar"/>
<pathelement location="${dependencyfinder.home}/lib/log4j.jar"/>
</path>
<taskdef resource="dependencyfindertasks.properties">
<classpath refid="dependencyfinder"/>
</taskdef>
Erreur "unable to find a javac compiler"
La solution est de prendre le fichier tools.jar qui se trouve dans le dossier lib du jdk et de le copie dans le dossier lib/ext du JRE.
Poster un nouveau commentaire