You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2009/09/04 15:02:02 UTC
svn commit: r811376 - in /ant/core/trunk: ./ docs/manual/CoreTasks/
docs/manual/OptionalTasks/ src/main/org/apache/tools/ant/taskdefs/
src/main/org/apache/tools/ant/taskdefs/optional/
src/tests/antunit/taskdefs/ src/tests/antunit/taskdefs/optional/
Author: bodewig
Date: Fri Sep 4 13:02:02 2009
New Revision: 811376
URL: http://svn.apache.org/viewvc?rev=811376&view=rev
Log:
compiler adapter as nested element in javac, rmic, native2ascii and javah. Document package-info.java stuff in javac manual page.
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/optional/Javah.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml
ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml
ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascii-test.xml
ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Sep 4 13:02:02 2009
@@ -860,6 +860,12 @@
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
Modified: ant/core/trunk/docs/manual/CoreTasks/javac.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/javac.html?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javac.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javac.html Fri Sep 4 13:02:02 2009
@@ -59,9 +59,12 @@
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 @@
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 @@
</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 @@
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>
Modified: ant/core/trunk/docs/manual/CoreTasks/rmic.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/rmic.html?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/rmic.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/rmic.html Fri Sep 4 13:02:02 2009
@@ -48,8 +48,8 @@
<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 @@
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 @@
<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>
Modified: ant/core/trunk/docs/manual/OptionalTasks/javah.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/javah.html?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/javah.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/javah.html Fri Sep 4 13:02:02 2009
@@ -34,8 +34,8 @@
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 @@
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 @@
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>
Modified: ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/native2ascii.html Fri Sep 4 13:02:02 2009
@@ -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 @@
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 @@
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>
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=811376&r1=811375&r2=811376&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 Fri Sep 4 13:02:02 2009
@@ -127,6 +127,7 @@
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.
@@ -866,6 +867,18 @@
}
/**
+ * 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 @@
}
CompilerAdapter adapter =
+ nestedAdapter != null ? nestedAdapter :
CompilerAdapterFactory.getCompiler(compilerImpl, this,
createCompilerClasspath());
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=811376&r1=811375&r2=811376&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 Fri Sep 4 13:02:02 2009
@@ -128,6 +128,8 @@
private boolean listFiles = false;
+ private RmicAdapter nestedAdapter = null;
+
/**
* Constructor for Rmic.
*/
@@ -560,6 +562,18 @@
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 @@
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);
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=811376&r1=811375&r2=811376&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 Fri Sep 4 13:02:02 2009
@@ -83,6 +83,7 @@
//private Path extdirs;
private FacadeTaskHelper facade = null;
private Vector files = new Vector();
+ private JavahAdapter nestedAdapter = null;
/**
* No arg constructor.
@@ -417,6 +418,18 @@
}
/**
+ * 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
*
* @throws BuildException is there is a problem in the task execution.
@@ -452,6 +465,7 @@
}
JavahAdapter ad =
+ nestedAdapter != null ? nestedAdapter :
JavahAdapterFactory.getAdapter(facade.getImplementation(),
this,
createImplementationClasspath());
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=811376&r1=811375&r2=811376&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 Fri Sep 4 13:02:02 2009
@@ -48,6 +48,7 @@
private Mapper mapper;
private FacadeTaskHelper facade = null;
+ private Native2AsciiAdapter nestedAdapter = null;
/** No args constructor */
public Native2Ascii() {
@@ -185,6 +186,18 @@
}
/**
+ * 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
*
* @throws BuildException is there is a problem in the task execution.
@@ -274,6 +287,7 @@
log("converting " + srcName, Project.MSG_VERBOSE);
Native2AsciiAdapter ad =
+ nestedAdapter != null ? nestedAdapter :
Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(),
this,
createImplementationClasspath());
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=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml Fri Sep 4 13:02:02 2009
@@ -155,4 +155,14 @@
</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>
Modified: 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=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/javah-test.xml Fri Sep 4 13:02:02 2009
@@ -52,4 +52,15 @@
</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>
Modified: ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascii-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascii-test.xml?rev=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascii-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/native2ascii-test.xml Fri Sep 4 13:02:02 2009
@@ -53,4 +53,15 @@
</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>
Modified: 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=811376&r1=811375&r2=811376&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/rmic-test.xml Fri Sep 4 13:02:02 2009
@@ -66,4 +66,14 @@
</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>