bodewig 2005/02/04 00:13:48 Modified: . Tag: ANT_16_BRANCH WHATSNEW build.xml docs/manual/OptionalTasks Tag: ANT_16_BRANCH javah.html native2ascii.html src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH ExecuteJava.java LogOutputStream.java Redirector.java src/main/org/apache/tools/ant/taskdefs/compilers Tag: ANT_16_BRANCH Kjc.java src/main/org/apache/tools/ant/taskdefs/optional Tag: ANT_16_BRANCH Javah.java Native2Ascii.java src/main/org/apache/tools/ant/taskdefs/optional/junit Tag: ANT_16_BRANCH JUnitTask.java src/main/org/apache/tools/ant/taskdefs/rmic Tag: ANT_16_BRANCH KaffeRmic.java src/main/org/apache/tools/ant/types Tag: ANT_16_BRANCH CommandlineJava.java src/main/org/apache/tools/ant/util Tag: ANT_16_BRANCH ConcatFileInputStream.java JavaEnvUtils.java LeadPipeInputStream.java Added: src/main/org/apache/tools/ant/taskdefs/optional/javah Tag: ANT_16_BRANCH JavahAdapter.java JavahAdapterFactory.java Kaffeh.java SunJavah.java src/main/org/apache/tools/ant/taskdefs/optional/native2ascii Tag: ANT_16_BRANCH DefaultNative2Ascii.java KaffeNative2Ascii.java Native2AsciiAdapter.java Native2AsciiAdapterFactory.java SunNative2Ascii.java Log: Merge Kaffe related changes from HEAD Revision Changes Path No revision No revision 1.503.2.174 +29 -239 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.173 retrieving revision 1.503.2.174 diff -u -r1.503.2.173 -r1.503.2.174 --- WHATSNEW 3 Feb 2005 19:29:11 -0000 1.503.2.173 +++ WHATSNEW 4 Feb 2005 08:13:45 -0000 1.503.2.174 @@ -23,6 +23,11 @@ * Javadoc fixes for Location, Project, and RuntimeConfigurable Bugzilla 30160. +* Enable to choose the regexp implementation without system property. + Bugzilla Report 15390. + +* Expose objects and methods in IntrospectionHelper. Bugzilla Report 30794. + * Allow file attribute of <move> to rename a directory. Bugzilla Report 22863. @@ -89,6 +94,8 @@ * Added length task to get strings' and files' lengths. +* <native2ascii> and <javah> now also support Kaffe's versions. + * Recursive token expansion in a filterset can now be disabled by setting its recurse attribute to false. @@ -101,27 +108,27 @@ * Target Location was always UNKNOWN_LOCATION due to an omitted merge. * Impossible to use implicit classpath for <taskdef> - when Ant core loader != Java application loader and Path.systemClassPath taken from ${java.class.path} - Bugzilla 30161. - -* Enable to choose the regexp implementation without system property. - Bugzilla Report 15390. + when Ant core loader != Java application loader and + Path.systemClassPath taken from ${java.class.path} Bugzilla 30161. -* MacroInstance did not clean up nested elements correctly in the execute method, causing - multiple use of the same macro instance with nested elements to fail. +* MacroInstance did not clean up nested elements correctly in the execute + method, causing multiple use of the same macro instance with nested + elements to fail. * checksum fileext property doc wrong. Bugzilla 30787. * FTP task, getTimeDiff method was returning wrong value. Bugzilla 30595. -* Zip task was not zipping when only empty directories were found. Bugzilla 30365. +* Zip task was not zipping when only empty directories were found. + Bugzilla 30365. -* Jar task was not including manifest files when duplicate="preserve" was chosen. Bugzilla 32802. +* Jar task was not including manifest files when duplicate="preserve" was + chosen. Bugzilla 32802. * Classpath was treated in the same way as -lib options. Bugzilla 28046. -* Manual page for cvsversion contained incorrect attributes and did not say since 1.6.1. - Bugzilla 31408. +* Manual page for cvsversion contained incorrect attributes and did not + say since 1.6.1. Bugzilla 31408. * Typo in definition of <cvsversion> task causing it not to be defined. Bugzilla 31403. @@ -220,11 +227,6 @@ attribute to point to. This is the last version of the XSLT stylesheet that is expected to be compatible with Xalan-J 1. -* Expose objects and methods in IntrospectionHelper. Bugzilla Report 30794. - -* Added a comment attribute to the zip task. - Bugzilla report 22793. - Fixed bugs: ----------- @@ -370,6 +372,8 @@ * New attribute "negate" on <propertyset> to invert selection criteria. +* Target now supports a Location member. Bugzilla Report 28599. + * New "pattern" attribute for <date> selector. * <junit> has a new forkmode attribute that controls the number of @@ -406,8 +410,6 @@ * Add deleteonexit attribute to <delete>. -* Target now supports a Location member. Bugzilla Report 28599. - * Added Target.getIf/Unless(). Bugzilla Report 29320. * <fail> has a status attribute that can be used to pass an exit @@ -486,7 +488,6 @@ Other changes: -------------- - * Shipped XML parser is now Xerces-J 2.6.1 * <fixcrlf> has a new attribute - fixlast. Bugzilla Report 23262. @@ -516,227 +517,10 @@ * added support for branch logging via the tag attribute in <cvschangelog> Bugzilla Report 13510. -* added support the groovy language in the script and scriptdef tasks. - - -Changes from Ant 1.6.B3 to Ant 1.6.0 -==================================== - -Changes that could break older environments: --------------------------------------------- - -* Attempts to read input in <java> and <exec> tasks will now receive an EOF - rather than blocking. If you run such a process and rely on it blocking, as - it would do in Ant 1.5, you may have problem. - -* <checksum> message "calculating checksum" downgraded to MSG_VERBOSE - to limit output in case of large filesets. - Bugzilla Report 25607. - -* Change logging level of captured standard error output from MSG_ERR to MSG_WARN. - Previous some standard error was output as MSG_ERR and some as MSG_WARN (namely - standard error from exec and forked jvms). - -Fixed bugs: ------------ - -* <xmlcatalog>s only worked when defined inside of tasks. Bugzilla - Report 20965. - -* <xmlcatalog> Wrong file location to URL conversion in XMLCatalog. - Bugzilla Report 23913. - -* <checksum> was throwing a null pointer exception, when used with nested filesets - and totalproperty attribute not set. - Bugzilla Report 25606. - -Other changes: --------------- - -Changes from Ant 1.6.B2 to Ant 1.6.B3 -===================================== - -Changes that could break older environments: --------------------------------------------- -* Changed namespace processing. The namespace uri - of nested elements of a type or a task are now the - same as the type or task. Previously the namespace uri - of nested elements was ant's namespace uri. This change will affect users - of ant 1.6b1 and ant 1.6b2. - -* <csc>'s executable attribute defaults to mcs on non-Windows platforms. - -Fixed bugs: ------------ -* the <java> task checks that the Main method of the class to be executed is static, - and fails with a decent BuildException if it is not the case - -* a space at the end of the Ant-Version line of the default manifest has been removed - -* better debugging support for ApacheCatalogResolver - Bugzilla Report 24070. - -* better report of exceptions in the renaming of the old file in <zip update="true"/> - and the derived classes <jar>, ... - -* use of <parallel> and xmlns:prefix="antlib:package" - -* user and new arguments were swapped in PropertyHelper setNew and setUser. - Bugzilla Report 23966. - -* <style/> be able to resolve entities inside stylesheets. - -* <csc> and other .NET tasks : fixed Error when compiling many source files. - Bugzilla Report 19630. - -* <junit> Make properties available in timed-out tests. - Bugzilla Report 23935. - -* <junit> Pull ant-launcher.jar in the runtime as well. - -* <telnet> : better support for people debugging timed out reads. - -* <ssh> : parse properly return codes from server. - Also fix for Bugzilla Report 23986. - -* <scp> If remotedir has been omitted, make it default to "." . - Bugzilla Report 23987. - -* starteam tasks : insure proper disconnect from the server. - Bugzilla Report 24110. - -* <script>, <scriptdef> - fix problem : script task cannot cope with undefined task/type elements in buildfile - Bugzilla Report 23915. - -* <cvstagdiff> had a problem with aliased modules and with requests for multiple modules. - Bugzilla Reports 21373 and 22877. - -* <cvstagdiff> could not parse properly the revision number of new files with CVS 1.11.9 or higher. - Bugzilla Report 24406. +* added support the groovy language in the script and scriptdef tasks -* <ftp> null pointer exception when attempting rmdir in an empty directory. - Bugzilla Report 24440. - -* <scp> could corrupt files when transfering lots of files. - Bugzilla Report 24449. - -* <jdepend> Fix NPE - Bugzilla Report 24344. - - -Other changes: --------------- -* Attributes in the template bodies of <macrodef> are now denoted by @{attribute} instead of ${attribute} - -* <concat> will expand properties entered in the text of the tag - -* <exec> resolution behavior (resolveexecutable attribute) has been improved - -* running.html has been augmented with a list of the magic properties - -* welcome.html documentation has been updated - -* Change default uri from ant:core to antlib:org.apache.tools.ant - -* upgrade to xml-apis.jar from Xerces-J 2.6.0. - -* Shipped XML parser is now Xerces 2.6.0 - -* set project for created targets. - -* make sure that the checkstyle stylesheets make their way into the distribution. - -* improve ant's own build file concerning the sources which depend upon bsf (rhino). - -* a number of documentation corrections. - Bugzilla reports 24059, 24060, 24069, 24074. - -* replacement of accentuated characters in the source code (actually in JavaDoc comments) - by UNICODE escapes. - Bugzilla report 23919. - -* load all xml resources for typedef not just the first - Bugzilla report 24024 - -* <presetdef> fix so that the preset attributes are optional and - may be overridded (previosly the attributes were set twice) - -* provide stack for errors using import, ant, antcall, subant and macros - -* import task uses the FileUtils#resolveFile method to resolve the imported file, - in order to avoid trouble on Windows or Netware - -* ignore attributes from different URIS - -* <jdepend> - fix timeout attribute of jdepend - add unit tests - add includeruntime to allow unittests to run - checkstyle -Changes from Ant 1.6.B1 to Ant 1.6.B2 -===================================== - -Changes that could break older environments: --------------------------------------------- - -Fixed bugs: ------------ - -* fix usage of mixed case names of add(typedef) introspection. - fix by moving the tolower method from unknownelement to introspectionhelper. - -* documentation added for -lib option used when starting ant via launcher - Bugzilla Report 23454. - -* user-friendly messages added for incorrect use of -lib option - Bugzilla Report 23454. - -* make <input/> be skipped when a property is already set - Bugzilla Report 19967. - -* improved cleanup of temporary files - this concerns <javadoc/>, <replace/>, <zip/>, <javac/>, <cvstagdiff/>, <cab/>, - <replaceregexp/>, <junit/>, metamata tasks, sitraka tasks, <symlink/> - temporary files are now marked with deleteOnExit - Bugzilla Report 17512. - -* Reuse the resolution logic of <property> inside <loadproperties>. - So <expandproperties/> is not needed any more together with <loadproperties/> - Bugzilla Report 17782. - -* Comparison of TemplateElement(s) and Attribute(s) fixed inside macrodef. - -* Don't silently swallow exceptions when something is wrong with adding or removing - shutdown hooks , Bugzilla Report 23609. - -* noinform attribute for Websphere element of <ejbjar/> - Bugzilla Report 23535. - -* <junit/> (JunitTestRunner) - Don't mask arbitrary exceptions when looking for a suite method. - Bugzilla Report 23033. - -* <ftp/> fix problem with relative remotedir - Bugzilla Report 23833. - -* ssh tasks : make .ssh/known_hosts optional - -* <vssget/> was sending a wrong command line prefix for labels -VL-Lsome.label - this change fixes it to -VLsome.label instead - -* <zipfileset/> allow it to refer to a fileset, to which zipfileset specific attributes are added - this solves one frequent use case in the <war/> task - -Other changes: --------------- - -* add an optional attribute to <import/> - -* upgrade protected access to public for setMacroDef for macroinstance object - -Changes from Ant 1.5.4 to Ant 1.6 -================================= +Changes from Ant 1.5.4 to Ant 1.6.0 +=================================== Changes that could break older environments: -------------------------------------------- @@ -811,6 +595,9 @@ are resolved at a later stage. This causes some differences especially for user defined task containers. +* <checksum> log message "Calculating checksum ..." has been degraded + from INFO to VERBOSE. + Fixed bugs: ----------- * Filter readers were not handling line endings properly. Bugzilla @@ -1004,6 +791,9 @@ Other changes: -------------- + +* Shipped XML parser is now Xerces 2.6.0 + * All tasks can be used outside of <target>s. Note that some tasks will not work at all outside of targets as they would cause infinite loops (<antcall> as well as <ant> and <subant> if they invoke the 1.392.2.37 +4 -13 ant/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/ant/build.xml,v retrieving revision 1.392.2.36 retrieving revision 1.392.2.37 diff -u -r1.392.2.36 -r1.392.2.37 --- build.xml 29 Oct 2004 07:43:16 -0000 1.392.2.36 +++ build.xml 4 Feb 2005 08:13:45 -0000 1.392.2.37 @@ -4,12 +4,12 @@ ======================================================================= Apache Ant own build file - Copyright (c) 2000-2004 The Apache Software Foundation. All rights + Copyright (c) 2000-2005 The Apache Software Foundation. All rights reserved. ======================================================================= --> -<project default="main" basedir="."> +<project name="apache-ant" default="main" basedir="."> <!-- Give user a chance to override without editing this file (and without typing -D each time it compiles it) --> @@ -152,15 +152,6 @@ </or> </selector> - <!-- classes that should be present in Sun based JVMs, but not in - Kaffe for example --> - <selector id="needs.sun.tools"> - <or> - <filename name="${optional.package}/Native2Ascii*"/> - <filename name="${optional.package}/Javah*"/> - </or> - </selector> - <selector id="needs.sun.uue"> <filename name="${ant.package}/taskdefs/email/UUMailer*"/> </selector> @@ -168,6 +159,7 @@ <selector id="needs.sun.b64"> <or> <filename name="${optional.package}/splash/SplashTask*"/> + <filename name="${optional.package}/splash/SplashScreenTest.java"/> </or> </selector> @@ -448,7 +440,7 @@ classname="jdepend.framework.JDepend" classpathref="classpath"/> <available property="log4j.present" - classname="org.apache.log4j.Category" + classname="org.apache.log4j.Logger" classpathref="classpath"/> <available property="commons.logging.present" classname="org.apache.commons.logging.LogFactory" @@ -615,7 +607,6 @@ <or> <selector refid="needs.jdk1.3+" unless="jdk1.3+"/> <selector refid="needs.jdk1.4+" unless="jdk1.4+"/> - <selector refid="needs.sun.tools" unless="sun.tools.present"/> <selector refid="needs.sun.uue" unless="sunuue.present"/> <selector refid="needs.sun.b64" unless="base64.present"/> No revision No revision 1.6.2.4 +61 -1 ant/docs/manual/OptionalTasks/javah.html Index: javah.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/javah.html,v retrieving revision 1.6.2.3 retrieving revision 1.6.2.4 diff -u -r1.6.2.3 -r1.6.2.4 --- javah.html 17 May 2004 10:35:41 -0000 1.6.2.3 +++ javah.html 4 Feb 2005 08:13:45 -0000 1.6.2.4 @@ -16,6 +16,16 @@ whether <a href="http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javah.html">JDK1.2</a> (or later) or <a href="http://java.sun.com/products/jdk/1.1/docs/tooldocs/win32/javah.html">pre-JDK1.2</a> 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> +<ul> + <li>default - the default compiler (kaffeh or sun) for the platform.</li> + <li>sun (the standard compiler of the JDK)</li> + <li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> +</ul> + <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tr> @@ -75,8 +85,58 @@ <td valign="top"> location of installed extensions.</td> <td valign="top" align="center">No</td> </tr> + <tr> + <td valign="top">implementation</td> + <td valign="top">The compiler implementation to use. If this + attribute is not set, the default compiler for the current VM + will be used. (See the above <a + href="#implementationvalues">list</a> of valid compilers.)</td> + <td align="center" valign="top">No</td> + </tr> </table> <p>Either outputFile or destdir must be supplied, but not both. </p> + +<h3>Parameters specified as nested elements</h3> + +<h4>arg</h4> + +<p>You can specify additional command line arguments for the compiler +with nested <code><arg></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">implementation</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="#implementationvalues">list</a> of valid compilers.)</td> + <td align="center">No</td> + </tr> +</table> + <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 @@ -111,7 +171,7 @@ describe its progress.</p> <hr> -<p align="center">Copyright © 2001-2002,2004 The Apache Software Foundation. All rights +<p align="center">Copyright © 2001-2002,2004-2005 The Apache Software Foundation. All rights Reserved.</p> </body> 1.8.2.4 +61 -2 ant/docs/manual/OptionalTasks/native2ascii.html Index: native2ascii.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/native2ascii.html,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -u -r1.8.2.3 -r1.8.2.4 --- native2ascii.html 19 Nov 2004 09:10:04 -0000 1.8.2.3 +++ native2ascii.html 4 Feb 2005 08:13:45 -0000 1.8.2.4 @@ -41,6 +41,15 @@ and <code><patternset></code> elements. </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> + <ul> + <li>default - the default converter (kaffe or sun) for the platform.</li> + <li>sun (the standard converter of the JDK)</li> + <li>kaffe (the standard converter of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li> + </ul> + <table border="1" cellpadding="2" cellspacing="0"> <tr> <td><b>Attribute</b></td> @@ -50,7 +59,8 @@ <tr> <td>reverse</td> <td>Reverse the sense of the conversion, - i.e. convert from ASCII to native</td> + i.e. convert from ASCII to native <b>only supported by the + sun converter</b></td> <td align="center">No</td> </tr> <tr> @@ -106,8 +116,57 @@ taken to be an exclude pattern</td> <td align="center">No</td> </tr> + <tr> + <td valign="top">implementation</td> + <td valign="top">The converter implementation to use. + If this attribute is not set, the default converter for the + current VM will be used. (See the above <a + href="#implementationvalues">list</a> of valid converters.)</td> + <td align="center" valign="top">No</td> + </tr> </table> +<h3>Parameters specified as nested elements</h3> + +<h4>arg</h4> + +<p>You can specify additional command line arguments for the converter +with nested <code><arg></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 converter 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">implementation</td> + <td>Only pass the specified argument if the chosen converter + implementation matches the value of this attribute. Legal values + are the same as those in the above <a + href="#implementationvalues">list</a> of valid compilers.)</td> + <td align="center">No</td> + </tr> +</table> + <h3>Examples</h3> <pre> @@ -134,6 +193,6 @@ </p> </body> <hr> -<p align="center">Copyright © 2000-2002,2004 The Apache Software Foundation. All rights +<p align="center">Copyright © 2000-2002,2004-2005 The Apache Software Foundation. All rights Reserved.</p> </html> No revision No revision 1.38.2.6 +48 -2 ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java Index: ExecuteJava.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v retrieving revision 1.38.2.5 retrieving revision 1.38.2.6 diff -u -r1.38.2.5 -r1.38.2.6 --- ExecuteJava.java 9 Mar 2004 17:01:33 -0000 1.38.2.5 +++ ExecuteJava.java 4 Feb 2005 08:13:46 -0000 1.38.2.6 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,10 @@ * */ - package org.apache.tools.ant.taskdefs; +import java.io.File; +import java.io.IOException; import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -25,11 +26,14 @@ import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Permissions; +import org.apache.tools.ant.util.JavaEnvUtils; import org.apache.tools.ant.util.TimeoutObserver; import org.apache.tools.ant.util.Watchdog; @@ -174,6 +178,7 @@ if (loader != null) { loader.resetThreadContextLoader(); loader.cleanup(); + loader = null; } if (sysProperties != null) { sysProperties.restoreSystem(); @@ -225,4 +230,45 @@ public synchronized boolean killedProcess() { return timedOut; } + + /** + * Runs the Java command in a separate VM, this does not give you + * the full flexibility of the Java task, but may be enough for + * simple needs. + * + * @since Ant 1.6.3 + */ + public int fork(ProjectComponent pc) throws BuildException { + CommandlineJava cmdl = new CommandlineJava(); + cmdl.setClassname(javaCommand.getExecutable()); + String[] args = javaCommand.getArguments(); + for (int i = 0; i < args.length; i++) { + cmdl.createArgument().setValue(args[i]); + } + if (classpath != null) { + cmdl.createClasspath(pc.getProject()).append(classpath); + } + if (sysProperties != null) { + cmdl.addSysproperties(sysProperties); + } + + Redirector redirector = new Redirector(pc); + Execute exe + = new Execute(redirector.createHandler(), + timeout == null + ? null + : new ExecuteWatchdog(timeout.longValue())); + exe.setAntRun(pc.getProject()); + exe.setCommandline(cmdl.getCommandline()); + + try { + int rc = exe.execute(); + redirector.complete(); + timedOut = exe.killedProcess(); + return rc; + } catch (IOException e) { + throw new BuildException(e); + } + } + } 1.16.2.6 +16 -4 ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java Index: LogOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java,v retrieving revision 1.16.2.5 retrieving revision 1.16.2.6 diff -u -r1.16.2.5 -r1.16.2.6 --- LogOutputStream.java 11 Mar 2004 11:22:56 -0000 1.16.2.5 +++ LogOutputStream.java 4 Feb 2005 08:13:46 -0000 1.16.2.6 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; @@ -48,7 +49,7 @@ = new ByteArrayOutputStream(INTIAL_SIZE); private boolean skip = false; - private Task task; + private ProjectComponent pc; private int level = Project.MSG_INFO; /** @@ -58,7 +59,18 @@ * @param level loglevel used to log data written to this stream. */ public LogOutputStream(Task task, int level) { - this.task = task; + this((ProjectComponent) task, level); + } + + /** + * Creates a new instance of this class. + * + * @param task the task for whom to log + * @param level loglevel used to log data written to this stream. + * @since Ant 1.6.3 + */ + public LogOutputStream(ProjectComponent pc, int level) { + this.pc = pc; this.level = level; } @@ -114,7 +126,7 @@ * @param line the line to log. */ protected void processLine(String line, int level) { - task.log(line, level); + pc.log(line, level); } 1.11.2.11 +21 -9 ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java Index: Redirector.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java,v retrieving revision 1.11.2.10 retrieving revision 1.11.2.11 diff -u -r1.11.2.10 -r1.11.2.11 --- Redirector.java 6 Jan 2005 17:30:03 -0000 1.11.2.10 +++ Redirector.java 4 Feb 2005 08:13:46 -0000 1.11.2.11 @@ -31,8 +31,9 @@ import java.util.Arrays; import java.util.Vector; -import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; +import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.filters.util.ChainReaderHelper; import org.apache.tools.ant.util.StringUtils; @@ -46,7 +47,7 @@ /** * The Redirector class manages the setup and connection of - * input and output redirection for an Ant task. + * input and output redirection for an Ant project component. * * @since Ant 1.6 */ @@ -125,7 +126,7 @@ private boolean createEmptyFiles = true; /** The task for which this redirector is working */ - private Task managingTask; + private ProjectComponent managingTask; /** The stream for output data */ private OutputStream outputStream = null; @@ -172,6 +173,17 @@ * @param managingTask the task for which the redirector is to work */ public Redirector(Task managingTask) { + this((ProjectComponent) managingTask); + } + + /** + * Create a redirector instance for the given task + * + * @param managingTask the project component for which the + * redirector is to work + * @since Ant 1.6.3 + */ + public Redirector(ProjectComponent managingTask) { this.managingTask = managingTask; } @@ -489,8 +501,8 @@ || !(outputEncoding.equalsIgnoreCase(inputEncoding))) { try { LeadPipeInputStream snk = new LeadPipeInputStream(); - snk.setManagingTask(managingTask); - + snk.setManagingComponent(managingTask); + InputStream outPumpIn = snk; Reader reader = new InputStreamReader(outPumpIn, inputEncoding); @@ -518,8 +530,8 @@ || !(errorEncoding.equalsIgnoreCase(inputEncoding))) { try { LeadPipeInputStream snk = new LeadPipeInputStream(); - snk.setManagingTask(managingTask); - + snk.setManagingComponent(managingTask); + InputStream errPumpIn = snk; Reader reader = new InputStreamReader(errPumpIn, inputEncoding); @@ -554,7 +566,7 @@ } catch (IOException eyeOhEx) { throw new BuildException(eyeOhEx); } - ((ConcatFileInputStream)inputStream).setManagingTask(managingTask); + ((ConcatFileInputStream) inputStream).setManagingComponent(managingTask); } else if (inputString != null) { managingTask.log("Using input \"" + inputString + "\"", Project.MSG_VERBOSE); @@ -773,7 +785,7 @@ Arrays.fill(c, ' '); String indent = new String(c); - for (int i = 1; i < file.length ; i++) { + for (int i = 1; i < file.length; i++) { outputStream = new TeeOutputStream(outputStream, new LazyFileOutputStream(file[i], append, createEmptyFiles)); managingTask.log(indent + file[i], loglevel); No revision No revision 1.14.2.5 +7 -28 ant/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java Index: Kjc.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java,v retrieving revision 1.14.2.4 retrieving revision 1.14.2.5 diff -u -r1.14.2.4 -r1.14.2.5 --- Kjc.java 9 Mar 2004 17:01:38 -0000 1.14.2.4 +++ Kjc.java 4 Feb 2005 08:13:46 -0000 1.14.2.5 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation + * Copyright 2001-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ package org.apache.tools.ant.taskdefs.compilers; -import java.lang.reflect.Method; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.ExecuteJava; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; @@ -40,31 +40,10 @@ public boolean execute() throws BuildException { attributes.log("Using kjc compiler", Project.MSG_VERBOSE); Commandline cmd = setupKjcCommand(); - - try { - Class c = Class.forName("at.dms.kjc.Main"); - - // Call the compile() method - Method compile = c.getMethod("compile", - new Class [] {String [].class}); - Boolean ok = - (Boolean) compile.invoke(null, - new Object[] {cmd.getArguments()}); - return ok.booleanValue(); - } catch (ClassNotFoundException ex) { - throw new BuildException("Cannot use kjc compiler, as it is not " - + "available. A common solution is to " - + "set the environment variable CLASSPATH " - + "to your kjc archive (kjc.jar).", - location); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException("Error starting kjc compiler: ", - ex, location); - } - } + cmd.setExecutable("at.dms.kjc.Main"); + ExecuteJava ej = new ExecuteJava(); + ej.setJavaCommand(cmd); + return ej.fork(getJavac()) == 0; } /** @@ -91,7 +70,7 @@ Path cp = new Path(project); // kjc don't have bootclasspath option. - if (bootclasspath != null) { + if (bootclasspath != null && bootclasspath.size() > 0) { cp.append(bootclasspath); } No revision No revision 1.27.2.5 +153 -156 ant/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java Index: Javah.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java,v retrieving revision 1.27.2.4 retrieving revision 1.27.2.5 diff -u -r1.27.2.4 -r1.27.2.5 --- Javah.java 9 Mar 2004 17:01:41 -0000 1.27.2.4 +++ Javah.java 4 Feb 2005 08:13:46 -0000 1.27.2.5 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,18 +18,21 @@ package org.apache.tools.ant.taskdefs.optional; import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter; +import org.apache.tools.ant.taskdefs.optional.javah.JavahAdapterFactory; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.JavaEnvUtils; +import org.apache.tools.ant.util.facade.FacadeTaskHelper; +import org.apache.tools.ant.util.facade.ImplementationSpecificArgument; /** * Generates JNI header files using javah. @@ -76,6 +79,11 @@ private Path bootclasspath; //private Path extdirs; private static String lSep = System.getProperty("line.separator"); + private FacadeTaskHelper facade = null; + + public Javah() { + facade = new FacadeTaskHelper(JavahAdapterFactory.getDefault()); + } /** * the fully-qualified name of the class (or classes, separated by commas). @@ -101,7 +109,6 @@ public void setName(String name) { this.name = name; - log("ClassArgument.name=" + name); } public String getName() { @@ -110,6 +117,28 @@ } /** + * Names of the classes to process. + * + * @since Ant 1.6.3 + */ + public String[] getClasses() { + ArrayList al = new ArrayList(); + if (cls != null) { + StringTokenizer tok = new StringTokenizer(cls, ",", false); + while (tok.hasMoreTokens()) { + al.add(tok.nextToken().trim()); + } + } + + Enumeration e = classes.elements(); + while (e.hasMoreElements()) { + ClassArgument arg = (ClassArgument) e.nextElement(); + al.add(arg.getName()); + } + return (String[]) al.toArray(new String[0]); + } + + /** * Set the destination directory into which the Java source * files should be compiled. */ @@ -118,6 +147,15 @@ } /** + * The destination directory, if any. + * + * @since Ant 1.6.3 + */ + public File getDestdir() { + return destDir; + } + + /** * the classpath to use. */ public void setClasspath(Path src) { @@ -147,6 +185,15 @@ } /** + * The classpath to use. + * + * @since Ant 1.6.3 + */ + public Path getClasspath() { + return classpath; + } + + /** * location of bootstrap class files. */ public void setBootclasspath(Path src) { @@ -175,27 +222,14 @@ createBootclasspath().setRefid(r); } - ///** - // * Sets the extension directories that will be used during the - // * compilation. - // */ - //public void setExtdirs(Path extdirs) { - // if (this.extdirs == null) { - // this.extdirs = extdirs; - // } else { - // this.extdirs.append(extdirs); - // } - //} - - ///** - // * Maybe creates a nested classpath element. - // */ - //public Path createExtdirs() { - // if (extdirs == null) { - // extdirs = new Path(project); - // } - // return extdirs.createPath(); - //} + /** + * The bootclasspath to use. + * + * @since Ant 1.6.3 + */ + public Path getBootclasspath() { + return bootclasspath; + } /** * Concatenates the resulting header or source files for all @@ -206,6 +240,15 @@ } /** + * The destination file, if any. + * + * @since Ant 1.6.3 + */ + public File getOutputfile() { + return outputFile; + } + + /** * If true, output files should always be written (JDK1.2 only). */ public void setForce(boolean force) { @@ -213,6 +256,15 @@ } /** + * Whether output files should always be written. + * + * @since Ant 1.6.3 + */ + public boolean getForce() { + return force; + } + + /** * If true, specifies that old JDK1.0-style header files should be * generated. * (otherwise output file contain JNI-style native method function prototypes) (JDK1.2 only) @@ -222,6 +274,15 @@ } /** + * Whether old JDK1.0-style header files should be generated. + * + * @since Ant 1.6.3 + */ + public boolean getOld() { + return old; + } + + /** * If true, generate C declarations from the Java object file (used with old). */ public void setStubs(boolean stubs) { @@ -229,6 +290,15 @@ } /** + * Whether C declarations from the Java object file should be generated. + * + * @since Ant 1.6.3 + */ + public boolean getStubs() { + return stubs; + } + + /** * If true, causes Javah to print a message concerning * the status of the generated files. */ @@ -237,6 +307,51 @@ } /** + * Whether verbose output should get generated. + * + * @since Ant 1.6.3 + */ + public boolean getVerbose() { + return verbose; + } + + /** + * Choose the implementation for this particular task. + * @param impl the name of the implemenation + * @since Ant 1.6.3 + */ + public void setImplementation(String impl) { + if ("default".equals(impl)) { + facade.setImplementation(JavahAdapterFactory.getDefault()); + } else { + facade.setImplementation(impl); + } + } + + /** + * Adds an implementation specific command-line argument. + * @return a ImplementationSpecificArgument to be configured + * + * @since Ant 1.6.3 + */ + public ImplementationSpecificArgument createArg() { + ImplementationSpecificArgument arg = + new ImplementationSpecificArgument(); + facade.addImplementationArgument(arg); + return arg; + } + + /** + * Returns the (implementation specific) settings given as nested + * arg elements. + * + * @since Ant 1.6.3 + */ + public String[] getCurrentArgs() { + return facade.getArgs(); + } + + /** * Execute the task * * @throws BuildException is there is a problem in the task execution. @@ -271,124 +386,20 @@ classpath = classpath.concatSystemClasspath("ignore"); } - String compiler = getProject().getProperty("build.compiler"); - if (compiler == null) { - if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) - && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { - compiler = "modern"; - } else { - compiler = "classic"; - } - } - - doClassicCompile(); - } - - // XXX - // we need a way to not use the current classpath. - - /** - * Performs a compile using the classic compiler that shipped with - * JDK 1.1 and 1.2. - */ - - private void doClassicCompile() throws BuildException { - Commandline cmd = setupJavahCommand(); - - // Use reflection to be able to build on all JDKs - /* - // provide the compiler a different message sink - namely our own - sun.tools.javac.Main compiler = - new sun.tools.javac.Main(new LogOutputStream(this, Project.MSG_WARN), "javac"); - - if (!compiler.compile(cmd.getArguments())) { - throw new BuildException("Compile failed"); - } - */ - - - try { - Class javahMainClass = null; - try { - // first search for the "old" javah class in 1.4.2 tools.jar - javahMainClass = Class.forName("com.sun.tools.javah.oldjavah.Main"); - } catch (ClassNotFoundException cnfe) { - // assume older than 1.4.2 tools.jar - javahMainClass = Class.forName("com.sun.tools.javah.Main"); - } - - // now search for the constructor that takes in String[] arguments. - Class[] strings = new Class[] {String[].class}; - Constructor constructor = javahMainClass.getConstructor(strings); - - // construct the javah Main instance - Object javahMain = constructor.newInstance(new Object[] {cmd.getArguments()}); - - // find the run method - Method runMethod = javahMainClass.getMethod("run", new Class[0]); - - runMethod.invoke(javahMain, new Object[0]); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException("Error starting javah: " + ex, ex, getLocation()); - } + JavahAdapter ad = + JavahAdapterFactory.getAdapter(facade.getImplementation(), + this); + if (!ad.compile(this)) { + throw new BuildException("compilation failed"); } } /** - * Does the command line argument processing common to classic and - * modern. + * Logs the compilation parameters, adds the files to compile and logs the + * "niceSourceList" */ - private Commandline setupJavahCommand() { - Commandline cmd = new Commandline(); - - if (destDir != null) { - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(destDir); - } - - if (outputFile != null) { - cmd.createArgument().setValue("-o"); - cmd.createArgument().setFile(outputFile); - } - - if (classpath != null) { - cmd.createArgument().setValue("-classpath"); - cmd.createArgument().setPath(classpath); - } - - // JDK1.1 is rather simpler than JDK1.2 - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { - if (verbose) { - cmd.createArgument().setValue("-v"); - } - } else { - if (verbose) { - cmd.createArgument().setValue("-verbose"); - } - if (old) { - cmd.createArgument().setValue("-old"); - } - if (force) { - cmd.createArgument().setValue("-force"); - } - } - - if (stubs) { - if (!old) { - throw new BuildException("stubs only available in old mode.", getLocation()); - } - cmd.createArgument().setValue("-stubs"); - } - if (bootclasspath != null) { - cmd.createArgument().setValue("-bootclasspath"); - cmd.createArgument().setPath(bootclasspath); - } - + public void logAndAddFiles(Commandline cmd) { logAndAddFilesToCompile(cmd); - return cmd; } /** @@ -396,32 +407,18 @@ * "niceSourceList" */ protected void logAndAddFilesToCompile(Commandline cmd) { - int n = 0; log("Compilation " + cmd.describeArguments(), Project.MSG_VERBOSE); StringBuffer niceClassList = new StringBuffer(); - if (cls != null) { - StringTokenizer tok = new StringTokenizer(cls, ",", false); - while (tok.hasMoreTokens()) { - String aClass = tok.nextToken().trim(); - cmd.createArgument().setValue(aClass); - niceClassList.append(" " + aClass + lSep); - n++; - } - } - - Enumeration e = classes.elements(); - while (e.hasMoreElements()) { - ClassArgument arg = (ClassArgument) e.nextElement(); - String aClass = arg.getName(); - cmd.createArgument().setValue(aClass); - niceClassList.append(" " + aClass + lSep); - n++; + String[] c = getClasses(); + for (int i = 0; i < c.length; i++) { + cmd.createArgument().setValue(c[i]); + niceClassList.append(" " + c[i] + lSep); } StringBuffer prefix = new StringBuffer("Class"); - if (n > 1) { + if (c.length > 1) { prefix.append("es"); } prefix.append(" to be compiled:"); 1.17.2.5 +79 -20 ant/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java Index: Native2Ascii.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java,v retrieving revision 1.17.2.4 retrieving revision 1.17.2.5 diff -u -r1.17.2.4 -r1.17.2.5 --- Native2Ascii.java 9 Mar 2004 17:01:41 -0000 1.17.2.4 +++ Native2Ascii.java 4 Feb 2005 08:13:46 -0000 1.17.2.5 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,15 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; +import org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapter; +import org.apache.tools.ant.taskdefs.optional.native2ascii.Native2AsciiAdapterFactory; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Mapper; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.IdentityMapper; import org.apache.tools.ant.util.SourceFileScanner; +import org.apache.tools.ant.util.facade.FacadeTaskHelper; +import org.apache.tools.ant.util.facade.ImplementationSpecificArgument; /** * Converts files from native encodings to ASCII. @@ -42,6 +46,11 @@ private String extension = null; // Extension of output files if different private Mapper mapper; + private FacadeTaskHelper facade = null; + + public Native2Ascii() { + facade = new FacadeTaskHelper(Native2AsciiAdapterFactory.getDefault()); + } /** * Flag the conversion to run in the reverse sense, @@ -55,6 +64,15 @@ } /** + * The value of the reverse attribute. + * + * @since Ant 1.6.3 + */ + public boolean getReverse() { + return reverse; + } + + /** * Set the encoding to translate to/from. * If unset, the default encoding for the JVM is used. * @@ -66,6 +84,15 @@ } /** + * The value of the reverse attribute. + * + * @since Ant 1.6.3 + */ + public String getEncoding() { + return encoding; + } + + /** * Set the source directory in which to find files to convert. * * @param srcDir directory to find input file in. @@ -95,6 +122,19 @@ } /** + * Choose the implementation for this particular task. + * @param impl the name of the implemenation + * @since Ant 1.6.3 + */ + public void setImplementation(String impl) { + if ("default".equals(impl)) { + facade.setImplementation(Native2AsciiAdapterFactory.getDefault()); + } else { + facade.setImplementation(impl); + } + } + + /** * Defines the FileNameMapper to use (nested mapper element). * * @return the mapper to use for file name translations. @@ -111,6 +151,28 @@ } /** + * A nested filenamemapper + * @param fileNameMapper the mapper to add + * @since Ant 1.6.3 + */ + public void add(FileNameMapper fileNameMapper) { + createMapper().add(fileNameMapper); + } + + /** + * Adds an implementation specific command-line argument. + * @return a ImplementationSpecificArgument to be configured + * + * @since Ant 1.6.3 + */ + public ImplementationSpecificArgument createArg() { + ImplementationSpecificArgument arg = + new ImplementationSpecificArgument(); + facade.addImplementationArgument(arg); + return arg; + } + + /** * Execute the task * * @throws BuildException is there is a problem in the task execution. @@ -171,29 +233,15 @@ * @param srcName name of the input file. * @param destName name of the input file. */ - private void convert(String srcName, String destName) throws BuildException { - - Commandline cmd = new Commandline(); // Command line to run + private void convert(String srcName, String destName) + throws BuildException { File srcFile; // File to convert File destFile; // where to put the results - // Set up the basic args (this could be done once, but - // it's cleaner here) - if (reverse) { - cmd.createArgument().setValue("-reverse"); - } - - if (encoding != null) { - cmd.createArgument().setValue("-encoding"); - cmd.createArgument().setValue(encoding); - } - // Build the full file names srcFile = new File(srcDir, srcName); destFile = new File(destDir, destName); - cmd.createArgument().setFile(srcFile); - cmd.createArgument().setFile(destFile); // Make sure we're not about to clobber something if (srcFile.equals(destFile)) { throw new BuildException("file " + srcFile @@ -213,13 +261,24 @@ } log("converting " + srcName, Project.MSG_VERBOSE); - sun.tools.native2ascii.Main n2a - = new sun.tools.native2ascii.Main(); - if (!n2a.convert(cmd.getArguments())) { + Native2AsciiAdapter ad = + Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(), + this); + if (!ad.convert(this, srcFile, destFile)) { throw new BuildException("conversion failed"); } } + /** + * Returns the (implementation specific) settings given as nested + * arg elements. + * + * @since Ant 1.6.3 + */ + public String[] getCurrentArgs() { + return facade.getArgs(); + } + private class ExtMapper implements FileNameMapper { public void setFrom(String s) { No revision No revision 1.1.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapter.java 1.1.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java 1.1.2.1 +0 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java Index: Kaffeh.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- Kaffeh.java 4 Feb 2005 08:08:07 -0000 1.1 +++ Kaffeh.java 4 Feb 2005 08:13:47 -0000 1.1.2.1 @@ -68,7 +68,6 @@ if (javah.getBootclasspath() != null) { cp.append(javah.getBootclasspath()); } - cp = cp.concatSystemBootClasspath("ignore"); if (javah.getClasspath() != null) { cp.append(javah.getClasspath()); } 1.1.2.1 +0 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/SunJavah.java Index: SunJavah.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/javah/SunJavah.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- SunJavah.java 4 Feb 2005 08:08:07 -0000 1.1 +++ SunJavah.java 4 Feb 2005 08:13:47 -0000 1.1.2.1 @@ -105,7 +105,6 @@ if (javah.getBootclasspath() != null) { bcp.append(javah.getBootclasspath()); } - bcp = bcp.concatSystemBootClasspath("ignore"); if (bcp.size() > 0) { cmd.createArgument().setValue("-bootclasspath"); cmd.createArgument().setPath(bcp); No revision No revision 1.83.2.17 +21 -16 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Index: JUnitTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v retrieving revision 1.83.2.16 retrieving revision 1.83.2.17 diff -u -r1.83.2.16 -r1.83.2.17 --- JUnitTask.java 7 Dec 2004 10:30:35 -0000 1.83.2.16 +++ JUnitTask.java 4 Feb 2005 08:13:47 -0000 1.83.2.17 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -771,7 +771,12 @@ Project.MSG_WARN); } - CommandlineJava cmd = (CommandlineJava) getCommandline().clone(); + CommandlineJava cmd = null; + try { + cmd = (CommandlineJava) getCommandline().clone(); + } catch (CloneNotSupportedException e) { + throw new BuildException(e); + } cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"); if (casesFile == null) { @@ -807,7 +812,7 @@ log("Running " + test.getName(), Project.MSG_INFO); cmd.createArgument() .setValue("formatter" - + "=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter"); + + "=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter"); } cmd.createArgument().setValue("showoutput=" @@ -901,7 +906,7 @@ private File createTempPropertiesFile(String prefix) { File propsFile = FileUtils.newFileUtils().createTempFile(prefix, ".properties", - tmpDir != null ? tmpDir : getProject().getBaseDir()); + tmpDir != null ? tmpDir : getProject().getBaseDir()); propsFile.deleteOnExit(); return propsFile; } @@ -1023,7 +1028,7 @@ } CommandlineJava.SysProperties sysProperties = - getCommandline().getSystemProperties(); + getCommandline().getSystemProperties(); if (sysProperties != null) { sysProperties.setSystem(); } @@ -1245,11 +1250,11 @@ //create a special test class that asserts a timout occurred, //and tell the formatter that it raised. Test t = new Test() { - public int countTestCases() { return 1; } - public void run(TestResult r) { - throw new AssertionFailedError("Timeout occurred"); - } - }; + public int countTestCases() { return 1; } + public void run(TestResult r) { + throw new AssertionFailedError("Timeout occurred"); + } + }; formatter.startTest(t); formatter.addError(t, new AssertionFailedError("Timeout occurred")); formatter.endTestSuite(test); @@ -1333,10 +1338,10 @@ */ ForkedTestConfiguration(JUnitTest test) { this(test.getFiltertrace(), - test.getHaltonerror(), - test.getHaltonfailure(), - test.getErrorProperty(), - test.getFailureProperty()); + test.getHaltonerror(), + test.getHaltonfailure(), + test.getErrorProperty(), + test.getFailureProperty()); } /** @@ -1458,7 +1463,7 @@ if ((errorOccurredHere && test.getHaltonerror()) || (failureOccurredHere && test.getHaltonfailure())) { throw new BuildException(name + " failed" - + (wasKilled ? " (timeout)" : ""), getLocation()); + + (wasKilled ? " (timeout)" : ""), getLocation()); } else { log(name + " FAILED" + (wasKilled ? " (timeout)" : ""), Project.MSG_ERR); No revision No revision 1.3.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/DefaultNative2Ascii.java 1.1.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java 1.3.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapter.java 1.1.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java 1.2.2.1 +0 -0 ant/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/SunNative2Ascii.java No revision No revision 1.11.2.6 +6 -18 ant/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java Index: KaffeRmic.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java,v retrieving revision 1.11.2.5 retrieving revision 1.11.2.6 diff -u -r1.11.2.5 -r1.11.2.6 --- KaffeRmic.java 15 Dec 2004 12:31:44 -0000 1.11.2.5 +++ KaffeRmic.java 4 Feb 2005 08:13:47 -0000 1.11.2.6 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2002,2004 The Apache Software Foundation + * Copyright 2001-2002,2004-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,9 @@ package org.apache.tools.ant.taskdefs.rmic; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.ExecuteJava; import org.apache.tools.ant.types.Commandline; /** @@ -57,21 +56,10 @@ getRmic().getLocation()); } - try { - Constructor cons = c.getConstructor(new Class[] {String[].class}); - Object rmic = cons.newInstance(new Object[] {cmd.getArguments()}); - Method doRmic = c.getMethod("run", (Class[]) null); - Boolean ok = (Boolean) doRmic.invoke(rmic, (Object[]) null); - - return ok.booleanValue(); - } catch (BuildException ex) { - //rethrow - throw ex; - } catch (Exception ex) { - //wrap - throw new BuildException("Error starting Kaffe rmic: ", - ex, getRmic().getLocation()); - } + cmd.setExecutable(c.getName()); + ExecuteJava ej = new ExecuteJava(); + ej.setJavaCommand(cmd); + return ej.fork(getRmic()) == 0; } /** No revision No revision 1.47.2.9 +62 -29 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java Index: CommandlineJava.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.47.2.8 retrieving revision 1.47.2.9 diff -u -r1.47.2.8 -r1.47.2.9 --- CommandlineJava.java 28 Oct 2004 09:17:49 -0000 1.47.2.8 +++ CommandlineJava.java 4 Feb 2005 08:13:47 -0000 1.47.2.9 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2004 The Apache Software Foundation + * Copyright 2000-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,17 @@ package org.apache.tools.ant.types; -import java.util.Enumeration; -import java.util.Properties; -import java.util.Vector; -import java.util.List; -import java.util.LinkedList; -import java.util.ListIterator; - import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.util.JavaEnvUtils; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Properties; +import java.util.Vector; + /** * A representation of a Java command line that is * a composite of 2 <tt>Commandline</tt>. One is used for the @@ -75,7 +75,7 @@ * get the properties as an array; this is an override of the * superclass, as it evaluates all the properties * @return the array of definitions; may be null - * @throws BuildException + * @throws BuildException on error */ public String[] getVariables() throws BuildException { @@ -100,10 +100,11 @@ listIt.add("-D" + props[i]); } } - Properties propertySets = mergePropertySets(); - for (Enumeration e = propertySets.keys(); e.hasMoreElements();) { + Properties propertySetProperties = mergePropertySets(); + for (Enumeration e = propertySetProperties.keys(); + e.hasMoreElements();) { String key = (String) e.nextElement(); - String value = propertySets.getProperty(key); + String value = propertySetProperties.getProperty(key); listIt.add("-D" + key + "=" + value); } } @@ -163,8 +164,9 @@ /** * deep clone * @return a cloned instance of SysProperties + * @exception CloneNotSupportedException for signature */ - public Object clone() { + public Object clone() throws CloneNotSupportedException { try { SysProperties c = (SysProperties) super.clone(); c.variables = (Vector) variables.clone(); @@ -184,6 +186,16 @@ } /** + * add a propertyset to the total set + * @param ps the new property set + * @since Ant 1.6.3 + */ + public void addSysproperties(SysProperties ps) { + variables.addAll(ps.variables); + propertySets.addAll(ps.propertySets); + } + + /** * merge all property sets into a single Properties object * @return the merged object */ @@ -196,6 +208,7 @@ } return p; } + } /** @@ -239,16 +252,25 @@ } /** - * set the executable used to start the new JVM - * @param vm + * add a set of system properties + * @param sysp a set of properties + * @since Ant 1.6.3 + */ + public void addSysproperties(SysProperties sysp) { + sysProperties.addSysproperties(sysp); + } + + /** + * Set the executable used to start the new JVM. + * @param vm the executable to use */ public void setVm(String vm) { vmCommand.setExecutable(vm); } /** - * set the JVM version required - * @param value + * Set the JVM version required. + * @param value the version required */ public void setVmversion(String value) { vmVersion = value; @@ -312,6 +334,11 @@ return null; } + /** + * Create a classpath. + * @param p the project to use to create the path in + * @return a path to be configured + */ public Path createClasspath(Project p) { if (classpath == null) { classpath = new Path(p); @@ -320,6 +347,9 @@ } /** + * Create a boot classpath. + * @param p the project to use to create the path in + * @return a path to be configured * @since Ant 1.6 */ public Path createBootclasspath(Project p) { @@ -329,6 +359,10 @@ return bootclasspath; } + /** + * Get the vm version. + * @return the vm version + */ public String getVmversion() { return vmVersion; } @@ -389,6 +423,7 @@ /** * Specify max memory of the JVM * -mx or -Xmx depending on VM version + * @param max the string to pass to the jvm to specifiy the max memory */ public void setMaxmemory(String max) { this.maxMemory = max; @@ -407,7 +442,7 @@ * Returns a String that describes the command and arguments * suitable for verbose output before a call to * <code>Runtime.exec(String[])<code> - * + * @return the description string * @since Ant 1.5 */ public String describeCommand() { @@ -419,7 +454,7 @@ * for in VM executions. * * <p>The class name is the executable in this context.</p> - * + * @return the description string * @since Ant 1.5 */ public String describeJavaCommand() { @@ -450,7 +485,7 @@ * @deprecated please dont use this -it effectively creates the entire command. */ public int size() { - int size = getActualVMCommand().size() + javaCommand.size() + int size = getActualVMCommand().size() + javaCommand.size() + sysProperties.size(); // classpath is "-classpath <classpath>" -> 2 args if (haveClasspath()) { @@ -531,8 +566,10 @@ /** * clone the object; clone of all fields in the class * @return a CommandlineJava object + * @throws BuildException if anything went wrong. + * @throws CloneNotSupportedException never */ - public Object clone() { + public Object clone() throws CloneNotSupportedException { try { CommandlineJava c = (CommandlineJava) super.clone(); c.vmCommand = (Commandline) vmCommand.clone(); @@ -563,7 +600,7 @@ /** * Has the classpath been specified and shall it really be used or * will build.sysclasspath null it? - * + * @return true if the classpath is to be used * @since Ant 1.6 */ protected boolean haveClasspath() { @@ -580,27 +617,23 @@ * * @param log whether to log a warning if a bootclasspath has been * specified but will be ignored. - * + * @return true if the bootclasspath is to be used * @since Ant 1.6 */ protected boolean haveBootclasspath(boolean log) { if (bootclasspath != null && bootclasspath.toString().trim().length() > 0) { - /* - * XXX - need to log something, but there is no ProjectComponent - * around to log to. - */ if (!bootclasspath.toString() .equals(bootclasspath.concatSystemClasspath("ignore") .toString())) { if (log) { - System.out.println("Ignoring bootclasspath as " + bootclasspath.log("Ignoring bootclasspath as " + "build.sysclasspath has been set."); } } else if (vmVersion.startsWith("1.1")) { if (log) { - System.out.println("Ignoring bootclasspath as " + bootclasspath.log("Ignoring bootclasspath as " + "the target VM doesn't support it."); } } else { No revision No revision 1.1.2.3 +15 -5 ant/src/main/org/apache/tools/ant/util/ConcatFileInputStream.java Index: ConcatFileInputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/ConcatFileInputStream.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- ConcatFileInputStream.java 26 Jan 2005 22:07:52 -0000 1.1.2.2 +++ ConcatFileInputStream.java 4 Feb 2005 08:13:47 -0000 1.1.2.3 @@ -23,8 +23,9 @@ import java.io.IOException; import java.io.FileInputStream; -import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectComponent; +import org.apache.tools.ant.Task; /** * Special <CODE>InputStream</CODE> that will @@ -37,7 +38,7 @@ private boolean eof = false; private File[] file; private InputStream currentStream; - private Task managingTask; + private ProjectComponent managingPc; /** * Construct a new <CODE>ConcatFileInputStream</CODE> @@ -71,7 +72,16 @@ * @param task the managing <CODE>Task</CODE>. */ public void setManagingTask(Task task) { - this.managingTask = task; + setManagingComponent(task); + } + + /** + * Set a managing <CODE>Task</CODE> for + * this <CODE>ConcatFileInputStream</CODE>. + * @param task the managing <CODE>Task</CODE>. + */ + public void setManagingComponent(ProjectComponent pc) { + this.managingPc = pc; } /** @@ -80,8 +90,8 @@ * @param loglevel the <CODE>int</CODE> logging level. */ public void log(String message, int loglevel) { - if (managingTask != null) { - managingTask.log(message, loglevel); + if (managingPc != null) { + managingPc.log(message, loglevel); } else { if (loglevel > Project.MSG_WARN) { System.out.println(message); 1.15.2.6 +35 -10 ant/src/main/org/apache/tools/ant/util/JavaEnvUtils.java Index: JavaEnvUtils.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/JavaEnvUtils.java,v retrieving revision 1.15.2.5 retrieving revision 1.15.2.6 diff -u -r1.15.2.5 -r1.15.2.6 --- JavaEnvUtils.java 9 Mar 2004 17:01:57 -0000 1.15.2.5 +++ JavaEnvUtils.java 4 Feb 2005 08:13:47 -0000 1.15.2.6 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 The Apache Software Foundation + * Copyright 2002-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,12 @@ * A set of helper methods related to locating executables or checking * conditons of a given Java installation. * - * * @since Ant 1.5 */ -public class JavaEnvUtils { +public final class JavaEnvUtils { + + private JavaEnvUtils() { + } /** Are we on a DOS-based system */ private static final boolean isDos = Os.isFamily("dos"); @@ -61,6 +63,9 @@ /** Version constant for Java 1.5 */ public static final String JAVA_1_5 = "1.5"; + /** Whether this is the Kaffe VM */ + private static boolean kaffeDetected; + /** array of packages in the runtime */ private static Vector jrePackages; @@ -97,6 +102,13 @@ // swallow as we've hit the max class version that // we have } + kaffeDetected = false; + try { + Class.forName("kaffe.util.NotImplemented"); + kaffeDetected = true; + } catch (Throwable t) { + // swallow as this simply doesn't seem to be Kaffe + } } /** @@ -111,12 +123,22 @@ * Compares the current Java version to the passed in String - * assumes the argument is one of the constants defined in this * class. - * @return true if the version of Java is the same as the given - * version. + * @param version the version to check against the current version. + * @return true if the version of Java is the same as the given version. * @since Ant 1.5 */ public static boolean isJavaVersion(String version) { - return javaVersion == version; + return javaVersion.equals(version); + } + + /** + * Checks whether the current Java VM is Kaffe. + * @return true if the current Java VM is Kaffe. + * @since Ant 1.6.3 + * @see http://www.kaffe.org/ + */ + public static boolean isKaffe() { + return kaffeDetected; } /** @@ -133,7 +155,8 @@ * <code>JAVA_HOME</code> points to your JDK installation. JDK * < 1.2 has them in the same directory as the JDK * executables.</p> - * + * @param command the java executable to find. + * @return the path to the command. * @since Ant 1.5 */ public static String getJreExecutable(String command) { @@ -173,7 +196,8 @@ * * <p>You typically find them in <code>JAVA_HOME/bin</code> if * <code>JAVA_HOME</code> points to your JDK installation.</p> - * + * @param command the java executable to find. + * @return the path to the command. * @since Ant 1.5 */ public static String getJdkExecutable(String command) { @@ -237,7 +261,7 @@ /** * demand creation of the package list. - * When you add a new package, add a new test below + * When you add a new package, add a new test below. */ private static void buildJrePackages() { @@ -281,6 +305,7 @@ /** * Testing helper method; kept here for unification of changes. + * @return a list of test classes depending on the java version. */ public static Vector getJrePackageTestCases() { Vector tests = new Vector(); @@ -325,7 +350,7 @@ /** * get a vector of strings of packages built into * that platforms runtime jar(s) - * @return list of packages + * @return list of packages. */ public static Vector getJrePackages() { if (jrePackages == null) { 1.1.2.2 +20 -8 ant/src/main/org/apache/tools/ant/util/LeadPipeInputStream.java Index: LeadPipeInputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/LeadPipeInputStream.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- LeadPipeInputStream.java 23 Jun 2004 19:30:14 -0000 1.1.2.1 +++ LeadPipeInputStream.java 4 Feb 2005 08:13:47 -0000 1.1.2.2 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation + * Copyright 2004-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.io.PipedInputStream; import java.io.PipedOutputStream; +import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; @@ -30,7 +31,7 @@ * @since Ant 1.6.2 */ public class LeadPipeInputStream extends PipedInputStream { - private Task managingTask; + private ProjectComponent managingPc; /** * Construct a new <CODE>LeadPipeInputStream</CODE>. @@ -52,7 +53,8 @@ /** * Construct a new <CODE>LeadPipeInputStream</CODE> to pull * from the specified <CODE>PipedOutputStream</CODE>. - * @param src the <CODE>PipedOutputStream</CODE> source. + * @param src the <CODE>PipedOutputStream</CODE> source. + * @throws IOException if unable to construct the stream. */ public LeadPipeInputStream(PipedOutputStream src) throws IOException { super(src); @@ -77,8 +79,9 @@ result = super.read(); } catch (IOException eyeOhEx) { if ("write end dead".equalsIgnoreCase(eyeOhEx.getMessage())) { - if (in > 0 && out < buffer.length && out > in) { - result = buffer[out++] & 0xFF; + if (super.in > 0 && super.out < super.buffer.length + && super.out > super.in) { + result = super.buffer[super.out++] & 0xFF; } } else { log("error at LeadPipeInputStream.read(): " @@ -116,7 +119,16 @@ * @param task the managing <CODE>Task</CODE>. */ public void setManagingTask(Task task) { - this.managingTask = task; + setManagingComponent(task); + } + + /** + * Set a managing <CODE>ProjectComponent</CODE> for + * this <CODE>LeadPipeInputStream</CODE>. + * @param pc the managing <CODE>ProjectComponent</CODE>. + */ + public void setManagingComponent(ProjectComponent pc) { + this.managingPc = pc; } /** @@ -125,8 +137,8 @@ * @param loglevel the <CODE>int</CODE> logging level. */ public void log(String message, int loglevel) { - if (managingTask != null) { - managingTask.log(message, loglevel); + if (managingPc != null) { + managingPc.log(message, loglevel); } else { if (loglevel > Project.MSG_WARN) { System.out.println(message);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]