git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272440 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -299,6 +299,12 @@ Other changes: | |||||
| * An alias of <xslt> has been added to refer to the <style> task. | * 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 | Changes from Ant 1.4 to Ant 1.4.1 | ||||
| =========================================== | =========================================== | ||||
| @@ -360,26 +360,6 @@ | |||||
| <font color="#000000" size="-1" face="arial,helvetica,sanserif"> | <font color="#000000" size="-1" face="arial,helvetica,sanserif"> | ||||
| Stefan, others welcome | Stefan, others welcome | ||||
| </font> | </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, others welcome | |||||
| </font> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| @@ -475,6 +455,26 @@ | |||||
| <font color="#000000" size="-1" face="arial,helvetica,sanserif"> | <font color="#000000" size="-1" face="arial,helvetica,sanserif"> | ||||
| Steve, in a really long meeting | Steve, in a really long meeting | ||||
| </font> | </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> | </td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| @@ -30,8 +30,9 @@ supports all attributes of <code><fileset></code> | |||||
| (<code>dir</code> becomes <code>base</code>) as well as the nested | (<code>dir</code> becomes <code>base</code>) as well as the nested | ||||
| <code><include></code>, <code><exclude></code> and | <code><include></code>, <code><exclude></code> and | ||||
| <code><patternset></code> elements.</p> | <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> | <ul> | ||||
| <li>sun (the standard compiler of the JDK)</li> | <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> | <li>kaffe (the standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> | ||||
| @@ -165,12 +166,63 @@ please consult miniRMI's documentation to learn how to use it.</p> | |||||
| <td valign="top">location of installed extensions.</td> | <td valign="top">location of installed extensions.</td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </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> | </table> | ||||
| <h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
| <h4>classpath and extdirs</h4> | <h4>classpath and extdirs</h4> | ||||
| <p><code>Rmic</code>'s <i>classpath</i> and <i>extdirs</i> attributes are <a | <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 | 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> | <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> | <h3>Examples</h3> | ||||
| <pre> <rmic classname="com.xyz.FooBar" base="${build}/classes"/></pre> | <pre> <rmic classname="com.xyz.FooBar" base="${build}/classes"/></pre> | ||||
| <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The | <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The | ||||
| @@ -66,6 +66,7 @@ import org.apache.tools.ant.types.Reference; | |||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | import org.apache.tools.ant.util.SourceFileScanner; | ||||
| import org.apache.tools.ant.util.facade.FacadeTaskHelper; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -134,6 +135,17 @@ public class Rmic extends MatchingTask { | |||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | 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. */ | /** Sets the base directory to output generated class. */ | ||||
| public void setBase(File base) { | public void setBase(File base) { | ||||
| this.baseDir = base; | this.baseDir = base; | ||||
| @@ -363,6 +375,42 @@ public class Rmic extends MatchingTask { | |||||
| return compileList; | 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 { | public void execute() throws BuildException { | ||||
| if (baseDir == null) { | if (baseDir == null) { | ||||
| throw new BuildException("base attribute must be set!", location); | throw new BuildException("base attribute must be set!", location); | ||||
| @@ -375,8 +423,7 @@ public class Rmic extends MatchingTask { | |||||
| log("Verify has been turned on.", Project.MSG_INFO); | 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 | // now we need to populate the compiler adapter | ||||
| adapter.setRmic(this); | adapter.setRmic(this); | ||||
| @@ -573,5 +620,19 @@ public class Rmic extends MatchingTask { | |||||
| public ClassLoader getLoader() { | public ClassLoader getLoader() { | ||||
| return loader; | 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); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -246,6 +246,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
| cmd.createArgument().setValue("-g"); | cmd.createArgument().setValue("-g"); | ||||
| } | } | ||||
| cmd.addArguments(attributes.getCurrentCompilerArgs()); | |||||
| logAndAddFilesToCompile(cmd); | logAndAddFilesToCompile(cmd); | ||||
| return cmd; | return cmd; | ||||
| } | } | ||||
| @@ -90,26 +90,6 @@ public class RmicAdapterFactory { | |||||
| */ | */ | ||||
| public static RmicAdapter getRmic(String rmicType, Task task) | public static RmicAdapter getRmic(String rmicType, Task task) | ||||
| throws BuildException { | 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")) { | if (rmicType.equalsIgnoreCase("sun")) { | ||||
| return new SunRmic(); | return new SunRmic(); | ||||
| } else if (rmicType.equalsIgnoreCase("kaffe")) { | } else if (rmicType.equalsIgnoreCase("kaffe")) { | ||||
| @@ -0,0 +1,141 @@ | |||||
| /* | |||||
| * 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 apache@apache.org. | |||||
| * | |||||
| * 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:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| * @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); | |||||
| } | |||||
| } | |||||
| @@ -58,6 +58,7 @@ import junit.framework.TestCase; | |||||
| /** | /** | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.5 | |||||
| */ | */ | ||||
| public class FacadeTaskHelperTest extends TestCase { | public class FacadeTaskHelperTest extends TestCase { | ||||
| @@ -58,6 +58,7 @@ import junit.framework.TestCase; | |||||
| /** | /** | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.5 | |||||
| */ | */ | ||||
| public class ImplementationSpecificArgumentTest extends TestCase { | public class ImplementationSpecificArgumentTest extends TestCase { | ||||
| @@ -95,12 +95,6 @@ | |||||
| <td>Stefan, others welcome</td> | <td>Stefan, others welcome</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td>compiler attribute for rmic</td> | |||||
| <td></td> | |||||
| <td>Stefan, others welcome</td> | |||||
| </tr> | |||||
| <tr> | <tr> | ||||
| <td>JUnit's System.err/.out handling</td> | <td>JUnit's System.err/.out handling</td> | ||||
| <td>Currently this is coupled to SummaryResultFormatter - | <td>Currently this is coupled to SummaryResultFormatter - | ||||
| @@ -139,6 +133,11 @@ | |||||
| import (for Axis interop testing)</td> | import (for Axis interop testing)</td> | ||||
| <td>Steve, in a really long meeting</td> | <td>Steve, in a really long meeting</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td>compiler attribute for rmic</td> | |||||
| <td></td> | |||||
| <td>Stefan</td> | |||||
| </tr> | |||||
| <tr> | <tr> | ||||
| <td>PGP signing task if possible</td> | <td>PGP signing task if possible</td> | ||||
| <td>Not done, but deemed impossible - at least in the 1.5 | <td>Not done, but deemed impossible - at least in the 1.5 | ||||