bodewig 02/04/15 06:20:26
Modified: . WHATSNEW
docs ant15_todo.html
docs/manual/CoreTasks rmic.html
src/main/org/apache/tools/ant/taskdefs Rmic.java
src/main/org/apache/tools/ant/taskdefs/rmic
DefaultRmicAdapter.java RmicAdapterFactory.java
src/testcases/org/apache/tools/ant/util/facade
FacadeTaskHelperTest.java
ImplementationSpecificArgumentTest.java
xdocs ant15_todo.xml
Added: src/testcases/org/apache/tools/ant/taskdefs RmicTest.java
Log:
Add compiler attribute and nested <compilerarg> element to <rmic>.
Revision Changes Path
1.251 +6 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -r1.250 -r1.251
--- WHATSNEW 13 Apr 2002 11:18:28 -0000 1.250
+++ WHATSNEW 15 Apr 2002 13:20:25 -0000 1.251
@@ -299,6 +299,12 @@
* An alias of <xslt> has been added to refer to the <style> task.
+* The compiler implementation for <rmic> can now be chosen on a task by
+ task basis. The new "compiler" attribute of <rmic> can be used to override
+ the value of the build.rmic property, if set.
+
+* <rmic> has a new nested element, <compilerarg>, which allows you
+ to specify additional args for the specific compiler you're using.
Changes from Ant 1.4 to Ant 1.4.1
===========================================
1.9 +20 -20 jakarta-ant/docs/ant15_todo.html
Index: ant15_todo.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/ant15_todo.html,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ant15_todo.html 15 Apr 2002 12:30:27 -0000 1.8
+++ ant15_todo.html 15 Apr 2002 13:20:25 -0000 1.9
@@ -366,26 +366,6 @@
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
- compiler attribute for rmic
- </font>
- </td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
- valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- </font>
- </td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
- valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Stefan, others welcome
- </font>
- </td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
- valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
JUnit's System.err/.out handling
</font>
</td>
@@ -474,6 +454,26 @@
valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Steve, in a really long meeting
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ compiler attribute for rmic
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Stefan
</font>
</td>
</tr>
1.10 +54 -2 jakarta-ant/docs/manual/CoreTasks/rmic.html
Index: rmic.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/rmic.html,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- rmic.html 21 Feb 2002 12:41:34 -0000 1.9
+++ rmic.html 15 Apr 2002 13:20:25 -0000 1.10
@@ -30,8 +30,9 @@
(<code>dir</code> becomes <code>base</code>) as well as the nested
<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. There are three choices:</p>
+<p>It is possible to use different compilers. This can be selected
+with the "build.rmic" property or the <code>compiler</code>
+attribute. <a name="compilervalues">There are three choices</a>:</p>
<ul>
<li>sun (the standard compiler of the JDK)</li>
<li>kaffe (the standard compiler of <a href="http://www.kaffe.org"
target="_top">Kaffe</a>)</li>
@@ -165,12 +166,63 @@
<td valign="top">location of installed extensions.</td>
<td align="center" valign="top">No</td>
</tr>
+ <tr>
+ <td valign="top">compiler</td>
+ <td valign="top">The compiler implementation to use.
+ If this attribute is not set, the value of the
+ <code>build.rmic</code> property, if set, will be used.
+ Otherwise, the default compiler for the current VM will be used.
+ (See the above <a href="#compilervalues">list</a> of valid
+ compilers.)</td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>classpath and extdirs</h4>
<p><code>Rmic</code>'s <i>classpath</i> and <i>extdirs</i> attributes are <a
href="../using.html#path">PATH like structure</a> and can also be set via a
nested
<i>classpath</i> and <i>extdirs</i> elements.</p>
+
+<h4>compilerarg</h4>
+
+<p>You can specify additional command line arguments for the compiler
+with nested <code><compilerarg></code> elements. These elements
+are specified like <a href="../using.html#arg">Command-line
+Arguments</a> but have an additional attribute that can be used to
+enable arguments only if a given compiler implementation will be
+used.</p>
+<table border="1" cellpadding="2" cellspacing="0">
+<tr>
+ <td width="12%" valign="top"><b>Attribute</b></td>
+ <td width="78%" valign="top"><b>Description</b></td>
+ <td width="10%" valign="top"><b>Required</b></td>
+</tr>
+ <tr>
+ <td valign="top">value</td>
+ <td align="center" rowspan="4">See
+ <a href="../using.html#arg">Command-line Arguments</a>.</td>
+ <td align="center" rowspan="4">Exactly one of these.</td>
+ </tr>
+ <tr>
+ <td valign="top">line</td>
+ </tr>
+ <tr>
+ <td valign="top">file</td>
+ </tr>
+ <tr>
+ <td valign="top">path</td>
+ </tr>
+ <tr>
+ <td valign="top">compiler</td>
+ <td>Only pass the specified argument if the chosen
+ compiler implementation matches the value of this attribute.
+ Legal values are the
+ same as those in the above <a href="#compilervalues">list</a> of valid
+ compilers.)</td>
+ <td align="center">No</td>
+ </tr>
+</table>
+
<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
1.35 +63 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java
Index: Rmic.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Rmic.java 14 Apr 2002 11:16:13 -0000 1.34
+++ Rmic.java 15 Apr 2002 13:20:25 -0000 1.35
@@ -66,6 +66,7 @@
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.SourceFileScanner;
+import org.apache.tools.ant.util.facade.FacadeTaskHelper;
import java.io.File;
import java.io.IOException;
@@ -134,6 +135,17 @@
private FileUtils fileUtils = FileUtils.newFileUtils();
+ private FacadeTaskHelper facade;
+
+ public Rmic() {
+ try {
+ Class.forName("kaffe.rmi.rmic.RMIC");
+ facade = new FacadeTaskHelper("kaffe");
+ } catch (ClassNotFoundException cnfe) {
+ facade = new FacadeTaskHelper("sun");
+ }
+ }
+
/** Sets the base directory to output generated class. */
public void setBase(File base) {
this.baseDir = base;
@@ -363,6 +375,42 @@
return compileList;
}
+ /**
+ * @since Ant 1.5
+ */
+ public void setCompiler(String compiler) {
+ facade.setImplementation(compiler);
+ }
+
+ /**
+ * @since Ant 1.5
+ */
+ public String getCompiler() {
+ facade.setMagicValue(getProject().getProperty("build.rmic"));
+ return facade.getImplementation();
+ }
+
+ /**
+ * Adds an implementation specific command line argument.
+ * @since Ant 1.5
+ */
+ public ImplementationSpecificArgument createCompilerArg() {
+ ImplementationSpecificArgument arg =
+ new ImplementationSpecificArgument();
+ facade.addImplementationArgument(arg);
+ return arg;
+ }
+
+ /**
+ * Get the additional implementation specific command line arguments.
+ * @return array of command line arguments, guaranteed to be non-null.
+ * @since Ant 1.5
+ */
+ public String[] getCurrentCompilerArgs() {
+ getCompiler();
+ return facade.getArgs();
+ }
+
public void execute() throws BuildException {
if (baseDir == null) {
throw new BuildException("base attribute must be set!",
location);
@@ -375,8 +423,7 @@
log("Verify has been turned on.", Project.MSG_INFO);
}
- String compiler = project.getProperty("build.rmic");
- RmicAdapter adapter = RmicAdapterFactory.getRmic(compiler, this);
+ RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(),
this);
// now we need to populate the compiler adapter
adapter.setRmic(this);
@@ -573,5 +620,19 @@
public ClassLoader getLoader() {
return loader;
}
+
+ /**
+ * Adds an "compiler" attribute to Commandline$Attribute used to
+ * filter command line attributes based on the current
+ * implementation.
+ */
+ public class ImplementationSpecificArgument extends
+ org.apache.tools.ant.util.facade.ImplementationSpecificArgument {
+
+ public void setCompiler(String impl) {
+ super.setImplementation(impl);
+ }
+ }
+
}
1.17 +2 -0
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
Index: DefaultRmicAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DefaultRmicAdapter.java 15 Apr 2002 12:11:50 -0000 1.16
+++ DefaultRmicAdapter.java 15 Apr 2002 13:20:25 -0000 1.17
@@ -246,6 +246,8 @@
cmd.createArgument().setValue("-g");
}
+ cmd.addArguments(attributes.getCurrentCompilerArgs());
+
logAndAddFilesToCompile(cmd);
return cmd;
}
1.7 +0 -20
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
Index: RmicAdapterFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RmicAdapterFactory.java 15 Apr 2002 12:11:50 -0000 1.6
+++ RmicAdapterFactory.java 15 Apr 2002 13:20:26 -0000 1.7
@@ -90,26 +90,6 @@
*/
public static RmicAdapter getRmic(String rmicType, Task task)
throws BuildException {
- if (rmicType == null) {
- /*
- * When not specified rmicType, search SUN's rmic and
- * Kaffe's rmic.
- */
- try {
- Class.forName("sun.rmi.rmic.Main");
- rmicType = "sun";
- } catch (ClassNotFoundException cnfe) {
- try {
- Class.forName("kaffe.rmi.rmic.RMIC");
- Class.forName("kaffe.tools.compiler.Compiler");
- rmicType = "kaffe";
- } catch (ClassNotFoundException cnfk) {
- throw new BuildException("Couldn\'t guess rmic "
- + "implementation");
- }
- }
- }
-
if (rmicType.equalsIgnoreCase("sun")) {
return new SunRmic();
} else if (rmicType.equalsIgnoreCase("kaffe")) {
1.1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java
Index: RmicTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.Project;
import junit.framework.TestCase;
/**
* Testcase for <rmic>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
* @version $Revision: 1.1 $
* @since Ant 1.5
*/
public class RmicTest extends TestCase {
private Project project;
private Rmic rmic;
public RmicTest(String name) {
super(name);
}
public void setUp() {
project = new Project();
project.init();
rmic = new Rmic();
rmic.setProject(project);
}
/**
* Test nested compiler args.
*/
public void testCompilerArg() {
String[] args = rmic.getCurrentCompilerArgs();
assertNotNull(args);
assertEquals("no args", 0, args.length);
Rmic.ImplementationSpecificArgument arg = rmic.createCompilerArg();
String ford = "Ford";
String prefect = "Prefect";
String testArg = ford + " " + prefect;
arg.setValue(testArg);
args = rmic.getCurrentCompilerArgs();
assertEquals("unconditional single arg", 1, args.length);
assertEquals(testArg, args[0]);
arg.setCompiler("weblogic");
args = rmic.getCurrentCompilerArgs();
assertNotNull(args);
assertEquals("implementation is weblogic but build.rmic is null",
0, args.length);
project.setProperty("build.rmic", "sun");
args = rmic.getCurrentCompilerArgs();
assertNotNull(args);
assertEquals("implementation is weblogic but build.rmic is sun",
0, args.length);
project.setProperty("build.rmic", "weblogic");
args = rmic.getCurrentCompilerArgs();
assertEquals("both are weblogic", 1, args.length);
assertEquals(testArg, args[0]);
}
/**
* Test compiler attribute.
*/
public void testCompilerAttribute() {
// check defaults
String compiler = rmic.getCompiler();
assertNotNull(compiler);
assertTrue("default value",
"sun".equals(compiler) || "kaffe".equals(compiler));
project.setNewProperty("build.rmic", "weblogic");
compiler = rmic.getCompiler();
assertNotNull(compiler);
assertEquals("weblogic", compiler);
// check attribute overrides build.compiler
rmic.setCompiler("kaffe");
compiler = rmic.getCompiler();
assertNotNull(compiler);
assertEquals("kaffe", compiler);
}
}
1.2 +1 -0
jakarta-ant/src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java
Index: FacadeTaskHelperTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FacadeTaskHelperTest.java 15 Apr 2002 12:51:56 -0000 1.1
+++ FacadeTaskHelperTest.java 15 Apr 2002 13:20:26 -0000 1.2
@@ -58,6 +58,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
+ * @since Ant 1.5
*/
public class FacadeTaskHelperTest extends TestCase {
1.2 +1 -0
jakarta-ant/src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java
Index: ImplementationSpecificArgumentTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ImplementationSpecificArgumentTest.java 15 Apr 2002 12:51:56 -0000
1.1
+++ ImplementationSpecificArgumentTest.java 15 Apr 2002 13:20:26 -0000
1.2
@@ -58,6 +58,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
+ * @since Ant 1.5
*/
public class ImplementationSpecificArgumentTest extends TestCase {
1.9 +5 -6 jakarta-ant/xdocs/ant15_todo.xml
Index: ant15_todo.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/xdocs/ant15_todo.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ant15_todo.xml 15 Apr 2002 12:30:27 -0000 1.8
+++ ant15_todo.xml 15 Apr 2002 13:20:26 -0000 1.9
@@ -96,12 +96,6 @@
</tr>
<tr>
- <td>compiler attribute for rmic</td>
- <td></td>
- <td>Stefan, others welcome</td>
- </tr>
-
- <tr>
<td>JUnit's System.err/.out handling</td>
<td>Currently this is coupled to SummaryResultFormatter -
no SummaryFormatter, no output. Want to decouple it.</td>
@@ -138,6 +132,11 @@
<td>update to release, add uptodateness, add a web service
import (for Axis interop testing)</td>
<td>Steve, in a really long meeting</td>
+ </tr>
+ <tr>
+ <td>compiler attribute for rmic</td>
+ <td></td>
+ <td>Stefan</td>
</tr>
<tr>
<td>PGP signing task if possible</td>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>