bodewig 2003/07/25 01:27:46 Modified: . Tag: ANT_15_BRANCH WHATSNEW build.xml docs/manual/Integration Tag: ANT_15_BRANCH VAJAntTool.html lib Tag: ANT_15_BRANCH README xercesImpl.jar src/main/org/apache/tools/ant/taskdefs/optional Tag: ANT_15_BRANCH Javah.java src/main/org/apache/tools/ant/taskdefs/optional/ide Tag: ANT_15_BRANCH VAJExport.java VAJImport.java VAJLoad.java VAJLocalUtil.java VAJRemoteUtil.java VAJTask.java VAJToolsServlet.java Log: Merge from HEAD Revision Changes Path No revision No revision 1.263.2.131 +36 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.263.2.130 retrieving revision 1.263.2.131 diff -u -r1.263.2.130 -r1.263.2.131 --- WHATSNEW 31 Mar 2003 09:22:24 -0000 1.263.2.130 +++ WHATSNEW 25 Jul 2003 08:27:42 -0000 1.263.2.131 @@ -1,3 +1,39 @@ +Changes from Ant 1.5.3 to Ant 1.5.4 +=================================== + +Changes that could break older environments: +-------------------------------------------- + +* If the Visual Age tasks used to work for you, they may stop doing so + now - and we'd like to know about it. The current set of tasks is + supposed to work with any version of VAJ starting with 3.0. + +Fixed bugs: +----------- + +* The Visual Age for Java tasks didn't work (at least for versions 3.0 + and higher). Bugzilla Report 10016. + +* URL-encoding in <vaj*port> didn't work properly. + +* VAJRemoteUtil called getAbsolutePath instead of getPath + causing problems when using a Windows VAJ server from a UNIX server. + Bugzilla Report 20457. + +Other changes: +-------------- + +* Shipped XML parser is now Xerces 2.4.0 + +* <javah> will invoke oldjavah on JDK 1.4.2. Bugzilla Report 18667. + +* The VAJ tasks now support a haltonfailure attribute to conditionally + keep building even if they fail. + +* It is now possible to use the latest (versioned or unversioned) edition + in <vajload> by using special wildcard characters. Also fixes + Bugzilla Report 2236. + Changes from Ant 1.5.2 to Ant 1.5.3 =================================== 1.304.2.51 +0 -9 ant/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/ant/build.xml,v retrieving revision 1.304.2.50 retrieving revision 1.304.2.51 diff -u -r1.304.2.50 -r1.304.2.51 --- build.xml 8 Apr 2003 14:17:04 -0000 1.304.2.50 +++ build.xml 25 Jul 2003 08:27:42 -0000 1.304.2.51 @@ -288,10 +288,6 @@ <patternset id="needs.antlr"> <exclude name="${optional.package}/ANTLR*.java" unless="antlr.present"/> </patternset> - <patternset id="needs.servletapi"> - <exclude name="${optional.package}/ide/VAJ*Servlet.java" - unless="servlet.present"/> - </patternset> <patternset id="needs.jmf"> <exclude name="${optional.package}/sound/*.java" unless="jmf.present"/> </patternset> @@ -434,10 +430,6 @@ classname="org.apache.env.Which" classpathref="classpath"/> - <available property="servlet.present" - classname="javax.servlet.Servlet" - classpathref="classpath"/> - <available property="xerces.present" classname="org.apache.xerces.parsers.SAXParser" classpathref="classpath"/> @@ -613,7 +605,6 @@ <patternset refid="needs.starteam"/> <patternset refid="needs.antlr"/> <patternset refid="needs.vaj"/> - <patternset refid="needs.servletapi"/> <patternset refid="needs.jmf"/> <patternset refid="needs.xalan2"/> <patternset refid="needs.jdepend"/> No revision No revision 1.10.2.6 +63 -56 ant/docs/manual/Integration/VAJAntTool.html Index: VAJAntTool.html =================================================================== RCS file: /home/cvs/ant/docs/manual/Integration/VAJAntTool.html,v retrieving revision 1.10.2.5 retrieving revision 1.10.2.6 diff -u -r1.10.2.5 -r1.10.2.6 --- VAJAntTool.html 10 Feb 2003 13:59:38 -0000 1.10.2.5 +++ VAJAntTool.html 25 Jul 2003 08:27:43 -0000 1.10.2.6 @@ -10,12 +10,14 @@ <H1>Visual Age for Java Tasks and Plugin User Manual</H1> <a name="authors"></A>by<UL> <LI>Wolf Siberski - (<A href="mailto:[EMAIL PROTECTED]"> - [EMAIL PROTECTED]</A> ) + (siberski at kbs.uni-hannover.de) <LI>Christoph Wilhelms - (<A href="mailto:[EMAIL PROTECTED]"> - [EMAIL PROTECTED]</A>)</LI></UL> -Version 1.2 - 2001/06/14<br> + (christoph.wilhelms at tui.de)</LI> + <LI>Martin Landers + (martin.landers at bea.de)</LI> + <LI>François Rey + (francois dot rey at capco dot com)</LI></UL> +Version 1.2.1 - 2003/01/16<br> <hr> <h2>Table of Contents</H2> <ul> @@ -50,6 +52,14 @@ <H3>What's new</H3> <table cellpadding="2" cellspacing="2" border="0" width="500"> <tr valign="top"> + <td valign="top">2003/01/16</TD> + <td valign="top"> + <UL> + <LI>Now works outside of VAJ. + <LI>Added attribute haltonerror, "*" and "**" version qualifiers. + <LI>Amended documentation (this file) accordingly. + </LI></UL></TD></TR> + <tr valign="top"> <td valign="top">2001/06/14</TD> <td valign="top"> <UL> @@ -106,7 +116,13 @@ <servername>:<port no>).<BR>If this attribute is set, the tasks will be executed on the specified tool server. </P></TD> - <td valign="top" align="middle">no</TD></TR></TABLE> + <td valign="top" align="middle">no</TD></TR> + <tr> + <td valign="top">haltonerror</B></TD> + <td valign="top"> + <P>Stop the build process if an error occurs, + (default: "yes")</P></TD> + <td align="middle" valign="top">no</TD></TR></TABLE> <h3>Parameters specified as nested elements</H3> <h4>vajproject</H4> @@ -123,13 +139,17 @@ <td valign="top" align="middle">yes</TD></TR> <tr> <td valign="top">version</TD> - <td valign="top">name of the requested version</TD> + <td valign="top"><P>name of the requested version, + or one of the special qualifiers "*" or "**"<BR> + "*" loads the latest <b>versioned</b> edition of the project<BR> + "**" will load the latest version (including open editions)</P></TD> <td valign="top" align="middle">yes</TD></TR> </TABLE> <h3>Example</H3> <pre><vajload remote="localhost:32767"> - <vajproject name="My Testcases" version="1.7beta"/> + <vajproject name="My App" version="*"/> + <vajproject name="My Testcases" version="**"/> <vajproject name="JUnit" version="3.2"/> </vajload> </PRE> @@ -193,7 +213,13 @@ <servername>:<port no>).<BR>If this attribute is set, the tasks will be executed on the specified tool server. </P></TD> - <td valign="top" align="middle">no</TD></TR></TABLE> + <td valign="top" align="middle">no</TD></TR> + <tr> + <td valign="top">haltonerror</B></TD> + <td valign="top"> + <P>Stop the build process if an error occurs, + (default: "yes")</P></TD> + <td align="middle" valign="top">no</TD></TR></TABLE> <h3>Parameters specified as nested elements</H3> @@ -260,7 +286,7 @@ <td valign="top"><b>Description</B></TD> <td align="middle" valign="top"><b>Required</B></TD></TR> <tr> - <td valign="top">vajProject</TD> + <td valign="top">project</TD> <td valign="top">imported files are added to this VAJ project</TD> <td valign="top" align="middle">yes</TD></TR> @@ -285,7 +311,13 @@ <servername>:<port no>).<BR>If this attribute is set, the tasks will be executed on the specified tool server. </P></TD> - <td valign="top" align="middle">no</TD></TR></TABLE> + <td valign="top" align="middle">no</TD></TR> + <tr> + <td valign="top">haltonerror</B></TD> + <td valign="top"> + <P>Stop the build process if an error occurs, + (default: "yes")</P></TD> + <td align="middle" valign="top">no</TD></TR></TABLE> <h3>Parameters specified as nested elements</H3> @@ -315,34 +347,16 @@ <hr> <h2><a name="installation"></A>Installation</H2> -<p>At the moment the installation has it's rough edges. If something -described below doesn't work for You, it's probably not Your fault -but incomplete/wrong instructions. In this case, please contact one -of the <A href="#authors">authors</A>.</P> <p>We assume <CODE>C:\IBMVJava</CODE> as VAJ install directory. If You have installed it elsewhere, adapt the pathes below. <h3>Plugin</H3> <ul> - <li>install the Visual Age IDE Tools (via File->Quick - Start-> Add feature->'IBM IDE Utility class libraries' - <li>import an appropriate XML parser to VAJ (we use Xerces - 1.2.0 and are happy with it). Unfortunately the XML parser delivered with VAJ - (in the project 'IBM XML Parser for Java') doesn't work with Ant. You have to - remove that project (temporarily) from the workspace before importing another - XML implementation. - - <li>import the Ant sources <STRONG>and </STRONG> resources into VAJ. <li>Create the directory <CODE> C:\IBMVJava\ide\tools\org-apache-tools-ant</CODE>. - <li>export the Ant and XML parser class and resource files - into this directory. Be sure to select class files <STRONG>and</STRONG> - resources. Sources don't have to - be exported. Some optional tasks have errors and can't be exported when You - don't have the necessary packages in Your workspace (e.g. junit task, ejbc - task). If You need this tasks either import these packages into VAJ, too, or - copy the .class files directly from the binary distribution. + <li>Expand in that directory all the jars contained in the <code>lib</CODE> + directory of your Ant installation. <li>copy <CODE>default.ini</CODE> (in <CODE> - ant\src\...\taskdefs\optional\ide</CODE>) to <CODE> + org\apache\tools\ant\taskdefs\optional\ide</CODE>) to <CODE> C:\IBMVJava\ide\tools\org-apache-tools-ant\default.ini</CODE>. <li>if you want to access this help from the Workbench, create the @@ -353,9 +367,7 @@ <li>VAJ has to be restarted to recognize the new tool. <li>Now if You open the context menu of a project, You should see the entry 'Ant Build' in the Tools submenu (see <A href="#usage">Usage</A>). - <li>Make sure the tool works as expected. Now You can - remove Ant and the imported XML parser from Your workspace (and optionally add - the IBM parser again). </LI></UL> + <li>Make sure the tool works as expected. </LI></UL> <h3>Servlets for Remote Tool Access</H3> <UL> <LI> @@ -374,25 +386,11 @@ <td valign="top"> <PRE>servlet.vajload.code=org.apache.tools.ant.taskdefs.optional.ide.VAJLoadServlet servlet.vajexport.code=org.apache.tools.ant.taskdefs.optional.ide.VAJExportServlet -servlet.vajimport.code=org.apache.tools.ant.taskdefs.optional.ide.VAJImportServletName<PRE> </PRE></PRE></TD></TR></TABLE> - <LI>export the following classes from the package - <CODE>org.apache.tools.ant</CODE> - to <CODE>C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\</CODE>:<BR> - <CODE>BuildException<BR> - DirectoryScanner<BR> - FileScanner<BR> - Location</CODE> - <LI>export the following classes from the package - <CODE>org.apache.tools.ant.taksdefs.optional.ide</CODE> - to <CODE>C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\</CODE>:<BR> - <CODE>VAJUtil<BR> - VAJExportServlet<BR> - VAJImportServlet<BR> - VAJLoadServlet<BR> - VAJLocalUtil<BR> - VAJProjectDescription<BR> - VAJToolsServlet<BR> - VAJWorkspaceScanner</CODE> +servlet.vajimport.code=org.apache.tools.ant.taskdefs.optional.ide.VAJImportServletName<PRE> +</TD></TR></TABLE> + <LI>Expand the Ant libraries (<code>ant.jar</CODE> and <code>optional.jar</CODE> + contained in the <code>lib</CODE> directory of your Ant installation) to the directory + <code>C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\</CODE>. <LI>configure the Remote Access (via Window->Options..., then choose 'Remote Access To Tool API') as shown in the following picture:</LI></UL> @@ -462,6 +460,10 @@ <BR>.../org/apache/tools/ant/taskdefs/defaults.properties is missing. Make sure that you import/export not only java/class files, but also all resource files when importing/exporting Ant.</P> +<P><STRONG>Q: If I try to re-load a build +file, I get the error "XML parser factory has not been configured correctly". Why?</STRONG><br> +A: Make sure the META-INF/services directory of the <code>xercesImpl.jar</CODE> has also been expanded +into the <CODE>C:\IBMVJava\ide\tools\org-apache-tools-ant</CODE> directory.</P> <P><STRONG>Q: I want to load, export and build more then one Visual Age project to one jar! How to?</STRONG><br> A: The VA tasks are able to load and export several @@ -553,9 +555,14 @@ <td valign="top">1.2</TD> <td valign="top">2001/07/02</TD> <td valign="top"> - <P>Added documentation of new remote feature.<BR>Minor corrections.</P></TD></TR></TABLE> + <P>Added documentation of new remote feature.<BR>Minor corrections.</P></TD></TR> + <tr valign="top"> + <td valign="top">1.2.1</TD> + <td valign="top">2003/01/16</TD> + <td valign="top"> + <P>Added documentation for haltonerror, "*" and "**" version qualifiers.</P></TD></TR></TABLE> <hr> -<center>Copyright &#copy 2001-2003 Apache Software +<center>Copyright © 2001-2003 Apache Software Foundation. All rights Reserved.</CENTER> </body> </html> No revision No revision 1.9.2.7 +1 -1 ant/lib/README Index: README =================================================================== RCS file: /home/cvs/ant/lib/README,v retrieving revision 1.9.2.6 retrieving revision 1.9.2.7 diff -u -r1.9.2.6 -r1.9.2.7 --- README 28 Jan 2003 08:56:13 -0000 1.9.2.6 +++ README 25 Jul 2003 08:27:43 -0000 1.9.2.7 @@ -2,7 +2,7 @@ Dependencies for a list of the jar requirements for various optional tasks and features. -This directory contains xercesImpl.jar from the 2.3.0 release of +This directory contains xercesImpl.jar from the 2.4.0 release of Apache Xerces. For more information or newer releases see <http://xml.apache.org/xerces2-j/>. See the file LICENSE.xerces for the terms of distribution. 1.1.2.6 +1875 -1777ant/lib/xercesImpl.jar <<Binary file>> No revision No revision 1.15.2.4 +45 -31 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.15.2.3 retrieving revision 1.15.2.4 diff -u -r1.15.2.3 -r1.15.2.4 --- Javah.java 10 Feb 2003 14:24:59 -0000 1.15.2.3 +++ Javah.java 25 Jul 2003 08:27:46 -0000 1.15.2.4 @@ -54,22 +54,20 @@ package org.apache.tools.ant.taskdefs.optional; +import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +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.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.Commandline; - import org.apache.tools.ant.util.JavaEnvUtils; -import java.io.File; -import java.util.Vector; -import java.util.StringTokenizer; -import java.util.Enumeration; - /** * Generates JNI header files using javah. * @@ -104,8 +102,6 @@ public class Javah extends Task { - private static final String FAIL_MSG = "Compile failed, messages should have been provided."; - private Vector classes = new Vector(2); private String cls; private File destDir; @@ -175,7 +171,7 @@ */ public Path createClasspath() { if (classpath == null) { - classpath = new Path(project); + classpath = new Path(getProject()); } return classpath.createPath(); } @@ -204,7 +200,7 @@ */ public Path createBootclasspath() { if (bootclasspath == null) { - bootclasspath = new Path(project); + bootclasspath = new Path(getProject()); } return bootclasspath.createPath(); } @@ -279,25 +275,31 @@ } /** - * Executes the task. + * Execute the task + * + * @throws BuildException is there is a problem in the task execution. */ public void execute() throws BuildException { // first off, make sure that we've got a srcdir if ((cls == null) && (classes.size() == 0)) { - throw new BuildException("class attribute must be set!", location); + throw new BuildException("class attribute must be set!", + getLocation()); } if ((cls != null) && (classes.size() > 0)) { - throw new BuildException("set class attribute or class element, not both.", location); + throw new BuildException("set class attribute or class element, " + + "not both.", getLocation()); } if (destDir != null) { if (!destDir.isDirectory()) { - throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", location); + throw new BuildException("destination directory \"" + destDir + + "\" does not exist or is not a directory", getLocation()); } if (outputFile != null) { - throw new BuildException("destdir and outputFile are mutually exclusive", location); + throw new BuildException("destdir and outputFile are mutually " + + "exclusive", getLocation()); } } @@ -307,10 +309,10 @@ classpath = classpath.concatSystemClasspath("ignore"); } - String compiler = project.getProperty("build.compiler"); + String compiler = getProject().getProperty("build.compiler"); if (compiler == null) { - if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) && - !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { + if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) + && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { compiler = "modern"; } else { compiler = "classic"; @@ -342,19 +344,31 @@ } */ try { - // Javac uses logstr to change the output stream and calls - // the constructor's invoke method to create a compiler instance - // dynamically. However, javah has a different interface and this - // makes it harder, so here's a simple alternative. - //------------------------------------------------------------------ - com.sun.tools.javah.Main main - = new com.sun.tools.javah.Main(cmd.getArguments()); - main.run(); + 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, location); + throw new BuildException("Error starting javah: " + ex, ex, getLocation()); } } } @@ -400,7 +414,7 @@ if (stubs) { if (!old) { - throw new BuildException("stubs only available in old mode.", location); + throw new BuildException("stubs only available in old mode.", getLocation()); } cmd.createArgument().setValue("-stubs"); } No revision No revision 1.7.2.4 +79 -17 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java Index: VAJExport.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java,v retrieving revision 1.7.2.3 retrieving revision 1.7.2.4 diff -u -r1.7.2.3 -r1.7.2.4 --- VAJExport.java 10 Feb 2003 14:25:09 -0000 1.7.2.3 +++ VAJExport.java 25 Jul 2003 08:27:46 -0000 1.7.2.4 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,23 +69,77 @@ * their respective package 'dir's. * Example: * <blockquote> - * <vajexport destdir="C:/builddir/source"> - * <include name="/MyVAProject/org/foo/subsystem1/**" /> - * <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/> - * </vajexport> + * <vajexport destdir="C:/builddir/source"> + * <include name="/MyVAProject/org/foo/subsystem1/**" /> + * <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/> + * </vajexport> * </blockquote> * exports all packages in the project MyVAProject which start with * 'org.foo.subsystem1' except of these starting with * 'org.foo.subsystem1.test'. * - * There are flags to choose which items to export: - * exportSources: export Java sources - * exportResources: export project resources - * exportClasses: export class files - * exportDebugInfo: export class files with debug info (use with exportClasses) - * default is exporting Java files and resources. + * <p>Parameters: + * <table border="1" cellpadding="2" cellspacing="0"> + * <tr> + * <td valign="top"><b>Attribute</b></td> + * <td valign="top"><b>Description</b></td> + * <td align="center" valign="top"><b>Required</b></td> + * </tr> + * <tr> + * <td valign="top">destdir</td> + * <td valign="top">location to store the exported files</td> + * <td align="center" valign="top">Yes</td> + * <tr> + * <td valign="top">exportSources</td> + * <td valign="top">export Java sources, defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">exportResources</td> + * <td valign="top">export resource files, defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">exportClasses</td> + * <td valign="top">export class files, defaults to "no"</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">exportDebugInfo</td> + * <td valign="top">include debug info in exported class files, + * defaults to "no"</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">defaultexcludes</td> + * <td valign="top">use default excludes when exporting, + * defaults to "yes". + * Default excludes are: IBM/**, + * Java class libraries/**, Sun class libraries/**, + * JSP Page Compile Generated Code/**, Visual Age*/**</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">overwrite</td> + * <td valign="top">overwrite existing files, defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">remote</td> + * <td valign="top">remote tool server to run this command against + * (format: <servername> : <port no>)</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">haltonerror</td> + * <td valign="top">stop the build process if an error occurs, + * defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> + * </table> * * @author Wolf Siberski, TUI Infotec GmbH + * @author Martin Landers, Beck et al. projects */ public class VAJExport extends VAJTask { @@ -124,12 +178,20 @@ } // delegate the export to the VAJUtil object. - getUtil().exportPackages(destDir, - patternSet.getIncludePatterns(getProject()), - patternSet.getExcludePatterns(getProject()), - exportClasses, exportDebugInfo, - exportResources, exportSources, - useDefaultExcludes, overwrite); + try { + getUtil().exportPackages(destDir, + patternSet.getIncludePatterns(getProject()), + patternSet.getExcludePatterns(getProject()), + exportClasses, exportDebugInfo, + exportResources, exportSources, + useDefaultExcludes, overwrite); + } catch (BuildException ex) { + if (haltOnError) { + throw ex; + } else { + log(ex.toString()); + } + } } /** 1.14.2.4 +48 -31 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java Index: VAJImport.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java,v retrieving revision 1.14.2.3 retrieving revision 1.14.2.4 diff -u -r1.14.2.3 -r1.14.2.4 --- VAJImport.java 10 Feb 2003 14:25:09 -0000 1.14.2.3 +++ VAJImport.java 25 Jul 2003 08:27:46 -0000 1.14.2.4 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,8 +61,6 @@ import org.apache.tools.ant.types.FileSet; -import java.lang.reflect.Field; - /** * Import source, class files, and resources to the Visual Age for Java * workspace. @@ -84,7 +82,7 @@ * created in the repository and automatically loaded into the Workspace. * There has to be at least one nested FileSet element. * </p> - * <p>There are attributes to choose which items to export: + * <p>Parameters: * <table border="1" cellpadding="2" cellspacing="0"> * <tr> * <td valign="top"><b>Attribute</b></td> @@ -112,9 +110,22 @@ * <td valign="top">import class files, defaults to "no"</td> * <td align="center" valign="top">No</td> * </tr> + * <tr> + * <td valign="top">remote</td> + * <td valign="top">remote tool server to run this command against + * (format: <servername> : <port no>)</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">haltonerror</td> + * <td valign="top">stop the build process if an error occurs, + * defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> * </table> * * @author Glenn McAllister, inspired by a similar task written by Peter Kelley + * @author Martin Landers, Beck et al. projects */ public class VAJImport extends VAJTask { protected Vector filesets = new Vector(); @@ -126,6 +137,25 @@ /** + * Extended DirectoryScanner that has accessors for the + * includes and excludes fields. + * + * This is kindof a hack to get includes and excludes + * from the directory scanner. In order to keep + * the URLs short we only want to send the patterns to the + * remote tool server and let him figure out the files. + * + * This replaces the former reflection hack that + * didn't compile for old JDKs. + * + * @see VAJImport#importFileSet(FileSet) + */ + private static class LocalDirectoryScanner extends DirectoryScanner { + public String[] getIncludes() { return includes; } + public String[] getExcludes() { return excludes; } + } + + /** * The VisualAge for Java Project name to import into. */ public void setProject(String projectName) { @@ -184,8 +214,16 @@ throw new BuildException("The VisualAge for Java Project name is required!"); } - for (Enumeration e = filesets.elements(); e.hasMoreElements();) { - importFileset((FileSet) e.nextElement()); + try { + for (Enumeration e = filesets.elements(); e.hasMoreElements();) { + importFileset((FileSet) e.nextElement()); + } + } catch (BuildException ex) { + if (haltOnError) { + throw ex; + } else { + log(ex.toString()); + } } } @@ -194,35 +232,14 @@ * Workspace. */ protected void importFileset(FileSet fileset) { - DirectoryScanner ds = fileset.getDirectoryScanner(this.project); + LocalDirectoryScanner ds = new LocalDirectoryScanner(); + fileset.setupDirectoryScanner(ds, this.getProject()); if (ds.getIncludedFiles().length == 0) { return; } - String[] includes = null; - String[] excludes = null; - - // Hack to get includes and excludes. We could also use getIncludedFiles, - // but that would result in very long HTTP-requests. - // Therefore we want to send the patterns only to the remote tool server - // and let him figure out the files. - try { - Class directoryScanner = ds.getClass(); - - Field includesField = directoryScanner.getDeclaredField("includes"); - includesField.setAccessible(true); - includes = (String[]) includesField.get(ds); - - Field excludesField = directoryScanner.getDeclaredField("excludes"); - excludesField.setAccessible(true); - excludes = (String[]) excludesField.get(ds); - } catch (NoSuchFieldException nsfe) { - throw new BuildException( - "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage()); - } catch (IllegalAccessException iae) { - throw new BuildException( - "Access to DirectoryScanner.includes or .excludes not allowed"); - } + String[] includes = ds.getIncludes(); + String[] excludes = ds.getExcludes(); getUtil().importFiles(importProject, ds.getBasedir(), includes, excludes, 1.4.2.2 +49 -10 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java Index: VAJLoad.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -r1.4.2.1 -r1.4.2.2 --- VAJLoad.java 10 Feb 2003 14:25:09 -0000 1.4.2.1 +++ VAJLoad.java 25 Jul 2003 08:27:46 -0000 1.4.2.2 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,19 +56,50 @@ import java.util.Vector; +import org.apache.tools.ant.BuildException; /** - * Load specific project versions into the Visual Age for Java workspace. - * Each project and version name has to be specified completely. - * Example: - * <blockquote> - * <vajload> - * <project name="MyVAProject" version="2.1"/> - * <project name="Apache Xerces" version="1.2.0"/> - * </vajload> + * Load project versions into the Visual Age for Java workspace. + * Each project is identified by its name and a version qualifier. + * Allowed qualifiers are: + * <ul> + * <li>Any valid Visual Age version name</li> + * <li>* (loads the latest <b>versioned</b> edition)</li> + * <li>** (loads the latest edition, including open editions)</li> + * </ul> + * Example: + * <blockquote> + * <vajload> + * <project name="MyVAProject" version="*"/> + * <project name="Apache Xerces" version="1.2.0"/> + * <project name="Brand New Stuff" version="**"/> + * </vajload> * </blockquote> * + * <p>Parameters:</p> + * <table border="1" cellpadding="2" cellspacing="0"> + * <tr> + * <td valign="top"><b>Attribute</b></td> + * <td valign="top"><b>Description</b></td> + * <td align="center" valign="top"><b>Required</b></td> + * </tr> + * <tr> + * <td valign="top">remote</td> + * <td valign="top">remote tool server to run this command against + * (format: <servername> : <port no>)</td> + * <td align="center" valign="top">No</td> + * </tr> + * <tr> + * <td valign="top">haltonerror</td> + * <td valign="top">stop the build process if an error occurs, + * defaults to "yes"</td> + * <td align="center" valign="top">No</td> + * </tr> + * </table> + * </p> + * * @author Wolf Siberski, TUI Infotec GmbH + * @author Martin Landers, Beck et al. projects */ public class VAJLoad extends VAJTask { @@ -78,7 +109,15 @@ * Load specified projects. */ public void execute() { - getUtil().loadProjects(projectDescriptions); + try { + getUtil().loadProjects(projectDescriptions); + } catch (BuildException ex) { + if (haltOnError) { + throw ex; + } else { + log(ex.toString()); + } + } } /** 1.8.2.2 +73 -43 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java Index: VAJLocalUtil.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -r1.8.2.1 -r1.8.2.2 --- VAJLocalUtil.java 10 Feb 2003 14:25:10 -0000 1.8.2.1 +++ VAJLocalUtil.java 25 Jul 2003 08:27:46 -0000 1.8.2.2 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,20 +54,19 @@ package org.apache.tools.ant.taskdefs.optional.ide; -import java.util.Vector; -import java.util.Enumeration; -import java.io.File; - -import com.ibm.ivj.util.base.Package; -import com.ibm.ivj.util.base.IvjException; -import com.ibm.ivj.util.base.Workspace; -import com.ibm.ivj.util.base.ToolEnv; import com.ibm.ivj.util.base.ExportCodeSpec; -import com.ibm.ivj.util.base.ProjectEdition; import com.ibm.ivj.util.base.ImportCodeSpec; -import com.ibm.ivj.util.base.Type; +import com.ibm.ivj.util.base.IvjException; +import com.ibm.ivj.util.base.Package; import com.ibm.ivj.util.base.Project; - +import com.ibm.ivj.util.base.ProjectEdition; +import com.ibm.ivj.util.base.ToolEnv; +import com.ibm.ivj.util.base.Type; +import com.ibm.ivj.util.base.Workspace; +import java.io.File; +import java.util.Date; +import java.util.Enumeration; +import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; @@ -77,8 +76,9 @@ * wraps IvjExceptions into BuildExceptions * * @author Wolf Siberski, TUI Infotec GmbH + * @author Martin Landers, Beck et al. projects */ -abstract class VAJLocalUtil implements VAJUtil{ +abstract class VAJLocalUtil implements VAJUtil { // singleton containing the VAJ workspace private static Workspace workspace; @@ -126,12 +126,11 @@ /** * export packages */ - public void exportPackages( - File dest, + public void exportPackages(File dest, String[] includePatterns, String[] excludePatterns, boolean exportClasses, boolean exportDebugInfo, boolean exportResources, boolean exportSources, - boolean useDefaultExcludes, boolean overwrite) { + boolean useDefaultExcludes, boolean overwrite) { if (includePatterns == null || includePatterns.length == 0) { log("You must specify at least one include attribute. " + "Not exporting", MSG_ERR); @@ -196,10 +195,19 @@ e.hasMoreElements();) { VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); - ProjectEdition pe = findProjectEdition(d.getName(), d.getVersion()); + ProjectEdition pe; + if (d.getVersion().equals("*")) { + pe = findLatestProjectEdition(d.getName(), false); + } else if (d.getVersion().equals("**")) { + pe = findLatestProjectEdition(d.getName(), true); + } else { + pe = findProjectEdition(d.getName(), d.getVersion()); + } try { - log("Loading '" + d.getName() + "', Version '" + d.getVersion() - + "', into Workspace", MSG_VERBOSE); + log("Loading '" + pe.getName() + "', Version '" + + ((pe.getVersionName() != null) ? pe.getVersionName() + : "(" + pe.getVersionStamp() + ")") + + "' into Workspace", MSG_VERBOSE); pe.loadIntoWorkspace(); } catch (IvjException ex) { throw createBuildException("Project '" + d.getName() @@ -209,28 +217,6 @@ } /** - * returns a list of project names matching the given pattern - */ - private Vector findMatchingProjects(String pattern) { - String[] projectNames; - try { - projectNames = getWorkspace().getRepository().getProjectNames(); - } catch (IvjException e) { - throw createBuildException("VA Exception occured: ", e); - } - - Vector matchingProjects = new Vector(); - for (int i = 0; i < projectNames.length; i++) { - if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { - matchingProjects.addElement(projectNames[i]); - } - } - - return matchingProjects; - } - - - /** * return project descriptions containing full project names instead * of patterns with wildcards. */ @@ -246,8 +232,8 @@ String pattern = d.getName(); if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { d.setProjectFound(); - expandedDescs.addElement(new VAJProjectDescription( - projectNames[i], d.getVersion())); + expandedDescs.addElement(new VAJProjectDescription(projectNames[i], + d.getVersion())); break; } } @@ -288,6 +274,50 @@ } return pe; + } catch (IvjException e) { + throw createBuildException("VA Exception occured: ", e); + } + + } + + /** + * Finds the latest project edition in the repository. + * + * @param name project name + * @param includeOpenEditions include open/scratch editions in the search? + * @return com.ibm.ivj.util.base.ProjectEdition the specified edition + */ + private ProjectEdition findLatestProjectEdition( + String name, + boolean includeOpenEditions) { + try { + ProjectEdition[] editions = null; + editions = getWorkspace().getRepository().getProjectEditions(name); + if (editions == null) { + throw new BuildException("Project " + name + " doesn't exist"); + } + + // find latest (versioned) project edition by date + ProjectEdition pe = null; + // Let's hope there are no projects older than the epoch ;-) + Date latestStamp = new Date(0); + for (int i = 0; i < editions.length; i++) { + if (!includeOpenEditions && !editions[i].isVersion()) { + continue; + } + if (latestStamp.before(editions[i].getVersionStamp())) { + latestStamp = editions[i].getVersionStamp(); + pe = editions[i]; + } + } + + if (pe == null) { + throw new BuildException("Can't determine latest edition for project " + name); + } + log("Using version " + ((pe.getVersionName() != null) ? pe.getVersionName() + : "(" + pe.getVersionStamp() + ")") + + " of " + pe.getName(), MSG_INFO); + return pe; } catch (IvjException e) { throw createBuildException("VA Exception occured: ", e); } 1.5.2.2 +20 -19 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java Index: VAJRemoteUtil.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -r1.5.2.1 -r1.5.2.2 --- VAJRemoteUtil.java 10 Feb 2003 14:25:10 -0000 1.5.2.1 +++ VAJRemoteUtil.java 25 Jul 2003 08:27:46 -0000 1.5.2.2 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,28 +54,27 @@ package org.apache.tools.ant.taskdefs.optional.ide; -import java.util.Vector; - +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.HttpURLConnection; -import java.util.Enumeration; import java.net.URL; - +import java.net.URLEncoder; +import java.util.Enumeration; +import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.InputStream; -import java.io.File; - /** * Helper class for VAJ tasks. Holds Workspace singleton and * wraps IvjExceptions into BuildExceptions * * @author Wolf Siberski, TUI Infotec GmbH + * @author Martin Landers, Beck et al. projects */ -class VAJRemoteUtil implements VAJUtil{ +class VAJRemoteUtil implements VAJUtil { // calling task Task caller; @@ -92,8 +91,9 @@ */ public void exportPackages(File destDir, String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, boolean exportResources, - boolean exportSources, boolean useDefaultExcludes, boolean overwrite) { + boolean exportClasses, boolean exportDebugInfo, + boolean exportResources, boolean exportSources, + boolean useDefaultExcludes, boolean overwrite) { try { String request = "http://" + remoteServer + "/servlet/vajexport?" + VAJExportServlet.WITH_DEBUG_INFO + "=" + exportDebugInfo + "&" @@ -142,22 +142,22 @@ boolean includeSources, boolean useDefaultExcludes) { String result = VAJToolsServlet.DIR_PARAM + "=" - + dir.getAbsolutePath().replace('\\', '/') + "&" + + URLEncoder.encode(dir.getPath()) + "&" + VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&" + VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&" + VAJToolsServlet.SOURCES_PARAM + "=" + includeSources + "&" + VAJToolsServlet.DEFAULT_EXCLUDES_PARAM + "=" + useDefaultExcludes; if (includePatterns != null) { - for (int i = 0; i < includePatterns.length; i++){ + for (int i = 0; i < includePatterns.length; i++) { result = result + "&" + VAJExportServlet.INCLUDE_PARAM + "=" - + includePatterns[i].replace(' ', '+').replace('\\', '/'); + + URLEncoder.encode(includePatterns[i]); } } if (excludePatterns != null) { - for (int i = 0; i < excludePatterns.length; i++){ + for (int i = 0; i < excludePatterns.length; i++) { result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "=" - + excludePatterns[i].replace(' ', '+').replace('\\', '/'); + + URLEncoder.encode(excludePatterns[i]); } } @@ -214,6 +214,7 @@ is = connection.getInputStream(); break; } catch (IOException ex) { + // ignore } } if (is == null) { 1.4.2.3 +15 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java Index: VAJTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -r1.4.2.2 -r1.4.2.3 --- VAJTask.java 10 Feb 2003 14:25:10 -0000 1.4.2.2 +++ VAJTask.java 25 Jul 2003 08:27:46 -0000 1.4.2.3 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,6 +59,7 @@ * attributes (remoteServer) and util methods * * @author: Wolf Siberski + * @author: Martin Landers, Beck et al. projects */ import org.apache.tools.ant.Task; @@ -79,6 +80,8 @@ // holds the appropriate VAJUtil implementation private VAJUtil util = null; + // checks if this task throws BuildException on error + protected boolean haltOnError = true; /** * returns the VAJUtil implementation @@ -102,5 +105,16 @@ */ public void setRemote(String remoteServer) { this.remoteServer = remoteServer; + } + + /** + * Flag to control behaviour in case of VAJ errors. + * If this attribute is set errors will be ignored + * (no BuildException will be thrown) otherwise + * VAJ errors will be wrapped into a BuildException and + * stop the build. + */ + public void setHaltonerror(boolean newHaltOnError) { + haltOnError = newHaltOnError; } } 1.9.2.2 +5 -11 ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java Index: VAJToolsServlet.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -u -r1.9.2.1 -r1.9.2.2 --- VAJToolsServlet.java 10 Feb 2003 14:25:10 -0000 1.9.2.1 +++ VAJToolsServlet.java 25 Jul 2003 08:27:46 -0000 1.9.2.2 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,17 +54,11 @@ package org.apache.tools.ant.taskdefs.optional.ide; - - +import com.ibm.ivj.toolserver.servletclasses.servlet.ServletException; +import com.ibm.ivj.toolserver.servletclasses.servlet.http.HttpServlet; +import com.ibm.ivj.toolserver.servletclasses.servlet.http.HttpServletRequest; +import com.ibm.ivj.toolserver.servletclasses.servlet.http.HttpServletResponse; import java.io.IOException; - - - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.ServletException; - import org.apache.tools.ant.BuildException; import org.apache.tools.ant.util.StringUtils;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]