git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@811376 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -860,6 +860,12 @@ Other changes: | |||
| task's (compiler) adapter class. | |||
| Bugzilla Report 11143. | |||
| * <javac>, <rmic>, <javah> and <native2ascii> now provide a nested | |||
| element to specify the task's (compiler) adapter as an instance of | |||
| a class that has been defined via typedef/componentdef. This | |||
| allows more control over the classpath and allows adapters to be | |||
| defined in Antlibs easily. | |||
| * A new subclass org.apache.tools.ant.loader.AntClassLoader5 of | |||
| AntClassLoader has been added which overrides getResources | |||
| which became non-final in ClassLoader with Java5+ so | |||
| @@ -59,9 +59,12 @@ for information on how the | |||
| inclusion/exclusion of files works, and how to write wildcard patterns.</p> | |||
| <p>It is possible to use different compilers. This can be specified by | |||
| either setting the global <code>build.compiler</code> property, which will | |||
| affect all <code><javac></code> tasks throughout the build, or by | |||
| affect all <code><javac></code> tasks throughout the build, by | |||
| setting the <code>compiler</code> attribute, specific to the current | |||
| <code><javac></code> task. | |||
| <code><javac></code> task or by using a nested element of any | |||
| <a href="typedef.html">typedef</a>fed or | |||
| <a href="componentdef.html">componentdef</a>fed type that implements | |||
| <code>org.apache.tools.ant.taskdefs.compilers.CompilerAdapter</code>. | |||
| <a name="compilervalues">Valid values for either the | |||
| <code>build.compiler</code> property or the <code>compiler</code> | |||
| attribute are:</a></p> | |||
| @@ -516,6 +519,12 @@ used.</p> | |||
| custom class has been specified. Doesn't have any effect when | |||
| using one of the built-in compilers.</p> | |||
| <h4>Any nested element of a type that implements CompilerAdapter | |||
| <em>since Ant 1.8.0</em></h4> | |||
| <p>If a defined type implements the <code>CompilerAdapter</code> | |||
| interface a nested element of that type can be used as an | |||
| alternative to the <code>compiler</code> attribute.</p> | |||
| <h3>Examples</h3> | |||
| <pre> <javac srcdir="${src}" | |||
| @@ -662,6 +671,25 @@ the <tt><compilerarg></tt> element: | |||
| </javac> </pre> | |||
| </p> | |||
| <p>If you want to use a custom | |||
| CompilerAdapter <code>org.example.MyAdapter</code> you can either | |||
| use the compiler attribute:</p> | |||
| <pre> | |||
| <javac srcdir="${src.dir}" | |||
| destdir="${classes.dir}" | |||
| compiler="org.example.MyAdapter"/> | |||
| </pre> | |||
| <p>or a define a type and nest this into the task like in:</p> | |||
| <pre> | |||
| <componentdef classname="org.example.MyAdapter" | |||
| name="myadapter"/> | |||
| <javac srcdir="${src.dir}" | |||
| destdir="${classes.dir}"> | |||
| <myadapter/> | |||
| </javac> | |||
| </pre> | |||
| <p>in which case your compiler adapter can support attributes and | |||
| nested elements of its own.</p> | |||
| <h3>Jikes Notes</h3> | |||
| @@ -800,27 +828,14 @@ while all others are <code>false</code>.</p> | |||
| task is run again, the | |||
| task will try to compile the package-info java files again. | |||
| </p> | |||
| <p> | |||
| In <b>Ant 1.7.1</b> the package-info.java will only be compiled if: | |||
| <ol> | |||
| <li> | |||
| If a <code>package-info.class</code> file exists and is older than | |||
| the <code>package-info.java</code> file. | |||
| </li> | |||
| <li> | |||
| If the directory for the | |||
| <code>package-info.class</code> file does not exist. | |||
| </li> | |||
| <li> | |||
| If the directory for the | |||
| <code>package-info.class</code> file exists, and has an older | |||
| modification time than the | |||
| the <code>package-info.java</code> file. In this case | |||
| <javac> will touch the corresponding .class directory | |||
| on successful compilation. | |||
| </li> | |||
| </ol> | |||
| </p> | |||
| <p>With Ant 1.7.1 a different kind of logic was introduced that | |||
| involved the timestamp of the directory that would normally | |||
| contain the .class file. This logic turned out to lead to Ant not | |||
| recompiling <code>package-info.java</code> in certain setup.</p> | |||
| <p>Starting with Ant 1.8.0 Ant will create | |||
| "empty" <code>package-info.class</code> files if it compiles | |||
| a <code>package-info.java</code> and | |||
| no <code>package-info.class</code> file has been created by the | |||
| compiler itself.</p> | |||
| </body> | |||
| </html> | |||
| @@ -48,8 +48,8 @@ supports most attributes of <code><fileset></code> | |||
| <code><include></code>, <code><exclude></code> and | |||
| <code><patternset></code> elements.</p> | |||
| <p>It is possible to use different compilers. This can be selected | |||
| with the "build.rmic" property or the <code>compiler</code> | |||
| attribute. | |||
| with the "build.rmic" property, the <code>compiler</code> | |||
| attribute. or a nested element. | |||
| <a name="compilervalues">Here are the choices</a>:</p> | |||
| <ul> | |||
| <li>default -the default compiler (kaffe or sun) for the platform. | |||
| @@ -311,6 +311,13 @@ used.</p> | |||
| custom class has been specified. Doesn't have any effect when | |||
| using one of the built-in compilers.</p> | |||
| <h4>Any nested element of a type that implements RmicAdapter | |||
| <em>since Ant 1.8.0</em></h4> | |||
| <p>If a defined type implements the <code>RmicAdapter</code> | |||
| interface a nested element of that type can be used as an | |||
| alternative to the <code>compiler</code> attribute.</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 | |||
| @@ -321,7 +328,25 @@ files below <code>${build}/classes</code> whose classname starts with | |||
| <i>Remote</i>. The compiled files will be stored in the directory | |||
| <code>${build}/classes</code>.</p> | |||
| <p>If you want to use a custom | |||
| RmicAdapter <code>org.example.MyAdapter</code> you can either | |||
| use the compiler attribute:</p> | |||
| <pre> | |||
| <rmic classname="com.xyz.FooBar" | |||
| base="${build}/classes" | |||
| compiler="org.example.MyAdapter"/> | |||
| </pre> | |||
| <p>or a define a type and nest this into the task like in:</p> | |||
| <pre> | |||
| <componentdef classname="org.example.MyAdapter" | |||
| name="myadapter"/> | |||
| <rmic classname="com.xyz.FooBar" | |||
| base="${build}/classes"> | |||
| <myadapter/> | |||
| </rmic> | |||
| </pre> | |||
| <p>in which case your compiler adapter can support attributes and | |||
| nested elements of its own.</p> | |||
| </body> | |||
| </html> | |||
| @@ -34,8 +34,8 @@ whether <a href="http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javah.html">JD | |||
| systems are used.</p> | |||
| <p>It is possible to use different compilers. This can be selected | |||
| with the <code>implementation</code> attribute. <a | |||
| name="implementationvalues">Here are the choices</a>:</p> | |||
| with the <code>implementation</code> attribute or a nested element. <a | |||
| name="implementationvalues">Here are the choices of the attribute</a>:</p> | |||
| <ul> | |||
| <li>default - the default compiler (kaffeh or sun) for the platform.</li> | |||
| <li>sun (the standard compiler of the JDK)</li> | |||
| @@ -177,6 +177,13 @@ only if a given compiler implementation will be used.</p> | |||
| custom class has been specified. Doesn't have any effect when | |||
| using one of the built-in compilers.</p> | |||
| <h4>Any nested element of a type that implements JavahAdapter | |||
| <em>since Ant 1.8.0</em></h4> | |||
| <p>If a defined type implements the <code>JavahAdapter</code> | |||
| interface a nested element of that type can be used as an | |||
| alternative to the <code>implementation</code> attribute.</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 | |||
| @@ -210,6 +217,23 @@ is invoked, even if they already exist.</p> | |||
| writes the corresponding .c stubs. The verbose option will cause Javah to | |||
| describe its progress.</p> | |||
| <p>If you want to use a custom | |||
| JavahAdapter <code>org.example.MyAdapter</code> you can either | |||
| use the implementation attribute:</p> | |||
| <pre> | |||
| <javah destdir="c" class="org.foo.bar.Wibble" | |||
| implementation="org.example.MyAdapter"/> | |||
| </pre> | |||
| <p>or a define a type and nest this into the task like in:</p> | |||
| <pre> | |||
| <componentdef classname="org.example.MyAdapter" | |||
| name="myadapter"/> | |||
| <javah destdir="c" class="org.foo.bar.Wibble"> | |||
| <myadapter/> | |||
| </javah> | |||
| </pre> | |||
| <p>in which case your javah adapter can support attributes and | |||
| nested elements of its own.</p> | |||
| </body> | |||
| @@ -58,8 +58,8 @@ | |||
| </p> | |||
| <p>It is possible to use different converters. This can be selected | |||
| with the <code>implementation</code> attribute. | |||
| <a name="implementationvalues">Here are the choices</a>:</p> | |||
| with the <code>implementation</code> attribute or a nested element. | |||
| <a name="implementationvalues">Here are the choices of the attribute</a>:</p> | |||
| <ul> | |||
| <li>default - the default converter (kaffe or sun) for the platform.</li> | |||
| <li>sun (the standard converter of the JDK)</li> | |||
| @@ -190,6 +190,13 @@ only if a given converter implementation will be used.</p> | |||
| custom class has been specified. Doesn't have any effect when | |||
| using one of the built-in converters.</p> | |||
| <h4>Any nested element of a type that implements Native2AsciiAdapter | |||
| <em>since Ant 1.8.0</em></h4> | |||
| <p>If a defined type implements the <code>Native2AsciiAdapter</code> | |||
| interface a nested element of that type can be used as an | |||
| alternative to the <code>implementation</code> attribute.</p> | |||
| <h3>Examples</h3> | |||
| <pre> | |||
| @@ -214,6 +221,26 @@ only if a given converter implementation will be used.</p> | |||
| placing the results in the directory <em>src</em>. | |||
| The names of the files remain the same. | |||
| </p> | |||
| <p>If you want to use a custom | |||
| Native2AsciiAdapter <code>org.example.MyAdapter</code> you can either | |||
| use the implementation attribute:</p> | |||
| <pre> | |||
| <native2ascii encoding="EUCJIS" src="srcdir" dest="srcdir" | |||
| includes="**/*.eucjis" ext=".java" | |||
| implementation="org.example.MyAdapter"/> | |||
| </pre> | |||
| <p>or a define a type and nest this into the task like in:</p> | |||
| <pre> | |||
| <componentdef classname="org.example.MyAdapter" | |||
| name="myadapter"/> | |||
| <native2ascii encoding="EUCJIS" src="srcdir" dest="srcdir" | |||
| includes="**/*.eucjis" ext=".java"> | |||
| <myadapter/> | |||
| </native2ascii> | |||
| </pre> | |||
| <p>in which case your native2ascii adapter can support attributes and | |||
| nested elements of its own.</p> | |||
| </body> | |||
| </html> | |||
| @@ -127,6 +127,7 @@ public class Javac extends MatchingTask { | |||
| private String errorProperty; | |||
| private boolean taskSuccess = true; // assume the best | |||
| private boolean includeDestClasses = true; | |||
| private CompilerAdapter nestedAdapter = null; | |||
| /** | |||
| * Javac task for compilation of Java files. | |||
| @@ -865,6 +866,18 @@ public class Javac extends MatchingTask { | |||
| return facade.getImplementationClasspath(getProject()); | |||
| } | |||
| /** | |||
| * Set the compiler adapter explicitly. | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public void add(CompilerAdapter adapter) { | |||
| if (nestedAdapter != null) { | |||
| throw new BuildException("Can't have more than one compiler" | |||
| + " adapter"); | |||
| } | |||
| nestedAdapter = adapter; | |||
| } | |||
| /** | |||
| * Executes the task. | |||
| * @exception BuildException if an error occurs | |||
| @@ -1073,6 +1086,7 @@ public class Javac extends MatchingTask { | |||
| } | |||
| CompilerAdapter adapter = | |||
| nestedAdapter != null ? nestedAdapter : | |||
| CompilerAdapterFactory.getCompiler(compilerImpl, this, | |||
| createCompilerClasspath()); | |||
| @@ -128,6 +128,8 @@ public class Rmic extends MatchingTask { | |||
| private boolean listFiles = false; | |||
| private RmicAdapter nestedAdapter = null; | |||
| /** | |||
| * Constructor for Rmic. | |||
| */ | |||
| @@ -560,6 +562,18 @@ public class Rmic extends MatchingTask { | |||
| public void setListfiles(boolean list) { | |||
| listFiles = list; | |||
| } | |||
| /** | |||
| * Set the compiler adapter explicitly. | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public void add(RmicAdapter adapter) { | |||
| if (nestedAdapter != null) { | |||
| throw new BuildException("Can't have more than one rmic adapter"); | |||
| } | |||
| nestedAdapter = adapter; | |||
| } | |||
| /** | |||
| * execute by creating an instance of an implementation | |||
| * class and getting to do the work | |||
| @@ -582,8 +596,10 @@ public class Rmic extends MatchingTask { | |||
| if (verify) { | |||
| log("Verify has been turned on.", Project.MSG_VERBOSE); | |||
| } | |||
| RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this, | |||
| createCompilerClasspath()); | |||
| RmicAdapter adapter = | |||
| nestedAdapter != null ? nestedAdapter : | |||
| RmicAdapterFactory.getRmic(getCompiler(), this, | |||
| createCompilerClasspath()); | |||
| // now we need to populate the compiler adapter | |||
| adapter.setRmic(this); | |||
| @@ -83,6 +83,7 @@ public class Javah extends Task { | |||
| //private Path extdirs; | |||
| private FacadeTaskHelper facade = null; | |||
| private Vector files = new Vector(); | |||
| private JavahAdapter nestedAdapter = null; | |||
| /** | |||
| * No arg constructor. | |||
| @@ -416,6 +417,18 @@ public class Javah extends Task { | |||
| return facade.getImplementationClasspath(getProject()); | |||
| } | |||
| /** | |||
| * Set the adapter explicitly. | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public void add(JavahAdapter adapter) { | |||
| if (nestedAdapter != null) { | |||
| throw new BuildException("Can't have more than one javah" | |||
| + " adapter"); | |||
| } | |||
| nestedAdapter = adapter; | |||
| } | |||
| /** | |||
| * Execute the task | |||
| * | |||
| @@ -452,6 +465,7 @@ public class Javah extends Task { | |||
| } | |||
| JavahAdapter ad = | |||
| nestedAdapter != null ? nestedAdapter : | |||
| JavahAdapterFactory.getAdapter(facade.getImplementation(), | |||
| this, | |||
| createImplementationClasspath()); | |||
| @@ -48,6 +48,7 @@ public class Native2Ascii extends MatchingTask { | |||
| private Mapper mapper; | |||
| private FacadeTaskHelper facade = null; | |||
| private Native2AsciiAdapter nestedAdapter = null; | |||
| /** No args constructor */ | |||
| public Native2Ascii() { | |||
| @@ -184,6 +185,18 @@ public class Native2Ascii extends MatchingTask { | |||
| return facade.getImplementationClasspath(getProject()); | |||
| } | |||
| /** | |||
| * Set the adapter explicitly. | |||
| * @since Ant 1.8.0 | |||
| */ | |||
| public void add(Native2AsciiAdapter adapter) { | |||
| if (nestedAdapter != null) { | |||
| throw new BuildException("Can't have more than one native2ascii" | |||
| + " adapter"); | |||
| } | |||
| nestedAdapter = adapter; | |||
| } | |||
| /** | |||
| * Execute the task | |||
| * | |||
| @@ -274,6 +287,7 @@ public class Native2Ascii extends MatchingTask { | |||
| log("converting " + srcName, Project.MSG_VERBOSE); | |||
| Native2AsciiAdapter ad = | |||
| nestedAdapter != null ? nestedAdapter : | |||
| Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(), | |||
| this, | |||
| createImplementationClasspath()); | |||
| @@ -155,4 +155,14 @@ public class Adapter implements CompilerAdapter { | |||
| </javac> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| <target name="testCompilerAsNestedElement" depends="-create-javac-adapter"> | |||
| <componentdef classname="org.example.Adapter" name="myjavac"> | |||
| <classpath location="${adapter.dir}"/> | |||
| </componentdef> | |||
| <javac srcdir="${input}" destdir="${output}"> | |||
| <myjavac/> | |||
| </javac> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| </project> | |||
| @@ -52,4 +52,15 @@ public class Adapter implements JavahAdapter { | |||
| </javah> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| <target name="testImplementationAsNestedElement" | |||
| depends="-create-javah-adapter"> | |||
| <componentdef classname="org.example.Adapter" name="myjavac"> | |||
| <classpath location="${adapter.dir}"/> | |||
| </componentdef> | |||
| <javah class="org.example.Adapter" destdir="${output}"> | |||
| <myjavac/> | |||
| </javah> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| </project> | |||
| @@ -53,4 +53,15 @@ public class Adapter implements Native2AsciiAdapter { | |||
| </native2ascii> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| <target name="testImplementationAsNestedElement" | |||
| depends="-create-native2ascii-adapter"> | |||
| <componentdef classname="org.example.Adapter" name="myjavac"> | |||
| <classpath location="${adapter.dir}"/> | |||
| </componentdef> | |||
| <native2ascii src="${input}" dest="${output}" includes="**/*.java"> | |||
| <myjavac/> | |||
| </native2ascii> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| </project> | |||
| @@ -66,4 +66,14 @@ public class Adapter implements RmicAdapter { | |||
| </rmic> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| <target name="testCompilerAsNestedElement" depends="-create-rmic-adapter"> | |||
| <componentdef classname="org.example.Adapter" name="myjavac"> | |||
| <classpath location="${adapter.dir}"/> | |||
| </componentdef> | |||
| <rmic base="${adapter.dir}" includes="**/*.class"> | |||
| <myjavac/> | |||
| </rmic> | |||
| <au:assertLogContains text="adapter called"/> | |||
| </target> | |||
| </project> | |||