Author: bodewig
Date: Tue Jul 21 08:52:12 2009
New Revision: 796188
URL: http://svn.apache.org/viewvc?rev=796188&view=rev
Log:
Allow users to specify a classpath when using a custom adapter in javac, rmic,
javah or native2ascii. PR 11143
Added:
ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml (with
props)
ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml
(with props)
ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml (with props)
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/javac.html
ant/core/trunk/docs/manual/CoreTasks/rmic.html
ant/core/trunk/docs/manual/OptionalTasks/javah.html
ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Rmic.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
ant/core/trunk/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Jul 21 08:52:12 2009
@@ -784,6 +784,11 @@
different executable.
Bugzilla Report 42132.
+ * <javac>, <rmic>, <javah> and <native2ascci> now provide a nested
+ element to specify a classpath that will be used when loading the
+ task's (compiler) adapter class.
+ Bugzilla Issue 11143.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
Modified: ant/core/trunk/docs/manual/CoreTasks/javac.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/javac.html?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javac.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javac.html Tue Jul 21 08:52:12 2009
@@ -509,6 +509,14 @@
</tr>
</table>
+<h4>compilerclasspath <em>since Ant 1.8.0</em></h4>
+
+<p>A <a href="../using.html#path">PATH like structure</a> holding the
+ classpath to use when loading the compiler implementation if a
+ custom class has been specified. Doesn't have any effect when
+ using one of the built-in compilers.</p>
+
+
<h3>Examples</h3>
<pre> <javac srcdir="${src}"
destdir="${build}"
Modified: ant/core/trunk/docs/manual/CoreTasks/rmic.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/rmic.html?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/rmic.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/rmic.html Tue Jul 21 08:52:12 2009
@@ -276,6 +276,13 @@
</tr>
</table>
+<h4>compilerclasspath <em>since Ant 1.8.0</em></h4>
+
+<p>A <a href="../using.html#path">PATH like structure</a> holding the
+ classpath to use when loading the compiler implementation if a
+ custom class has been specified. Doesn't have any effect when
+ using one of the built-in compilers.</p>
+
<h3>Examples</h3>
<pre> <rmic classname="com.xyz.FooBar"
base="${build}/classes"/></pre>
<p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The
Modified: ant/core/trunk/docs/manual/OptionalTasks/javah.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/javah.html?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/javah.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/javah.html Tue Jul 21 08:52:12 2009
@@ -170,6 +170,13 @@
</tr>
</table>
+<h4>implementationclasspath <em>since Ant 1.8.0</em></h4>
+
+<p>A <a href="../using.html#path">PATH like structure</a> holding the
+ classpath to use when loading the compiler implementation if a
+ custom class has been specified. Doesn't have any effect when
+ using one of the built-in compilers.</p>
+
<h3>Examples</h3>
<pre> <javah destdir="c"
class="org.foo.bar.Wibble"/></pre>
<p>makes a JNI header of the named class, using the JDK1.2 JNI model. Assuming
Modified: ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html Tue Jul 21
08:52:12 2009
@@ -183,6 +183,13 @@
</tr>
</table>
+<h4>implementationclasspath <em>since Ant 1.8.0</em></h4>
+
+<p>A <a href="../using.html#path">PATH like structure</a> holding the
+ classpath to use when loading the converter implementation if a
+ custom class has been specified. Doesn't have any effect when
+ using one of the built-in converters.</p>
+
<h3>Examples</h3>
<pre>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java Tue Jul 21
08:52:12 2009
@@ -860,6 +860,16 @@
}
/**
+ * The classpath to use when loading the compiler implementation
+ * if it is not a built-in one.
+ *
+ * @since Ant 1.8.0
+ */
+ public Path createCompilerClasspath() {
+ return facade.getImplementationClasspath(getProject());
+ }
+
+ /**
* Executes the task.
* @exception BuildException if an error occurs
*/
@@ -1067,7 +1077,8 @@
}
CompilerAdapter adapter =
- CompilerAdapterFactory.getCompiler(compilerImpl, this);
+ CompilerAdapterFactory.getCompiler(compilerImpl, this,
+ createCompilerClasspath());
// now we need to populate the compiler adapter
adapter.setJavac(this);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Rmic.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Rmic.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Rmic.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Rmic.java Tue Jul 21
08:52:12 2009
@@ -510,6 +510,16 @@
}
/**
+ * The classpath to use when loading the compiler implementation
+ * if it is not a built-in one.
+ *
+ * @since Ant 1.8.0
+ */
+ public Path createCompilerClasspath() {
+ return facade.getImplementationClasspath(getProject());
+ }
+
+ /**
* execute by creating an instance of an implementation
* class and getting to do the work
* @throws org.apache.tools.ant.BuildException
@@ -528,7 +538,8 @@
if (verify) {
log("Verify has been turned on.", Project.MSG_VERBOSE);
}
- RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this);
+ RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this,
+
createCompilerClasspath());
// now we need to populate the compiler adapter
adapter.setRmic(this);
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
Tue Jul 21 08:52:12 2009
@@ -21,6 +21,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
@@ -63,6 +64,40 @@
*/
public static CompilerAdapter getCompiler(String compilerType, Task task)
throws BuildException {
+ return getCompiler(compilerType, task, null);
+ }
+
+ /**
+ * Based on the parameter passed in, this method creates the necessary
+ * factory desired.
+ *
+ * The current mapping for compiler names are as follows:
+ * <ul><li>jikes = jikes compiler
+ * <li>classic, javac1.1, javac1.2 = the standard compiler from JDK
+ * 1.1/1.2
+ * <li>modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+
+ * <li>jvc, microsoft = the command line compiler from Microsoft's SDK
+ * for Java / Visual J++
+ * <li>kjc = the kopi compiler</li>
+ * <li>gcj = the gcj compiler from gcc</li>
+ * <li>sj, symantec = the Symantec Java compiler</li>
+ * <li><i>a fully qualified classname</i> = the name of a compiler
+ * adapter
+ * </ul>
+ *
+ * @param compilerType either the name of the desired compiler, or the
+ * full classname of the compiler's adapter.
+ * @param task a task to log through.
+ * @param classpath the classpath to use when looking up an
+ * adapter class
+ * @return the compiler adapter
+ * @throws BuildException if the compiler type could not be resolved into
+ * a compiler adapter.
+ * @since Ant 1.8.0
+ */
+ public static CompilerAdapter getCompiler(String compilerType, Task task,
+ Path classpath)
+ throws BuildException {
boolean isClassicCompilerSupported = true;
//as new versions of java come out, add them to this test
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
@@ -133,7 +168,8 @@
|| compilerType.equalsIgnoreCase("symantec")) {
return new Sj();
}
- return resolveClassName(compilerType);
+ return resolveClassName(compilerType,
+
task.getProject().createClassLoader(classpath));
}
/**
@@ -163,12 +199,15 @@
* Throws a fit if it can't.
*
* @param className The fully qualified classname to be created.
+ * @param loader the classloader to use
* @throws BuildException This is the fit that is thrown if className
* isn't an instance of CompilerAdapter.
*/
- private static CompilerAdapter resolveClassName(String className)
+ private static CompilerAdapter resolveClassName(String className,
+ ClassLoader loader)
throws BuildException {
return (CompilerAdapter) ClasspathUtils.newInstance(className,
+ loader != null ? loader :
CompilerAdapterFactory.class.getClassLoader(),
CompilerAdapter.class);
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
Tue Jul 21 08:52:12 2009
@@ -407,6 +407,16 @@
}
/**
+ * The classpath to use when loading the javah implementation
+ * if it is not a built-in one.
+ *
+ * @since Ant 1.8.0
+ */
+ public Path createImplementationClasspath() {
+ return facade.getImplementationClasspath(getProject());
+ }
+
+ /**
* Execute the task
*
* @throws BuildException is there is a problem in the task execution.
@@ -443,7 +453,8 @@
JavahAdapter ad =
JavahAdapterFactory.getAdapter(facade.getImplementation(),
- this);
+ this,
+ createImplementationClasspath());
if (!ad.compile(this)) {
throw new BuildException("compilation failed");
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
Tue Jul 21 08:52:12 2009
@@ -26,6 +26,7 @@
import org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapter;
import
org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapterFactory;
import org.apache.tools.ant.types.Mapper;
+import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.IdentityMapper;
import org.apache.tools.ant.util.SourceFileScanner;
@@ -174,6 +175,16 @@
}
/**
+ * The classpath to use when loading the native2ascii
+ * implementation if it is not a built-in one.
+ *
+ * @since Ant 1.8.0
+ */
+ public Path createImplementationClasspath() {
+ return facade.getImplementationClasspath(getProject());
+ }
+
+ /**
* Execute the task
*
* @throws BuildException is there is a problem in the task execution.
@@ -264,7 +275,8 @@
log("converting " + srcName, Project.MSG_VERBOSE);
Native2AsciiAdapter ad =
Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(),
- this);
+ this,
+
createImplementationClasspath());
if (!ad.convert(this, srcFile, destFile)) {
throw new BuildException("conversion failed");
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
Tue Jul 21 08:52:12 2009
@@ -19,6 +19,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
@@ -58,13 +59,35 @@
public static JavahAdapter getAdapter(String choice,
ProjectComponent log)
throws BuildException {
+ return getAdapter(choice, log, null);
+ }
+
+ /**
+ * Creates the JavahAdapter based on the user choice and
+ * potentially the VM vendor.
+ *
+ * @param choice the user choice (if any).
+ * @param log a ProjectComponent instance used to access Ant's
+ * logging system.
+ * @param classpath the classpath to use when looking up an
+ * adapter class
+ * @return The adapter to use.
+ * @throws BuildException if there is an error.
+ * @since Ant 1.8.0
+ */
+ public static JavahAdapter getAdapter(String choice,
+ ProjectComponent log,
+ Path classpath)
+ throws BuildException {
if ((JavaEnvUtils.isKaffe() && choice == null)
|| Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
return new Kaffeh();
} else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new SunJavah();
} else if (choice != null) {
- return resolveClassName(choice);
+ return resolveClassName(choice,
+ log.getProject()
+ .createClassLoader(classpath));
}
// This default has been good enough until Ant 1.6.3, so stick
@@ -77,12 +100,15 @@
* Throws a fit if it can't.
*
* @param className The fully qualified classname to be created.
+ * @param loader the classloader to use
* @throws BuildException This is the fit that is thrown if className
* isn't an instance of JavahAdapter.
*/
- private static JavahAdapter resolveClassName(String className)
+ private static JavahAdapter resolveClassName(String className,
+ ClassLoader loader)
throws BuildException {
return (JavahAdapter) ClasspathUtils.newInstance(className,
+ loader != null ? loader :
JavahAdapterFactory.class.getClassLoader(),
JavahAdapter.class);
}
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
Tue Jul 21 08:52:12 2009
@@ -19,6 +19,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
@@ -46,7 +47,7 @@
}
/**
- * Creates the Native2AsciiAdapter based on the user choice and *
+ * Creates the Native2AsciiAdapter based on the user choice and
* potentially the VM vendor.
*
* @param choice the user choice (if any).
@@ -58,13 +59,35 @@
public static Native2AsciiAdapter getAdapter(String choice,
ProjectComponent log)
throws BuildException {
+ return getAdapter(choice, log, null);
+ }
+
+ /**
+ * Creates the Native2AsciiAdapter based on the user choice and
+ * potentially the VM vendor.
+ *
+ * @param choice the user choice (if any).
+ * @param log a ProjectComponent instance used to access Ant's
+ * logging system.
+ * @param classpath the classpath to use when looking up an
+ * adapter class
+ * @return The adapter to use.
+ * @throws BuildException if there was a problem.
+ * @since Ant 1.8.0
+ */
+ public static Native2AsciiAdapter getAdapter(String choice,
+ ProjectComponent log,
+ Path classpath)
+ throws BuildException {
if ((JavaEnvUtils.isKaffe() && choice == null)
|| KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
return new KaffeNative2Ascii();
} else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
return new SunNative2Ascii();
} else if (choice != null) {
- return resolveClassName(choice);
+ return resolveClassName(choice,
+ log.getProject()
+ .createClassLoader(classpath));
}
// This default has been good enough until Ant 1.6.3, so stick
@@ -77,12 +100,15 @@
* Throws a fit if it can't.
*
* @param className The fully qualified classname to be created.
+ * @param loader the classloader to use
* @throws BuildException This is the fit that is thrown if className
* isn't an instance of Native2AsciiAdapter.
*/
- private static Native2AsciiAdapter resolveClassName(String className)
+ private static Native2AsciiAdapter resolveClassName(String className,
+ ClassLoader loader)
throws BuildException {
return (Native2AsciiAdapter) ClasspathUtils.newInstance(className,
+ loader != null ? loader :
Native2AsciiAdapterFactory.class.getClassLoader(),
Native2AsciiAdapter.class);
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
Tue Jul 21 08:52:12 2009
@@ -20,6 +20,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.ClasspathUtils;
import java.util.Locale;
@@ -66,6 +67,35 @@
*/
public static RmicAdapter getRmic(String rmicType, Task task)
throws BuildException {
+ return getRmic(rmicType, task, null);
+ }
+
+ /**
+ * Based on the parameter passed in, this method creates the necessary
+ * factory desired.
+ *
+ * <p>The current mapping for rmic names are as follows:</p>
+ * <ul><li>sun = SUN's rmic
+ * <li>kaffe = Kaffe's rmic
+ * <li><i>a fully qualified classname</i> = the name of a rmic
+ * adapter
+ * <li>weblogic = weblogic compiler
+ * <li>forking = Sun's RMIC by forking a new JVM
+ * </ul>
+ *
+ * @param rmicType either the name of the desired rmic, or the
+ * full classname of the rmic's adapter.
+ * @param task a task to log through.
+ * @param classpath the classpath to use when looking up an
+ * adapter class
+ * @return the compiler adapter
+ * @throws BuildException if the rmic type could not be resolved into
+ * a rmic adapter.
+ * @since Ant 1.8.0
+ */
+ public static RmicAdapter getRmic(String rmicType, Task task,
+ Path classpath)
+ throws BuildException {
//convert to lower case in the English locale,
String compiler = rmicType.toLowerCase(Locale.ENGLISH);
@@ -87,7 +117,8 @@
return new XNewRmic();
}
//no match? ask for the non-lower-cased type
- return resolveClassName(rmicType);
+ return resolveClassName(rmicType,
+
task.getProject().createClassLoader(classpath));
}
/**
@@ -95,12 +126,15 @@
* Throws a fit if it can't.
*
* @param className The fully qualified classname to be created.
+ * @param loader the classloader to use
* @throws BuildException This is the fit that is thrown if className
* isn't an instance of RmicAdapter.
*/
- private static RmicAdapter resolveClassName(String className)
+ private static RmicAdapter resolveClassName(String className,
+ ClassLoader loader)
throws BuildException {
return (RmicAdapter) ClasspathUtils.newInstance(className,
+ loader != null ? loader :
RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class);
}
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/util/facade/FacadeTaskHelper.java
Tue Jul 21 08:52:12 2009
@@ -21,6 +21,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
/**
* Helper class for facade implementations - encapsulates treatment of
@@ -53,6 +55,11 @@
private String defaultValue;
/**
+ * User specified path used as classpath when loading the implementation.
+ */
+ private Path implementationClasspath;
+
+ /**
* @param defaultValue The default value for the implementation.
* Must not be null.
*/
@@ -141,4 +148,18 @@
public boolean hasBeenSet() {
return userChoice != null || magicValue != null;
}
+
+ /**
+ * The classpath to use when loading the implementation.
+ *
+ * @param project the current project
+ * @return a Path instance that may be appended to
+ * @since Ant 1.8.0
+ */
+ public Path getImplementationClasspath(Project project) {
+ if (implementationClasspath == null) {
+ implementationClasspath = new Path(project);
+ }
+ return implementationClasspath;
+ }
}
Modified: ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml?rev=796188&r1=796187&r2=796188&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml Tue Jul 21
08:52:12 2009
@@ -119,4 +119,40 @@
updatedProperty="third-pass"/>
<au:assertPropertyEquals name="third-pass" value="true"/>
</target>
+
+ <target name="-create-javac-adapter">
+ <property name="adapter.dir" location="${output}/adapter"/>
+ <mkdir dir="${input}/org/example"/>
+ <echo file="${input}/org/example/Adapter.java"><![CDATA[
+package org.example;
+import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter;
+import org.apache.tools.ant.taskdefs.Javac;
+
+public class Adapter implements CompilerAdapter {
+ public void setJavac(Javac attributes) {}
+ public boolean execute() {
+ System.err.println("adapter called");
+ return true;
+ }
+}]]></echo>
+ <mkdir dir="${adapter.dir}"/>
+ <javac srcdir="${input}" destdir="${adapter.dir}"/>
+ </target>
+
+ <target name="testCompilerNotFound" depends="-create-javac-adapter">
+ <au:expectfailure>
+ <javac srcdir="${input}" destdir="${output}"
+ compiler="org.example.Adapter"/>
+ </au:expectfailure>
+ <au:assertLogDoesntContain text="adapter called"/>
+ </target>
+
+ <target name="testCompilerClasspath" depends="-create-javac-adapter"
+
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143">
+ <javac srcdir="${input}" destdir="${output}"
+ compiler="org.example.Adapter">
+ <compilerclasspath location="${adapter.dir}"/>
+ </javac>
+ <au:assertLogContains text="adapter called"/>
+ </target>
</project>
Added: ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml?rev=796188&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml Tue Jul
21 08:52:12 2009
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../../antunit-base.xml" />
+
+ <target name="-create-javah-adapter">
+ <property name="adapter.dir" location="${output}/adapter"/>
+ <mkdir dir="${input}/org/example"/>
+ <echo file="${input}/org/example/Adapter.java"><![CDATA[
+package org.example;
+import org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter;
+import org.apache.tools.ant.taskdefs.optional.Javah;
+
+public class Adapter implements JavahAdapter {
+ public boolean compile(Javah javah) {
+ System.err.println("adapter called");
+ return true;
+ }
+}]]></echo>
+ <mkdir dir="${adapter.dir}"/>
+ <javac srcdir="${input}" destdir="${adapter.dir}"/>
+ </target>
+
+ <target name="testAdapterNotFound" depends="-create-javah-adapter">
+ <au:expectfailure>
+ <javah class="org.example.Adapter" destdir="${output}"
+ implementation="org.example.Adapter"/>
+ </au:expectfailure>
+ <au:assertLogDoesntContain text="adapter called"/>
+ </target>
+
+ <target name="testImplementationClasspath" depends="-create-javah-adapter"
+
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143">
+ <javah class="org.example.Adapter" destdir="${output}"
+ implementation="org.example.Adapter">
+ <implementationclasspath location="${adapter.dir}"/>
+ </javah>
+ <au:assertLogContains text="adapter called"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml?rev=796188&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml
(added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml
Tue Jul 21 08:52:12 2009
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../../antunit-base.xml" />
+
+ <target name="-create-native2ascii-adapter">
+ <property name="adapter.dir" location="${output}/adapter"/>
+ <mkdir dir="${input}/org/example"/>
+ <echo file="${input}/org/example/Adapter.java"><![CDATA[
+package org.example;
+import java.io.File;
+import org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapter;
+import org.apache.tools.ant.taskdefs.optional.Native2Ascii;
+
+public class Adapter implements Native2AsciiAdapter {
+ public boolean convert(Native2Ascii native2ascii, File f1, File f2) {
+ System.err.println("adapter called");
+ return true;
+ }
+}]]></echo>
+ <mkdir dir="${adapter.dir}"/>
+ <javac srcdir="${input}" destdir="${adapter.dir}"/>
+ </target>
+
+ <target name="testAdapterNotFound" depends="-create-native2ascii-adapter">
+ <au:expectfailure>
+ <native2ascii src="${input}" dest="${output}" includes="**/*.java"
+ implementation="org.example.Adapter"/>
+ </au:expectfailure>
+ <au:assertLogDoesntContain text="adapter called"/>
+ </target>
+
+ <target name="testImplementationClasspath"
depends="-create-native2ascii-adapter"
+
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143">
+ <native2ascii src="${input}" dest="${output}" includes="**/*.java"
+ implementation="org.example.Adapter">
+ <implementationclasspath location="${adapter.dir}"/>
+ </native2ascii>
+ <au:assertLogContains text="adapter called"/>
+ </target>
+</project>
Propchange:
ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascci-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml?rev=796188&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml Tue Jul 21 08:52:12
2009
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../antunit-base.xml" />
+
+ <target name="-create-rmic-adapter">
+ <property name="adapter.dir" location="${output}/adapter"/>
+ <mkdir dir="${input}/org/example"/>
+ <echo file="${input}/org/example/Adapter.java"><![CDATA[
+package org.example;
+import org.apache.tools.ant.taskdefs.rmic.RmicAdapter;
+import org.apache.tools.ant.taskdefs.Rmic;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.GlobPatternMapper;
+
+public class Adapter implements RmicAdapter {
+ public void setRmic(Rmic attributes) {}
+ public boolean execute() {
+ System.err.println("adapter called");
+ return true;
+ }
+ public FileNameMapper getMapper() {
+ GlobPatternMapper m = new GlobPatternMapper();
+ m.setFrom("*.class");
+ m.setTo("*_foo.class");
+ return m;
+ }
+
+ public Path getClasspath() {
+ return new Path(null);
+ }
+}]]></echo>
+ <mkdir dir="${adapter.dir}"/>
+ <javac srcdir="${input}" destdir="${adapter.dir}"/>
+ </target>
+
+ <target name="testCompilerNotFound" depends="-create-rmic-adapter">
+ <au:expectfailure>
+ <rmic base="${adapter.dir}" includes="**/*.class"
+ compiler="org.example.Adapter"/>
+ </au:expectfailure>
+ <au:assertLogDoesntContain text="adapter called"/>
+ </target>
+
+ <target name="testCompilerClasspath" depends="-create-rmic-adapter"
+
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=11143">
+ <rmic base="${adapter.dir}" includes="**/*.class"
+ compiler="org.example.Adapter">
+ <compilerclasspath location="${adapter.dir}"/>
+ </rmic>
+ <au:assertLogContains text="adapter called"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml
------------------------------------------------------------------------------
svn:eol-style = native