Browse Source

removal of testlet, visual age for java, and icontract optional tasks.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@396131 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 19 years ago
parent
commit
53511a6584
31 changed files with 12 additions and 6102 deletions
  1. +6
    -0
      WHATSNEW
  2. +0
    -20
      build.xml
  3. +0
    -568
      docs/manual/Integration/VAJAntTool.html
  4. +0
    -167
      docs/manual/OptionalTasks/icontract.html
  5. +0
    -79
      docs/manual/OptionalTasks/test.html
  6. +5
    -7
      docs/manual/dirtasks.html
  7. +0
    -16
      docs/manual/install.html
  8. +0
    -3
      docs/manual/optionaltasklist.html
  9. +0
    -1
      docs/manual/running.html
  10. +1
    -39
      docs/manual/tasksoverview.html
  11. +0
    -5
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  12. +0
    -939
      src/main/org/apache/tools/ant/taskdefs/optional/IContract.java
  13. +0
    -140
      src/main/org/apache/tools/ant/taskdefs/optional/Test.java
  14. +0
    -111
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
  15. +0
    -1385
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
  16. +0
    -471
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
  17. +0
    -234
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
  18. +0
    -133
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java
  19. +0
    -210
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
  20. +0
    -65
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java
  21. +0
    -92
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java
  22. +0
    -48
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java
  23. +0
    -71
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java
  24. +0
    -459
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java
  25. +0
    -79
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java
  26. +0
    -242
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java
  27. +0
    -81
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java
  28. +0
    -182
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java
  29. +0
    -64
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java
  30. +0
    -187
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java
  31. +0
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini

+ 6
- 0
WHATSNEW View File

@@ -77,6 +77,12 @@ Changes that could break older environments:
* support for the XSL:P XML parser has been removed.
Bugzilla Report 23455.

* Visual Age for Java optional tasks removed.

* Testlet (test) optional task removed.

* Icontract optional task removed.

Fixed bugs:
-----------



+ 0
- 20
build.xml View File

@@ -264,10 +264,6 @@
</or>
</selector>

<selector id="needs.icontract">
<filename name="${optional.package}/IContract*"/>
</selector>

<selector id="needs.netrexx">
<filename name="${optional.package}/NetRexxC*"/>
</selector>
@@ -302,10 +298,6 @@
</or>
</selector>

<selector id="needs.vaj">
<filename name="${optional.package}/ide/VAJ*"/>
</selector>

<selector id="needs.antlr">
<filename name="${optional.package}/ANTLR*"/>
</selector>
@@ -445,9 +437,6 @@
<available property="antlr.present"
classname="antlr.Tool"
classpathref="classpath"/>
<available property="vaj.present"
classname="com.ibm.ivj.util.base.Workspace"
classpathref="classpath"/>
<available property="stylebook.present"
classname="org.apache.stylebook.Engine"
classpathref="classpath"/>
@@ -463,9 +452,6 @@
<available property="jai.present"
classname="javax.media.jai.JAI"
classpathref="classpath"/>
<available property="icontract.present"
classname="com.reliablesystems.iContract.IContracted"
classpathref="classpath"/>
<available property="jdepend.present"
classname="jdepend.framework.JDepend"
classpathref="classpath"/>
@@ -687,7 +673,6 @@
<selector refid="needs.apache-bsf" unless="bsf.present"/>
<selector refid="needs.stylebook" unless="stylebook.present"/>
<selector refid="needs.javamail" unless="javamail.complete"/>
<selector refid="needs.icontract" unless="icontract.present"/>
<selector refid="needs.netrexx" unless="netrexx.present"/>
<selector refid="needs.weblogic.ejbc" unless="ejb.ejbc.present"/>
<selector refid="needs.weblogic.ddcreator"
@@ -695,7 +680,6 @@
<selector refid="needs.weblogic.server" unless="ejb.wls.present"/>
<selector refid="needs.commons-net" unless="commons.net.present"/>
<selector refid="needs.starteam" unless="starteam.present"/>
<selector refid="needs.vaj" unless="vaj.present"/>
<selector refid="needs.antlr" unless="antlr.present"/>
<selector refid="needs.jmf" unless="jmf.present"/>
<selector refid="needs.jai" unless="jai.present"/>
@@ -867,14 +851,12 @@
<selector refid="needs.apache-bsf"/>
<selector refid="needs.stylebook"/>
<selector refid="needs.javamail"/>
<selector refid="needs.icontract"/>
<selector refid="needs.netrexx"/>
<selector refid="needs.weblogic.ejbc"/>
<selector refid="needs.weblogic.ddcreator"/>
<selector refid="needs.weblogic.server"/>
<selector refid="needs.commons-net"/>
<selector refid="needs.starteam"/>
<selector refid="needs.vaj"/>
<selector refid="needs.antlr"/>
<selector refid="needs.jmf"/>
<selector refid="needs.jai"/>
@@ -914,11 +896,9 @@
<optional-jar dep="apache-bsf"/>
<optional-jar dep="stylebook"/>
<optional-jar dep="javamail"/>
<optional-jar dep="icontract"/>
<optional-jar dep="netrexx"/>
<optional-jar dep="commons-net"/>
<optional-jar dep="starteam"/>
<optional-jar dep="vaj"/>
<optional-jar dep="antlr"/>
<optional-jar dep="jmf"/>
<optional-jar dep="jai"/>


+ 0
- 568
docs/manual/Integration/VAJAntTool.html View File

@@ -1,568 +0,0 @@
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us">
<title>Visual Age for Java Tasks and Plugin User Manual</title>
</head>
<body>

<H1>Visual Age for Java Tasks and Plugin User Manual</H1>
<a name="authors"></A>by<UL>
<LI>Wolf Siberski
(siberski at kbs.uni-hannover.de)
<LI>Christoph Wilhelms
(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>
<li><A href="#introduction">Introduction</A>
<li><A href="#tasks">The Tasks</A><A href="#introduction"></A>
<ul>
<li><A href="#vajload">VAJLoad</A>
<li><A href="#vajexport">VAJExport</A>
<li><A href="#vajimport">VAJImport</A></LI></UL>
<li><A href="#sample_buildfile">A sample build file</A><br>
<li><A href="#plugin">The Plugin</A>
<ul>
<li><A href="#installation">Installation</A>
<li><A href="#usage">Usage</A> </LI></UL>
<li><A href="#faq">Frequently Asked Questions</A>
<li><A href="#va_versions">Visual Age Versions</A>
<li><A href="#history">History</A><A href="#history"></A> </LI></UL>

<hr>
<h2><a name="introduction"></A>Introduction</H2>
<P>Visual Age for Java is a great Java IDE, but it lacks
decent build support; for creating deliveries. On the other hand, Ant supports
the build process very good, but is (at least at the moment) command line based.
So we decided to write some tasks to access the VAJ repository and a small
visual Ant frontend to make running Ant from VAJ possible. We use the Tool API
to integrate Ant in VisualAge for Java. In combination with the VAJ tasks
(vajload, vajexport, vajimport) you can load defined&nbsp;versions of projects
into your workspace, export the source code, compile it with an external
compiler and build a jar without leaving the IDE. Of course compile messages are
viewed in a logging window. Concluding: This tool provides decent deployment
support VAJ has not (out of the box).</P>
<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>
<LI>Now all tasks can access VAJ via 'Remote Access
To Tool API'. Therefore builds containing VAJ tasks can also be executed
from the command line (Kudos to Glenn McAllister for describing the
concept and providing source code at
<A href="http://www7.software.ibm.com/vad.nsf/Data/Document4366">
http://www7.software.ibm.com/vad.nsf/Data/Document4366</A>.&nbsp;

<LI>It is possible to cancel a running&nbsp;build
executed from the plugin
<LI>Improved error handling in the plugin. Now all
errors should show up either in the log window or in the
console.</LI></UL></TD></TR></TABLE>

<h2><a name="tasks"></A>The Tasks</H2>
At the moment there are three tasks which help integrating the VAJ repository
contents into an external build process:

<table cellpadding="2" cellspacing="2" border="0" width="500">

<tr valign="top">
<td valign="top"><A href="#vajload">VAJLoad</A><br></TD>
<td valign="top"> loads specified versions into the workspace<br></TD></TR>
<tr valign="top">
<td valign="top"><A href="#vajexport">VAJExport</A><br></TD>
<td valign="top"> exports specified packages into the file system<br></TD></TR>
<tr valign="top">
<td valign="top"><A href="#vajimport">VAJImport</A><br></TD>
<td valign="top"> imports specified files into the workspace<br></TD></TR></TABLE>
<P>These tasks are described in detail below.</P>


<hr>

<P></P>
<h2><a name="vajload"></A>VAJLoad</H2>
<h3>Description:</H3>
<p>Loads a specified VAJ project version into the
workspace.</P>

<h3>Parameters</H3>

<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<td valign="top">remote</TD>
<td valign="top">
<P>name and port of a remote tool server. (format:
<code>&lt;servername&gt;</code>:<code>&lt;port no&gt;</code>).<BR>If this
attribute is set, the tasks will&nbsp;be executed on the specified tool
server.&nbsp;</P></TD>
<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>
<table border="1" cellpadding="2" cellspacing="0">

<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<td valign="top">name</TD>
<td valign="top">name of the VAJ project to load into
the workspace</TD>
<td valign="top" align="middle">yes</TD></TR>
<tr>
<td valign="top">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>&lt;vajload remote="localhost:32767"&gt;
&lt;vajproject name="My App" version="*"/&gt;
&lt;vajproject name="My Testcases" version="**"/&gt;
&lt;vajproject name="JUnit" version="3.2"/&gt;
&lt;/vajload&gt;
</PRE>

<hr>
<h2><a name="vajexport"></A>VAJExport</H2>

<h3>Description:</H3>
<p>Exports Java source files, class files and/or resources from the workspace
to the file system. Exports can be specified by giving the VAJ project
name and package name(s). This works very similar to
<A href="../CoreTypes/fileset.html">FileSets</A>. </P>

<h3>Parameters</H3>
<table border="1" cellpadding="2" cellspacing="0">

<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<td valign="top">destdir</TD>
<td valign="top">location to store the exported
files</TD>
<td valign="top" align="middle">yes</TD></TR>
<tr>
<td valign="top">exportSources</TD>
<td valign="top">export source files (default:
"yes")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">exportResources</TD>
<td valign="top">export resource files (default:
"yes")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">exportClasses</TD>
<td valign="top">export class files (default: "no")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">exportDebugInfo</TD>
<td valign="top">include debug info in exported class
files (default: "no")</TD>
<td valign="top" align="middle">no</TD></TR>
<TR>
<TD vAlign=top>defaultexcludes</TD>
<TD vAlign=top>
<P>use default excludes when exporting (default: "yes").<BR>Default excludes are:&nbsp;IBM*/**, Java
class libraries/**, Sun class libraries*/**, JSP Page Compile Generated
Code/**, VisualAge*/**&nbsp;</P></TD>
<TD vAlign=top align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">overwrite</TD>
<td valign="top"> overwrite existing files (default:
"yes")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr>
<td valign="top">remote</TD>
<td valign="top">
<P>name and port of a remote tool server. (format:
<code>&lt;servername&gt;</code>:<code>&lt;port no&gt;</code>).<BR>If this
attribute is set, the tasks will&nbsp;be executed on the specified tool
server.&nbsp;</P></TD>
<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>include</H4>
specifies the packages to include into the export

<table border="1" cellpadding="2" cellspacing="0">

<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<td valign="top">name</TD>
<td valign="top">name of the VAJ project and package to export.<br>
The first element of the name must be the project name, <br>
then the package name elements
separated by '/'.</TD>
<td valign="top">yes</TD></TR></TABLE>

<h4>exclude</H4>
specifies the packages to exclude from the export<br>

<table border="1" cellpadding="2" cellspacing="0">

<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<td valign="top">name</TD>
<td valign="top">name of the VAJ project/package not to
export</TD>
<td valign="top" align="middle">yes</TD></TR></TABLE>

<h3>Example</H3>
<pre>&lt;vajexport destdir="${src.dir}" exportResources="no"&gt;
&lt;include name="MyProject/**"/&gt;
&lt;exclude name="MyProject/test/**"/&gt;
&lt;/vajexport&gt;
</PRE>
This example exports all packages in the VAJ project 'MyProject', except
packages starting with 'test'.
<h3>Default Excludes</H3>
The default excludes are:<br>
<pre> IBM*/**
Java class libraries/**
Sun class libraries*/**
JSP Page Compile Generated Code/**
VisualAge*/**
</PRE>
<hr>
<h2><a name="vajimport"></A>VAJImport</H2>

<h3>Description:</H3>
<p>Imports Java source files, class files and/or resources
from the file system into VAJ. These imports can be specified with a fileset.
</P>
<h3>Parameters</H3>
<table border="1" cellpadding="2" cellspacing="0">

<tr>
<td valign="top"><b>Attribute</B></TD>
<td valign="top"><b>Description</B></TD>
<td align="middle" valign="top"><b>Required</B></TD></TR>
<tr>
<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>
<tr>
<td valign="top">importSources</TD>
<td valign="top">import source files (default:
"yes")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">importResources</TD>
<td valign="top">import resource files (default:
"yes")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr valign="top">
<td valign="top">importClasses</TD>
<td valign="top">import class files (default: "no")</TD>
<td valign="top" align="middle">no</TD></TR>
<tr>
<td valign="top">remote</TD>
<td valign="top">
<P>name and port of a remote tool server. (format:
<code>&lt;servername&gt;</code>:<code>&lt;port no&gt;</code>).<BR>If this
attribute is set, the tasks will&nbsp;be executed on the specified tool
server.&nbsp;</P></TD>
<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>fileset</H4>
A <A href="../CoreTypes/fileset.html">FileSet</A> specifies the files to import.

<h3>Example</H3>
<pre>&lt;vajimport project="Test" importClasses="true"&gt;
&lt;fileset dir="${import.dir}"&gt;
&lt;include name="com/sample/**/*.class"/&gt;
&lt;exclude name="com/sample/test/**"/&gt;
&lt;/fileset&gt;
&lt;/vajimport&gt;
</PRE>
This example imports all class files in the directory ${import.dir}/com/sample
excluding those in the subdirectory test<br>

<hr>
<h2><a name="sample_buildfile"></A>The
Plugin</H2>
The tasks are usable within VAJ by running the
org.apache.tools.ant.Main class, but this is
quite inconvenient. Therefore a small GUI is
provided which allows selecting a build file
and executing its targets. This Plugin is accessible
from the VAJ Tools menu (see <A href="#usage">Usage</A>).

<hr>
<h2><a name="installation"></A>Installation</H2>
<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>Create the directory <CODE>
C:\IBMVJava\ide\tools\org-apache-tools-ant</CODE>.
<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>
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
directory <CODE> C:\IBMVJava\ide\tools\org-apache-tools-ant\doc</CODE>
and copy the files <CODE>VAJAntTool.html</CODE>,
<CODE>toolmenu.gif</CODE> and <CODE>
anttool1.gif</CODE> to it.
<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. </LI></UL>
<h3>Servlets for Remote Tool Access</H3>
<UL>
<LI>
For
a good introduction into the VAJ Remote Tool Access see the
great introduction from Glenn McAllister at
<A href="http://www7.software.ibm.com/vad.nsf/Data/Document4366">
http://www7.software.ibm.com/vad.nsf/Data/Document4366</A>.&nbsp;It
is highly recommended to read this article before doing the installation (to
understand what you do :-) ).
<LI>insert the following lines into
<code>C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\servlet.properties</CODE>.
Typically this file is empty. If not, be careful not to delete the other lines.
<table cellpadding="0" cellspacing="0" border="0" width="500">
<tr valign="top">
<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>
</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-&gt;Options..., then choose 'Remote Access To Tool API') as shown in
the following picture:</LI></UL>
<P align=center><IMG height=645 alt="" src="remacc.gif"
width=587 border=0 ></P>
<P>Now you should be able to execute VAJ Tasks from the
command line.</P>

<hr>
<h2><a name="usage"></A>Usage</H2>
<H3>Plugin</H3>
<P>
When the tool is installed correctly and your Ant build
file is configured, it is really easy to use.<br>
Go to your Workbench, select the project you want to deploy and
open its context menu. In the submenu <i>Tools</I> you should find
the new entry <i>Ant Build</I>. Klick it to start the tool! </P>

<center><IMG height=246 src="toolmenu.gif" width=393 border=0></CENTER>
After a short time this frame should pop up:
<center><IMG height=241 alt=""
src="anttool1.gif"
width=389 border=0></CENTER>
This frame contains the following elements:
<ul>
<li>A menubar with some options described later
<li>The name of your selected VAJ project
<li>An entry field for the Ant XML buildfile with a browse
[...] button. The full qualified filename, including the directory is needed
here.
<li>A list with tasks specified in the buildfile. Until your first save of
the build info (described later), this list will be empty. When loading
a build file by the ( <EM>Re)Load&nbsp;</EM> button, this list
is filled with all tasks which have a description attribute. The
task you select in this list will be executed when pressing the
<EM>Execute&nbsp;</EM> button.
<li>A pulldown box for specifying the log level.
<li>Four buttons. Two of them I have already
described. The other are the <EM>Stop</EM> button to cancel a running build
and the third one is just the <EM>Close</EM> button to exit our small tool!
<li>Note that the build is canceled on the next console
output after pressing the <EM>Stop</EM> button, not
directly after pressing it.</LI></UL>
<P>
After you have set up your buildprocess you might find it useful
to save the data you've just entered, so we implemented an option to
save it to the repository into your selected project. Make sure that you
have an open edition of your project before selecting
<i>Save
BuildInfo To Repository</I> from the <i>File</I> menu.
Now your information is saved to this edition of your project and will
be loaded automatically the next time you start <i>Ant Build</I>.<br>
If you have closed the log window accidentally, it can be reopened
with the <i>Log</I> item in the <i>File</I> menu, and if you want to
know who developed this, just select <i>About</I> in the <i>Help</I> menu. </P>
<H3>Servlets for Remote Tool Access</H3>
<P>With the servlets installed and the remote access
running you can use Ant from the command line without any restrictions. Just
make sure the remote attribute in your build file is set correctly.</P>
<hr>
<h2><a name="faq"></A>Frequently Asked
Questions</H2>
<P><STRONG>Q: If I try to load a build
file, I get the error "Can't load default task list". Why?</STRONG><br>
A: Ant not only contains class files, but also resource
files. This messsage appears if the file
<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
Projects all at once. You can choose whatever project you like for storing the
tool information, it doesn't really matter </P>
<p><STRONG>Q: When I load my build
file, the list of targets is empty. Why?</STRONG><br>
A: You
need to add the optional "description" parameter to the targets you want to come
up in the list. Then reload the build file in the "ant build" tool. We chose to
display only targets with description to allow the build file developer to
distinguish between targets for end users and helper targets. </P>
<p><STRONG>Q: Is there a sample build
file available? </STRONG><br>
A: Now you can find an <A href="#sample_buildfile">example</A> in this manual </P>
<p><STRONG>Q: Why does it export my
entire workspace when I've already implicitly selected a project when starting
the Tool?</STRONG><br>
A: This selection does not carry into
the buildfile you are using. Set the Project name at the beginning of the
"includes" parameter. </P>
<p><STRONG>Q: When I import Ant into
my Workspace, I get Problems reported. Can I ignore them?</STRONG><br>
A: It depends on the problems reported, and what you want to do with Ant.
Problems you can't ignore:
<ul>
<li>Classes from javax.xml.parser missing - install a compatible parser
(see <A href="#installation">installation</A>)
<li>Classes from com.ibm.ivj.util missing - install the Visual Age IDE
Utility feature (see <A href="#installation">installation</A>).
<li>Errors in optional tasks you use within your build
file</LI></UL>
<br>

<p><STRONG>Q: I want to use the same
buildfile both within Visual Age and from the command line using my regular Ant
environment. What do I need to be aware of?</STRONG><br>
A:
You have to specifie a remote server via the 'remote' attribute. Otherwise the
three Visual Age tasks won't work when executing Ant from the command line. </P>

<p><STRONG>Q: I can export packages
from project 'ABC', but not from project 'XYZ'! Why?</STRONG><br>
A: Common reasons are:</P>
<UL>
<li>The project is excluded by the default excludes (see
attribute 'defaultexcludes' of VAJExport)
<li>When looking at the project in the workspace, it is
often difficult to distinguish between project name and version name (e.g. as
in 'My GUI Components Java 2 3.5'). Check if you have the right project name
by switching off the version name display temporarilly.</LI></UL>
<p><STRONG>Q: How do I control the
import/export of sourcefiles, compiled files and project resources
explicity?</STRONG><br>
A: Via the Boolean values
exportClasses (default false) exportSources (default true) and exportResources
(default true). In some situations, Resources are not exported correctly without
this being explicity set. VAJ doesn't export resources correctly if a package
contains only resources (see below).</P>
<hr>
<h2><a name="known_problems"></A>Known
Problems</H2>
<ul>
<li>Exporting a package containing just resources doesn't
work. This is a VAJ Tool API bug. Workaround: create a dummy class and set
'exportSources' to false. </LI></UL>
<hr>

<h2><a name="va_versions"></A>VisualAge
for Java Versions</H2>
This tool integration has been tested with versions 3.02 and 3.5
of VisualAge for Java. It should run with the 2.x Versions, too, but
we didn't try. The graphical user interface is built with AWT so it is
JDK independent by now.
<hr>

<h2><a name="history"></A>History</H2>
<table cellpadding="2" cellspacing="2" border="1" width="400">
<tr valign="top">
<td valign="top">1.0</TD>
<td valign="top">2000/09/11</TD>
<td valign="top">Initial Version</TD></TR>
<TR>
<TD vAlign=top>1.1</TD>
<TD vAlign=top>2001/02/14</TD>
<TD vAlign=top>Added Task documentation and more FAQs
(thanks to Richard Bourke for the FAQ additions) </TD></TR>
<tr valign="top">
<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>
<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-2004 The Apache Software
Foundation. All rights Reserved.</CENTER>
</body>
</html>

+ 0
- 167
docs/manual/OptionalTasks/icontract.html View File

@@ -1,167 +0,0 @@
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
<title>IContract Task</title>
</head>

<body>

<h2><a name="icontract">icontract</a></h2>
<h3>Description</h3>

<P>
Instruments Java classes with <a href="http://www.reliable-systems.com/tools/">iContract</a>
DBC preprocessor.<br>
The task can generate a properties file for <a href="http://home.sol.no/~hellesoy/icplus.html">iControl</a>,
a graphical user interface that lets you turn on/off assertions. iControl generates a control file that you can refer to
from this task using the controlfile attribute.
</p>

<h3>Parameters</h3>
<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">srcdir</td>
<td valign="top">Location of the java files.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">instrumentdir</td>
<td valign="top">Indicates where the instrumented source files should go.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">repositorydir</td>
<td valign="top">Indicates where the repository source files should go.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">builddir</td>
<td valign="top">Indicates where the compiled instrumented classes should go.
Defaults to the value of instrumentdir.
<em>NOTE:</em> Don't use the same directory for compiled instrumented classes
and uninstrumented classes. It will break the dependency checking. (Classes will
not be reinstrumented if you change them).</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">repbuilddir</td>
<td valign="top">Indicates where the compiled repository classes should go.
Defaults to the value of repositorydir.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">pre</td>
<td valign="top">Indicates whether or not to instrument for preconditions.
Defaults to <code>true</code> unless controlfile is specified, in which case it
defaults to <code>false</code>.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">post</td>
<td valign="top">Indicates whether or not to instrument for postconditions.
Defaults to <code>true</code> unless controlfile is specified, in which case it
defaults to <code>false</code>.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">invariant</td>
<td valign="top">Indicates whether or not to instrument for invariants.
Defaults to <code>true</code> unless controlfile is specified, in which case it
defaults to <code>false</code>.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">failthrowable</td>
<td valign="top">The full name of the Throwable (Exception) that should be
thrown when an assertion is violated. Defaults to <code>java.lang.Error</code></td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">verbosity</td>
<td valign="top">Indicates the verbosity level of iContract. Any combination
of <code>error*,warning*,note*,info*,progress*,debug*</code> (comma separated) can be
used. Defaults to <code>error*</code></td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">quiet</td>
<td valign="top">Indicates if iContract should be quiet. Turn it off if many your classes extend uninstrumented classes
and you don't want warnings about this. Defaults to <code>false</code></td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">updateicontrol</td>
<td valign="top">If set to true, it indicates that the properties file for
iControl in the current directory should be updated (or created if it doesn't exist).
Defaults to <code>false</code>.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">controlfile</td>
<td valign="top">The name of the control file to pass to iContract. Consider using iControl to generate the file.
Default is not to pass a file. </td>
<td valign="top" align="center">Only if <code>updateicontrol=true</code></td>
</tr>
<tr>
<td valign="top">classdir</td>
<td valign="top">Indicates where compiled (uninstrumented) classes are located.
This is required in order to properly update the icontrol.properties file, not
for instrumentation.</td>
<td valign="top" align="center">Only if <code>updateicontrol=true</code></td>
</tr>
<tr>
<td valign="top">targets</td>
<td valign="top">Name of the file that will be generated by this task, which lists all the
classes that iContract will instrument. If specified, the file will not be deleted after execution.
If not specified, a file will still be created, but it will be deleted after execution.</td>
<td valign="top" align="center">No</td>
</tr>
</table>

<p>
<b>Note:</b> iContract will use the java compiler indicated by the project's
<code>build.compiler</code> property. See documentation of the Javac task for
more information. Nested includes and excludes are also supported.</p>

<p><b>Example:</b></p>

<p>
<b>Note:</b> iContract will use the java compiler indicated by the project's
<code>build.compiler</code> property. See documentation of the Javac task for
more information.</p>
<p>
Nested includes and excludes can be done very much the same way as any subclass
of MatchingTask.</p>

<p><b>Example:</b></p>

<pre>
&lt;icontract
srcdir=&quot;${build.src}&quot;
instrumentdir=&quot;${build.instrument}&quot;
repositorydir=&quot;${build.repository}&quot;
builddir=&quot;${build.instrclasses}&quot;
updateicontrol=&quot;true&quot;
classdir=&quot;${build.classes}&quot;
controlfile=&quot;control&quot;
targets=&quot;targets&quot;
verbosity=&quot;error*,warning*&quot;
quiet=&quot;true&quot;&gt;
&lt;classpath refid=&quot;compile-classpath&quot;/&gt;
&lt;/icontract&gt;
</pre>

<hr>
<p align="center">Copyright &copy; 2001-2002,2004-2005 The Apache Software Foundation. All rights
Reserved.</p>

</body>
</html>


+ 0
- 79
docs/manual/OptionalTasks/test.html View File

@@ -1,79 +0,0 @@
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
<title>Test Task</title>
</head>

<body>

<h2><a name="test">Test</a></h2>
<h3>Description</h3>
<p>This is a primitive task to execute a unit test in the org.apache.testlet framework.</p>
<p><strong>This task is deprecated as the Testlet framework has been
abandoned in favor of JUnit by the Avalon community.</strong></p>
<p><strong>Note:</strong> This task depends on external libraries not included
in the Ant distribution. See <a href="../install.html#librarydependencies">
Library Dependencies</a> for more information.
</p>

<h3>Parameters</h3>
<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">showSuccess</td>
<td valign="top">a boolean value indicating whether tests should display a
message on success
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">showBanner</td>
<td valign="top">a boolean value indicating whether a banner should be displayed
when starting testlet engine
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">forceShowTrace</td>
<td valign="top">a boolean indicating that a stack trace is displayed on any failure
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">showTrace</td>
<td valign="top">a boolean indicating that a stack trace is displayed on
error (but not normal failure)
</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<p>
The user can also specify the nested <code>&lt;classpath&gt;</code> element which defines classpath
in which the task is executed. The user also specifies a subelement per testlet executed
which has content that specifies tasklet classname.</p>

<h3>Examples</h3>
<blockquote>
<pre>
&lt;test showSuccess=&quot;false&quot; showBanner=&quot;false&quot; showTrace=&quot;true&quot; forceShowTrace=&quot;true&quot;&gt;
&lt;classpath refid=&quot;test.classpath&quot;/&gt;
&lt;testlet&gt;org.foo.MyTestlet&lt;/testlet&gt;
&lt;testlet&gt;org.foo.MyOtherTestlet&lt;/testlet&gt;
&lt;/test&gt;
</pre>
</blockquote>
The above will run the testlets org.foo.MyTestlet and org.foo.MyOtherTestlet

<hr>
<p align="center">Copyright &copy; 2001-2005 The Apache Software Foundation. All rights
Reserved.</p>

</body>
</html>


+ 5
- 7
docs/manual/dirtasks.html View File

@@ -50,6 +50,7 @@ either:</p>
<code>&lt;includesfile&gt;</code> and <code>&lt;excludesfile&gt;</code>.
</li>
</ul>
<p>
When dealing with an external file, each line of the file
is taken as a pattern that is added to the list of include or exclude
patterns.</p>
@@ -128,8 +129,9 @@ For example, <code>mypackage/test/</code> is interpreted as if it were
But not:
<pre>
org/apache/CVS/foo/bar/Entries (<code>foo/bar/</code>
part does not match)</td>
part does not match)
</pre>
</td>
</tr>
<tr>
<td valign="top"><code>org/apache/jakarta/**</code></td>
@@ -201,7 +203,6 @@ tasks that can act as an implicit fileset:</p>
<li><a href="OptionalTasks/ejb.html#ejbjar"><code>&lt;ejbjar&gt;</code></a></li>
<li><a href="OptionalTasks/ejb.html#ejbc"><code>&lt;ejbc&gt;</code></a></li>
<li><a href="OptionalTasks/cab.html"><code>&lt;cab&gt;</code></a></li>
<li><a href="OptionalTasks/icontract.html"><code>&lt;icontract&gt;</code></a></li>
<li><a href="OptionalTasks/native2ascii.html"><code>&lt;native2ascii&gt;</code></a></li>
<li><a href="OptionalTasks/netrexxc.html"><code>&lt;netrexxc&gt;</code></a></li>
<li>
@@ -212,10 +213,7 @@ tasks that can act as an implicit fileset:</p>
<li><a href="OptionalTasks/dotnet.html"><code>&lt;csc&gt;</code></a></li>
<li><a href="OptionalTasks/dotnet.html"><code>&lt;vbc&gt;</code></a></li>
<li><a href="OptionalTasks/translate.html"><code>&lt;translate&gt;</code></a></li>
<li>
<a href="Integration/VAJAntTool.html#vajexport"><code>&lt;vajexport&gt;</code></a>
</li>
<li><code>&lt;image&gt;</code></li>
<li><a href="OptionalTasks/image.html"><code>&lt;image&gt;</code></a></li>
<li><a href="OptionalTasks/jlink.html"><code>&lt;jlink&gt;</code></a> (deprecated)</li>
<li><a href="OptionalTasks/jspc.html"><code>&lt;jspc&gt;</code></a></li>
<li><a href="OptionalTasks/wljspc.html"><code>&lt;wljspc&gt;</code></a></li>
@@ -280,7 +278,7 @@ default excludes by using the <a
href="CoreTasks/defaultexcludes.html">defaultexcludes</a> task.</p>

<hr>
<p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All
<p align="center">Copyright &copy; 2000-2006 The Apache Software Foundation. All
rights Reserved.</p>

</body>


+ 0
- 16
docs/manual/install.html View File

@@ -469,13 +469,6 @@ you need jakarta-oro 2.0.1 or later, and <a href="#commons-net">commons-net</a><
<td>stylebook task</td>
<td>CVS repository of <a href="http://xml.apache.org/cvs.html" target="_top">http://xml.apache.org/cvs.html</a></td>
</tr>
<tr>
<td>testlet.jar</td>
<td><strong>deprecated</strong> test task</td>
<td>Build from the gzip compress tar archive in <a
href="http://avalon.apache.org/historiccvs/testlet/"
target="_top">http://avalon.apache.org/historiccvs/testlet/</a></td>
</tr>
<tr>
<td>antlr.jar</td>
<td>antlr task</td>
@@ -627,15 +620,6 @@ Already included in jdk 1.4</td>
<td><a href="http://java.sun.com/products/java-media/jai/"
target="_top">http://java.sun.com/products/java-media/jai/</a></td>
</tr>
<tr>
<td>IContract</td>
<td>icontract task<br>
Warning : the icontract jar file contains also antlr classes.<br>
To make the antlr task work properly, remove antlr/ANTLRGrammarParseBehavior.class
from the icontract jar file installed under $ANT_HOME/lib.</td>
<td><a href="http://www.reliable-systems.com/tools/"
target="_top">http://www.reliable-systems.com/tools/</a></td>
</tr>
</table>
<br>
<h2><a name="Troubleshooting">Troubleshooting</a></h2>


+ 0
- 3
docs/manual/optionaltasklist.html View File

@@ -28,7 +28,6 @@
<a href="OptionalTasks/ejb.html">EJB Tasks</a><br>
<a href="OptionalTasks/echoproperties.html">Echoproperties</a><br>
<a href="OptionalTasks/ftp.html">FTP</a><br>
<a href="OptionalTasks/icontract.html">IContract</a><br>
<a href="OptionalTasks/image.html">Image</a><br>
<a href="OptionalTasks/jarlib-available.html">Jarlib-available</a><br>
<a href="OptionalTasks/jarlib-display.html">Jarlib-display</a><br>
@@ -71,9 +70,7 @@
<a href="OptionalTasks/stylebook.html"><i>Stylebook</i></a><br>
<a href="OptionalTasks/symlink.html">Symlink</a><br>
<a href="OptionalTasks/telnet.html">Telnet</a><br>
<a href="OptionalTasks/test.html"><i>Test</i></a><br>
<a href="OptionalTasks/translate.html">Translate</a><br>
<a href="Integration/VAJAntTool.html#tasks">Visual Age for Java Tasks</a><br>
<a href="OptionalTasks/vss.html#tasks">Microsoft Visual SourceSafe Tasks</a><br>
<a href="OptionalTasks/wljspc.html">Weblogic JSP Compiler</a><br>
<a href="OptionalTasks/xmlvalidate.html">XmlValidate</a><br>


+ 0
- 1
docs/manual/running.html View File

@@ -345,7 +345,6 @@ org.apache.tools.ant.Executor implementation specified here.
see <a href="CoreTasks/javac.html">javac</a>,
<a href="OptionalTasks/ejb.html#ejbjar_weblogic">EJB Tasks</a>
(compiler attribute),
<a href="OptionalTasks/icontract.html">IContract</a>,
<a href="OptionalTasks/javah.html">javah</a>
</td>
</tr>


+ 1
- 39
docs/manual/tasksoverview.html View File

@@ -868,15 +868,6 @@ documentation.</p>
about all tasks currently known to Ant.</p></td>
</tr>

<tr valign="top">
<td nowrap><a href="OptionalTasks/icontract.html">IContract</a></td>
<td><p>Instruments Java classes using the
<a href="http://www.reliable-systems.com/tools/">iContract</a> DBC
preprocessor. This task can generate a properties file for
<a href="http://home.sol.no/~hellesoy/icplus.html">iControl</a>,
a graphical user interface that lets you turn on/off assertions.</p></td>
</tr>

<tr valign="top">
<td nowrap><a href="CoreTasks/import.html">Import</a></td>
<td><p>Import another build file and potentially override targets
@@ -1244,40 +1235,11 @@ documentation.</p>
report of the testcases results.</p></td>
</tr>

<tr valign="top">
<td nowrap><a href="OptionalTasks/test.html">Test</a></td>
<td><p>Executes a unit test in the <code>org.apache.testlet</code>
framework.</p></td>
</tr>
</table>

<p></p>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<th align="left">
<font size="+0" face="arial,helvetica,sanserif">
<a name="vaj">Visual Age for Java Tasks</a>
</font></th>
<font size="-1" face="arial,helvetica,sanserif">
<th align="right"><a href="#top">[Back to top]</a></th>
</font>
</table>
<table width="100%" border="1" cellpadding="4" cellspacing="0">
<tr valign="top">
<th nowrap>Task Name</th>
<th>Description</th>
</tr>

<tr valign="top">
<td nowrap><a href="Integration/VAJAntTool.html">
Visual Age for Java Tasks</a></td>
<td><p>(See the documentation describing the Visual Age for Java
tasks.)</p></td>
</tr>
</table>


<hr>
<p align="center">Copyright &copy; 2001-2005 The Apache Software Foundation.
<p align="center">Copyright &copy; 2001-2006 The Apache Software Foundation.
All rights Reserved.</p>

</body>


+ 0
- 5
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -118,7 +118,6 @@ echoxml=org.apache.tools.ant.taskdefs.EchoXML
ejbc=org.apache.tools.ant.taskdefs.optional.ejb.Ejbc
ejbjar=org.apache.tools.ant.taskdefs.optional.ejb.EjbJar
ftp=org.apache.tools.ant.taskdefs.optional.net.FTP
icontract=org.apache.tools.ant.taskdefs.optional.IContract
ilasm=org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm
ildasm=org.apache.tools.ant.taskdefs.optional.dotnet.Ildasm
image=org.apache.tools.ant.taskdefs.optional.image.Image
@@ -188,11 +187,7 @@ stlist=org.apache.tools.ant.taskdefs.optional.starteam.StarTeamList
stylebook=org.apache.tools.ant.taskdefs.optional.StyleBook
symlink=org.apache.tools.ant.taskdefs.optional.unix.Symlink
telnet=org.apache.tools.ant.taskdefs.optional.net.TelnetTask
test=org.apache.tools.ant.taskdefs.optional.Test
translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate
vajexport=org.apache.tools.ant.taskdefs.optional.ide.VAJExport
vajimport=org.apache.tools.ant.taskdefs.optional.ide.VAJImport
vajload=org.apache.tools.ant.taskdefs.optional.ide.VAJLoadProjects
vbc=org.apache.tools.ant.taskdefs.optional.dotnet.VisualBasicCompile
verifyjar=org.apache.tools.ant.taskdefs.VerifyJar
vssadd=org.apache.tools.ant.taskdefs.optional.vss.MSVSSADD


+ 0
- 939
src/main/org/apache/tools/ant/taskdefs/optional/IContract.java View File

@@ -1,939 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.Properties;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.taskdefs.Mkdir;
import org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;

/**
* Instruments Java classes with iContract DBC preprocessor.
* <br/>
* The task can generate a properties file for
* <a href="http://hjem.sol.no/hellesoy/icontrol.html">iControl</a>,
* a graphical user interface that lets you turn on/off assertions.
* iControl generates a control file that you can refer to
* from this task using the controlfile attribute.
* iContract is at
* <a href="http://www.reliable-systems.com/tools/">
* http://www.reliable-systems.com/tools/</a>
* <p/>
* Thanks to Rainer Schmitz for enhancements and comments.
*
*
* <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">srcdir</td>
* <td valign="top">Location of the java files.</td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">instrumentdir</td>
* <td valign="top">Indicates where the instrumented source
* files should go.</td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">repositorydir</td>
* <td valign="top">Indicates where the repository source
* files should go.</td>
* <td valign="top" align="center">Yes</td>
* </tr>
* <tr>
* <td valign="top">builddir</td>
* <td valign="top">Indicates where the compiled instrumented
* classes should go. Defaults to the value of
* instrumentdir.
* </p>
* <em>NOTE:</em> Don't use the same directory for compiled
* instrumented classes and uninstrumented classes. It will break the
* dependency checking. (Classes will not be reinstrumented if you
* change them).</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">repbuilddir</td>
* <td valign="top">Indicates where the compiled repository classes
* should go. Defaults to the value of repositorydir.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">pre</td>
* <td valign="top">Indicates whether or not to instrument for
* preconditions. Defaults to <code>true</code> unless
* controlfile is specified, in which case it defaults
* to <code>false</code>.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">post</td>
* <td valign="top">Indicates whether or not to instrument for
* postconditions. Defaults to <code>true</code> unless
* controlfile is specified, in which case it defaults
* to <code>false</code>.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">invariant</td>
* <td valign="top">Indicates whether or not to instrument for invariants.
* Defaults to <code>true</code> unless controlfile is
* specified, in which case it defaults to
* <code>false</code>.</td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">failthrowable</td>
* <td valign="top">The full name of the Throwable (Exception) that
* should be thrown when an assertion is violated.
* Defaults to <code>java.lang.Error</code></td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">verbosity</td>
* <td valign="top">Indicates the verbosity level of iContract.
* Any combination of
* <code>error*,warning*,note*,info*,progress*,debug*</code>
* (comma separated) can be used. Defaults to <code>error*</code></td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">quiet</td>
* <td valign="top">Indicates if iContract should be quiet. Turn it off
* if many your classes extend uninstrumented classes and you don't
* want warnings about this. Defaults to <code>false</code></td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">updateicontrol</td>
* <td valign="top">If set to true, it indicates that the properties
* file for iControl in the current directory should be updated
* (or created if it doesn't exist). Defaults to <code>false</code>.
* </td>
* <td valign="top" align="center">No</td>
* </tr>
* <tr>
* <td valign="top">controlfile</td>
* <td valign="top">The name of the control file to pass to iContract.
* Consider using iControl to generate the file.
* Default is not to pass a file. </td>
* <td valign="top" align="center">
* Only if <code>updateicontrol=true</code></td>
* </tr>
* <tr>
* <td valign="top">classdir</td>
* <td valign="top">Indicates where compiled (unistrumented) classes are
* located. This is required in order to properly update
* the icontrol.properties file, not for instrumentation.
* </td>
* <td valign="top" align="center">Only if
* <code>updateicontrol=true</code></td>
* </tr>
* <tr>
* <td valign="top">targets</td>
* <td valign="top">Name of the file that will be generated by this task,
* which lists all the classes that iContract will
* instrument. If specified, the file will not be deleted
* after execution. If not specified, a file will still
* be created, but it will be deleted after execution.</td>
* <td valign="top" align="center">No</td>
* </tr>
* </table>
*
* <p/>
* <b>Note:</b> iContract will use the java compiler indicated by the project's
* <code>build.compiler</code> property. See documentation of the Javac task for
* more information.
* <p/>
* Nested includes and excludes are also supported.
*
* <p><b>Example:</b></p>
* <pre>
* &lt;icontract
* srcdir="${build.src}"
* instrumentdir="${build.instrument}"
* repositorydir="${build.repository}"
* builddir="${build.instrclasses}"
* updateicontrol="true"
* classdir="${build.classes}"
* controlfile="control"
* targets="targets"
* verbosity="error*,warning*"
* quiet="true"
* >
* &lt;classpath refid="compile-classpath"/>
* &lt;/icontract>
* </pre>
*
*/
public class IContract extends MatchingTask {

private static final String ICONTROL_PROPERTIES_HEADER
= "You might want to set classRoot to point to your normal "
+ "compilation class root directory.";

/** compiler to use for instrumenation */
private String icCompiler = "javac";

/** temporary file with file names of all java files to be instrumented */
private File targets = null;

/**
* will be set to true if any of the source files are newer than the
* instrumented files
*/
private boolean dirty = false;

/** set to true if the iContract jar is missing */
private boolean iContractMissing = false;

/** source file root */
private File srcDir = null;

/** instrumentation src root */
private File instrumentDir = null;

/** instrumentation build root */
private File buildDir = null;

/** repository src root */
private File repositoryDir = null;

/** repository build root */
private File repBuildDir = null;

/** classpath */
private Path classpath = null;

/** The class of the Throwable to be thrown on failed assertions */
private String failThrowable = "java.lang.Error";

/** The -v option */
private String verbosity = "error*";

/** The -q option */
private boolean quiet = false;

/** The -m option */
private File controlFile = null;

/** Indicates whether or not to instrument for preconditions */
private boolean pre = true;
private boolean preModified = false;

/** Indicates whether or not to instrument for postconditions */
private boolean post = true;
private boolean postModified = false;

/** Indicates whether or not to instrument for invariants */
private boolean invariant = true;
private boolean invariantModified = false;

/**
* Indicates whether or not to instrument all files regardless of timestamp
*
* Can't be explicitly set, is set if control file exists and is newer
* than any source file
*/
private boolean instrumentall = false;

/**
* Indicates the name of a properties file (intentionally for iControl)
* where the classpath property should be updated.
*/
private boolean updateIcontrol = false;

/** Regular compilation class root */
private File classDir = null;

/**
* Sets the source directory.
*
* @param srcDir the source directory
*/
public void setSrcdir(File srcDir) {
this.srcDir = srcDir;
}


/**
* Sets the class directory (uninstrumented classes).
*
* @param classDir the source directory
*/
public void setClassdir(File classDir) {
this.classDir = classDir;
}


/**
* Sets the instrumentation directory.
*
* @param instrumentDir the source directory
*/
public void setInstrumentdir(File instrumentDir) {
this.instrumentDir = instrumentDir;
if (this.buildDir == null) {
setBuilddir(instrumentDir);
}
}


/**
* Sets the build directory for instrumented classes.
*
* @param buildDir the build directory
*/
public void setBuilddir(File buildDir) {
this.buildDir = buildDir;
}


/**
* Sets the build directory for repository classes.
*
* @param repositoryDir the source directory
*/
public void setRepositorydir(File repositoryDir) {
this.repositoryDir = repositoryDir;
if (this.repBuildDir == null) {
setRepbuilddir(repositoryDir);
}
}


/**
* Sets the build directory for instrumented classes.
*
* @param repBuildDir the build directory
*/
public void setRepbuilddir(File repBuildDir) {
this.repBuildDir = repBuildDir;
}


/**
* Turns on/off precondition instrumentation.
*
* @param pre true turns it on
*/
public void setPre(boolean pre) {
this.pre = pre;
preModified = true;
}


/**
* Turns on/off postcondition instrumentation.
*
* @param post true turns it on
*/
public void setPost(boolean post) {
this.post = post;
postModified = true;
}


/**
* Turns on/off invariant instrumentation.
*
* @param invariant true turns it on
*/
public void setInvariant(boolean invariant) {
this.invariant = invariant;
invariantModified = true;
}


/**
* Sets the Throwable (Exception) to be thrown on assertion violation.
*
* @param clazz the fully qualified Throwable class name
*/
public void setFailthrowable(String clazz) {
this.failThrowable = clazz;
}


/**
* Sets the verbosity level of iContract. Any combination of
* error*,warning*,note*,info*,progress*,debug* (comma separated) can be
* used. Defaults to error*,warning*
*
* @param verbosity verbosity level
*/
public void setVerbosity(String verbosity) {
this.verbosity = verbosity;
}


/**
* Tells iContract to be quiet.
*
* @param quiet true if iContract should be quiet.
*/
public void setQuiet(boolean quiet) {
this.quiet = quiet;
}


/**
* Sets the name of the file where targets will be written. That is the
* file that tells iContract what files to process.
*
* @param targets the targets file name
*/
public void setTargets(File targets) {
this.targets = targets;
}


/**
* Sets the control file to pass to iContract.
*
* @param controlFile the control file
*/
public void setControlfile(File controlFile) {
if (!controlFile.exists()) {
log("WARNING: Control file " + controlFile.getAbsolutePath()
+ " doesn't exist. iContract will be run "
+ "without control file.");
}
this.controlFile = controlFile;
}


/**
* Sets the classpath to be used for invocation of iContract.
*
* @param path the classpath
*/
public void setClasspath(Path path) {
createClasspath().append(path);
}


/**
* Sets the classpath.
*
* @return the nested classpath element
* @todo this overwrites the classpath so only one
* effective classpath element would work. This
* is not how we do this elsewhere.
*/
public Path createClasspath() {
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath;
}


/**
* Adds a reference to a classpath defined elsewhere.
*
* @param reference referenced classpath
*/
public void setClasspathRef(Reference reference) {
createClasspath().setRefid(reference);
}


/**
* If true, updates iControl properties file
*
* @param updateIcontrol true if iControl properties file should be
* updated
*/
public void setUpdateicontrol(boolean updateIcontrol) {
this.updateIcontrol = updateIcontrol;
}


/**
* Executes the task
*
* @exception BuildException if the instrumentation fails
*/
public void execute() throws BuildException {
preconditions();
scan();
if (dirty) {

// turn off assertions if we're using controlfile, unless they are not explicitly set.
boolean useControlFile = (controlFile != null) && controlFile.exists();

if (useControlFile && !preModified) {
pre = false;
}
if (useControlFile && !postModified) {
post = false;
}
if (useControlFile && !invariantModified) {
invariant = false;
}
// issue warning if pre,post or invariant is used together with controlfile
if ((pre || post || invariant) && controlFile != null) {
log("WARNING: specifying pre,post or invariant will "
+ "override control file settings");
}


// We want to be notified if iContract jar is missing.
// This makes life easier for the user who didn't understand
// that iContract is a separate library (duh!)
getProject().addBuildListener(new IContractPresenceDetector());

// Prepare the directories for iContract. iContract will make
// them if they don't exist, but for some reason I don't know,
// it will complain about the REP files afterwards
Mkdir mkdir = new Mkdir();
mkdir.bindToOwner(this);

mkdir.setDir(instrumentDir);
mkdir.execute();
mkdir.setDir(buildDir);
mkdir.execute();
mkdir.setDir(repositoryDir);
mkdir.execute();

// Set the classpath that is needed for regular Javac compilation
Path baseClasspath = createClasspath();

// Might need to add the core classes if we're not using
// Sun's Javac (like Jikes)
String compiler = getProject().getProperty("build.compiler");
ClasspathHelper classpathHelper = new ClasspathHelper(compiler);

classpathHelper.modify(baseClasspath);

// Create the classpath required to compile the sourcefiles
// BEFORE instrumentation
Path beforeInstrumentationClasspath = ((Path) baseClasspath.clone());

beforeInstrumentationClasspath.append(new Path(getProject(),
srcDir.getAbsolutePath()));

// Create the classpath required to compile the sourcefiles
// AFTER instrumentation
Path afterInstrumentationClasspath = ((Path) baseClasspath.clone());

afterInstrumentationClasspath.append(new Path(getProject(),
instrumentDir.getAbsolutePath()));
afterInstrumentationClasspath.append(new Path(getProject(),
repositoryDir.getAbsolutePath()));
afterInstrumentationClasspath.append(new Path(getProject(),
srcDir.getAbsolutePath()));
afterInstrumentationClasspath.append(new Path(getProject(),
buildDir.getAbsolutePath()));

// Create the classpath required to automatically compile the
// repository files
Path repositoryClasspath = ((Path) baseClasspath.clone());

repositoryClasspath.append(new Path(getProject(),
instrumentDir.getAbsolutePath()));
repositoryClasspath.append(new Path(getProject(),
srcDir.getAbsolutePath()));
repositoryClasspath.append(new Path(getProject(),
repositoryDir.getAbsolutePath()));
repositoryClasspath.append(new Path(getProject(),
buildDir.getAbsolutePath()));

// Create the classpath required for iContract itself
Path iContractClasspath = ((Path) baseClasspath.clone());

iContractClasspath.append(new Path(getProject(),
System.getProperty("java.home") + File.separator + ".."
+ File.separator + "lib" + File.separator + "tools.jar"));
iContractClasspath.append(new Path(getProject(),
srcDir.getAbsolutePath()));
iContractClasspath.append(new Path(getProject(),
repositoryDir.getAbsolutePath()));
iContractClasspath.append(new Path(getProject(),
instrumentDir.getAbsolutePath()));
iContractClasspath.append(new Path(getProject(),
buildDir.getAbsolutePath()));

// Create a forked java process
Java iContract = new Java(this);
iContract.setFork(true);
iContract.setClassname("com.reliablesystems.iContract.Tool");
iContract.setClasspath(iContractClasspath);

// Build the arguments to iContract
StringBuffer args = new StringBuffer();

args.append(directiveString());
args.append("-v").append(verbosity).append(" ");

args.append("-b").append("\"").append(icCompiler);
args.append(" -classpath ").append(beforeInstrumentationClasspath);
args.append("\" ");

args.append("-c").append("\"").append(icCompiler);
args.append(" -classpath ").append(afterInstrumentationClasspath);
args.append(" -d ").append(buildDir).append("\" ");

args.append("-n").append("\"").append(icCompiler);
args.append(" -classpath ").append(repositoryClasspath);
args.append("\" ");

args.append("-d").append(failThrowable).append(" ");

args.append("-o").append(instrumentDir).append(File.separator);
args.append("@p").append(File.separator).append("@f.@e ");

args.append("-k").append(repositoryDir).append(File.separator);
args.append("@p ");

args.append(quiet ? "-q " : "");
// reinstrument everything if controlFile exists and is newer
// than any class
args.append(instrumentall ? "-a " : "");
args.append("@").append(targets.getAbsolutePath());
iContract.createArg().setLine(args.toString());

//System.out.println( "JAVA -classpath " + iContractClasspath
// + " com.reliablesystems.iContract.Tool " + args.toString() );

// update iControlProperties if it's set.
if (updateIcontrol) {
Properties iControlProps = new Properties();

try {
// to read existing propertiesfile
iControlProps.load(new FileInputStream("icontrol.properties"));
} catch (IOException e) {
log("File icontrol.properties not found. That's ok. "
+ "Writing a default one.");
}
iControlProps.setProperty("sourceRoot",
srcDir.getAbsolutePath());
iControlProps.setProperty("classRoot",
classDir.getAbsolutePath());
iControlProps.setProperty("classpath",
afterInstrumentationClasspath.toString());
iControlProps.setProperty("controlFile",
controlFile.getAbsolutePath());
iControlProps.setProperty("targetsFile",
targets.getAbsolutePath());

try {
// to read existing propertiesfile
iControlProps.store(new FileOutputStream("icontrol.properties"),
ICONTROL_PROPERTIES_HEADER);
log("Updated icontrol.properties");
} catch (IOException e) {
log("Couldn't write icontrol.properties.");
}
}

// do it!
int result = iContract.executeJava();

if (result != 0) {
if (iContractMissing) {
log("iContract can't be found on your classpath. "
+ "Your classpath is:");
log(classpath.toString());
log("If you don't have the iContract jar, go get it at "
+ "http://www.reliable-systems.com/tools/");
}
throw new BuildException("iContract instrumentation failed. "
+ "Code = " + result);
}
} else {
// not dirty
//log( "Nothing to do. Everything up to date." );
}
}


/** Checks that the required attributes are set. */
private void preconditions() throws BuildException {
if (srcDir == null) {
throw new BuildException("srcdir attribute must be set!",
getLocation());
}
if (!srcDir.exists()) {
throw new BuildException("srcdir \"" + srcDir.getPath()
+ "\" does not exist!", getLocation());
}
if (instrumentDir == null) {
throw new BuildException("instrumentdir attribute must be set!",
getLocation());
}
if (repositoryDir == null) {
throw new BuildException("repositorydir attribute must be set!",
getLocation());
}
if (updateIcontrol && classDir == null) {
throw new BuildException("classdir attribute must be specified "
+ "when updateicontrol=true!", getLocation());
}
if (updateIcontrol && controlFile == null) {
throw new BuildException("controlfile attribute must be specified "
+ "when updateicontrol=true!", getLocation());
}
}


/**
* Verifies whether any of the source files have changed. Done by
* comparing date of source/class files. The whole lot is "dirty" if at
* least one source file or the control file is newer than the
* instrumented files. If not dirty, iContract will not be executed. <br/>
* Also creates a temporary file with a list of the source files, that
* will be deleted upon exit.
*/
private void scan() throws BuildException {
long now = (new Date()).getTime();

DirectoryScanner ds = null;

ds = getDirectoryScanner(srcDir);

String[] files = ds.getIncludedFiles();

FileOutputStream targetOutputStream = null;
PrintStream targetPrinter = null;
boolean writeTargets = false;

try {
if (targets == null) {
targets = new File("targets");
log("Warning: targets file not specified. generating file: "
+ targets.getName());
writeTargets = true;
} else if (!targets.exists()) {
log("Specified targets file doesn't exist. generating file: "
+ targets.getName());
writeTargets = true;
}
if (writeTargets) {
log("You should consider using iControl to create a target file.");
targetOutputStream = new FileOutputStream(targets);
targetPrinter = new PrintStream(targetOutputStream);
}
for (int i = 0; i < files.length; i++) {
File srcFile = new File(srcDir, files[i]);

if (files[i].endsWith(".java")) {
// print the target, while we're at here. (Only if generatetarget=true).
if (targetPrinter != null) {
targetPrinter.println(srcFile.getAbsolutePath());
}
File classFile = new File(
buildDir, files[i].substring(0, files[i].indexOf(".java")) + ".class");

if (srcFile.lastModified() > now) {
log("Warning: file modified in the future: "
+ files[i], Project.MSG_WARN);
}

if (!classFile.exists() || srcFile.lastModified() > classFile.lastModified()) {
//log( "Found a file newer than the instrumentDir class file: "
// + srcFile.getPath() + " newer than " + classFile.getPath()
// + ". Running iContract again..." );
dirty = true;
}
}
}
if (targetPrinter != null) {
targetPrinter.flush();
targetPrinter.close();
}
} catch (IOException e) {
throw new BuildException("Could not create target file:" + e.getMessage());
}

// also, check controlFile timestamp
long controlFileTime = -1;

try {
if (controlFile != null) {
if (controlFile.exists() && buildDir.exists()) {
controlFileTime = controlFile.lastModified();
ds = getDirectoryScanner(buildDir);
files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File srcFile = new File(srcDir, files[i]);

if (files[i].endsWith(".class")) {
if (controlFileTime > srcFile.lastModified()) {
if (!dirty) {
log("Control file "
+ controlFile.getAbsolutePath()
+ " has been updated. "
+ "Instrumenting all files...");
}
dirty = true;
instrumentall = true;
}
}
}
}
}
} catch (Throwable t) {
throw new BuildException("Got an interesting exception:"
+ t.getMessage());
}
}


/**
* Creates the -m option based on the values of controlFile, pre, post and
* invariant.
* @return the string containing the -m option.
*/
private String directiveString() {
StringBuffer sb = new StringBuffer();
boolean comma = false;

boolean useControlFile = (controlFile != null) && controlFile.exists();

if (useControlFile || pre || post || invariant) {
sb.append("-m");
}
if (useControlFile) {
sb.append("@").append(controlFile);
comma = true;
}
if (pre) {
if (comma) {
sb.append(",");
}
sb.append("pre");
comma = true;
}
if (post) {
if (comma) {
sb.append(",");
}
sb.append("post");
comma = true;
}
if (invariant) {
if (comma) {
sb.append(",");
}
sb.append("inv");
}
sb.append(" ");
return sb.toString();
}


/**
* BuildListener that sets the iContractMissing flag to true if a message
* about missing iContract is missing. Used to indicate a more verbose
* error to the user, with advice about how to solve the problem
*
*/
private class IContractPresenceDetector implements BuildListener {
public void buildFinished(BuildEvent event) {
}


public void buildStarted(BuildEvent event) {
}


public void messageLogged(BuildEvent event) {
if ("java.lang.NoClassDefFoundError: com/reliablesystems/iContract/Tool"
.equals(event.getMessage())) {
iContractMissing = true;
}
}


public void targetFinished(BuildEvent event) {
}


public void targetStarted(BuildEvent event) {
}


public void taskFinished(BuildEvent event) {
}


public void taskStarted(BuildEvent event) {
}
}


/**
* This class is a helper to set correct classpath for other compilers,
* like Jikes. It reuses the logic from DefaultCompilerAdapter, which is
* protected, so we have to subclass it.
*
*/
private class ClasspathHelper extends DefaultCompilerAdapter {
private final String compiler;


public ClasspathHelper(String compiler) {
super();
this.compiler = compiler;
}

// make it public
public void modify(Path path) {
// depending on what compiler to use, set the
// includeJavaRuntime flag
if ("jikes".equals(compiler)) {
icCompiler = compiler;
includeJavaRuntime = true;
path.append(getCompileClasspath());
}
}

// dummy implementation. Never called
public void setJavac(Javac javac) {
}


public boolean execute() {
return true;
}
}
}


+ 0
- 140
src/main/org/apache/tools/ant/taskdefs/optional/Test.java View File

@@ -1,140 +0,0 @@
/*
* Copyright 2000,2002-2006 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional;

import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;

/**
* This is a primitive task to execute a unit test in the
* org.apache.testlet framework.
*
* @deprecated since 1.5.x.
* Testlet has been abandoned in favor of JUnit by the
* Avalon community.
*
* @ant.task ignore="true"
*/
public class Test extends Java {

protected Vector m_tests = new Vector();


/**
* testlet to run
*/
protected static final class TestletEntry {

protected String m_testname = "";


/**
* name of test. No property expansion takes place here
* @param testname the test name
*/
public void addText(final String testname) {
m_testname += testname;
}


/**
* Get the test name
* @return the test name
*/
public String toString() {
return m_testname;
}
}


/** Constructor for the Test task. */
public Test() {
setClassname("org.apache.testlet.engine.TextTestEngine");
}


/**
* add a declaration of a testlet to run
* @return a <code>TestletEntry</code> to configure
*/
public TestletEntry createTestlet() {
final TestletEntry entry = new TestletEntry();

m_tests.addElement(entry);
return entry;
}


/**
* a boolean value indicating whether tests should display a
* message on success; optional
* @param showSuccess a <code>boolean</code> value
*/

public void setShowSuccess(final boolean showSuccess) {
createArg().setValue("-s=" + showSuccess);
}


/**
* a boolean value indicating whether a banner should be displayed
* when starting testlet engine; optional.
* @param showBanner a <code>String</code> value
*/
public void setShowBanner(final String showBanner) {
createArg().setValue("-b=" + showBanner);
}


/**
* a boolean indicating that a stack trace is displayed on
* error (but not normal failure); optional.
* @param showTrace a <code>boolean</code> value
*/
public void setShowTrace(final boolean showTrace) {
createArg().setValue("-t=" + showTrace);
}


/**
* a boolean indicating that a stack trace is to be displayed always.
* @param forceShowTrace a <code>boolean</code> value
*/
public void setForceShowTrace(final boolean forceShowTrace) {
createArg().setValue("-f=" + forceShowTrace);
}


/**
* Execute the task.
* @throws BuildException on error
*/
public void execute()
throws BuildException {

final int size = m_tests.size();

for (int i = 0; i < size; i++) {
createArg().setValue(m_tests.elementAt(i).toString());
}

super.execute();
}
}



+ 0
- 111
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java View File

@@ -1,111 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;


import com.ibm.ivj.util.base.Project;
import com.ibm.ivj.util.base.ToolData;
import org.apache.tools.ant.BuildException;


/**
* This class is the equivalent to org.apache.tools.ant.Main for the
* VAJ tool environment. It's main is called when the user selects
* Tools->Ant Build from the VAJ project menu.
* Additionally this class provides methods to save build info for
* a project in the repository and load it from the repository
*
*/
public class VAJAntTool {
private static final String TOOL_DATA_KEY = "AntTool";


/**
* Loads the BuildInfo for the specified VAJ project from the
* tool data for this project.
* If there is no build info stored for that project, a new
* default BuildInfo is returned
*
* @return BuildInfo buildInfo build info for the specified project
* @param projectName String project name
*/
public static VAJBuildInfo loadBuildData(String projectName) {
VAJBuildInfo result = null;
try {
Project project =
VAJLocalUtil.getWorkspace().loadedProjectNamed(projectName);
if (project.testToolRepositoryData(TOOL_DATA_KEY)) {
ToolData td = project.getToolRepositoryData(TOOL_DATA_KEY);
String data = (String) td.getData();
result = VAJBuildInfo.parse(data);
} else {
result = new VAJBuildInfo();
}
result.setVAJProjectName(projectName);
} catch (Throwable t) {
throw new BuildException("BuildInfo for Project "
+ projectName + " could not be loaded" + t);
}
return result;
}


/**
* Starts the application.
*
* @param args an array of command-line arguments. VAJ puts the
* VAJ project name into args[1] when starting the
* tool from the project context menu
*/
public static void main(java.lang.String[] args) {
try {
VAJBuildInfo info;
if (args.length >= 2 && args[1] instanceof String) {
String projectName = (String) args[1];
info = loadBuildData(projectName);
} else {
info = new VAJBuildInfo();
}

VAJAntToolGUI mainFrame = new VAJAntToolGUI(info);
mainFrame.show();
} catch (Throwable t) {
// if all error handling fails, output at least
// something on the console
t.printStackTrace();
}
}


/**
* Saves the BuildInfo for a project in the VAJ repository.
*
* @param info BuildInfo build info to save
*/
public static void saveBuildData(VAJBuildInfo info) {
String data = info.asDataString();
try {
ToolData td = new ToolData(TOOL_DATA_KEY, data);
VAJLocalUtil.getWorkspace().loadedProjectNamed(
info.getVAJProjectName()).setToolRepositoryData(td);
} catch (Throwable t) {
throw new BuildException("BuildInfo for Project "
+ info.getVAJProjectName() + " could not be saved", t);
}
}
}

+ 0
- 1385
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
File diff suppressed because it is too large
View File


+ 0
- 471
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java View File

@@ -1,471 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;


import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Target;

/**
* This class wraps the Ant project information needed to
* start Ant from Visual Age.
* It serves the following purposes:
* - acts as model for AntMakeFrame
* - converts itself to/from String (to store the information
* as ToolData in the VA repository)
* - wraps Project functions for the GUI (get target list,
* execute target)
* - manages a seperate thread for Ant project execution
* this allows interrupting a running build from a GUI
*
*/

class VAJBuildInfo implements Runnable {
/**
* This exception is thrown when a build is interrupted
*/
public static class BuildInterruptedException extends BuildException {
public String toString() {
return "BUILD INTERRUPTED";
}
}

/**
* BuildListener which checks for interruption and throws Exception
* if build process is interrupted. This class is a wrapper around
* a 'real' listener.
*/
private class InterruptedChecker implements BuildListener {
// the real listener
BuildListener wrappedListener;

/**
* Can only be constructed as wrapper around a real listener
* @param listener the real listener
*/
public InterruptedChecker(BuildListener listener) {
super();
wrappedListener = listener;
}

/**
* checks if the thread was interrupted. When an
* interrupt occurred, throw an Exception to stop
* the execution.
*/
protected void checkInterrupted() {
if (buildThread.isInterrupted()) {
throw new BuildInterruptedException();
}
}

/**
* Fired after the last target has finished. This event
* will still be thrown if an error occurred during the build.
*/
public void buildFinished(BuildEvent event) {
wrappedListener.buildFinished(event);
checkInterrupted();
}

/**
* Fired before any targets are started.
*/
public void buildStarted(BuildEvent event) {
wrappedListener.buildStarted(event);
checkInterrupted();
}

/**
* Fired whenever a message is logged.
*/
public void messageLogged(BuildEvent event) {
wrappedListener.messageLogged(event);
checkInterrupted();
}

/**
* Fired when a target has finished. This event will
* still be thrown if an error occurred during the build.
*/
public void targetFinished(BuildEvent event) {
wrappedListener.targetFinished(event);
checkInterrupted();
}

/**
* Fired when a target is started.
*/
public void targetStarted(BuildEvent event) {
wrappedListener.targetStarted(event);
checkInterrupted();
}

/**
* Fired when a task has finished. This event will still
* be throw if an error occurred during the build.
*/
public void taskFinished(BuildEvent event) {
wrappedListener.taskFinished(event);
checkInterrupted();
}

/**
* Fired when a task is started.
*/
public void taskStarted(BuildEvent event) {
wrappedListener.taskStarted(event);
checkInterrupted();
}
}

// name of the VA project this BuildInfo belongs to
private String vajProjectName = "";

// name of the Ant build file
private String buildFileName = "";

// main targets found in the build file
private Vector projectTargets = new Vector();

// target selected for execution
private String target = "";

// log level
private int outputMessageLevel = Project.MSG_INFO;

// Ant Project created from build file
private transient Project project;

// is true if Project initialization was successful
private transient boolean projectInitialized = false;

// Support for bound properties
protected transient PropertyChangeSupport propertyChange;

// thread for Ant build execution
private Thread buildThread;

// the listener used to log output.
private BuildListener projectLogger;


/**
* The addPropertyChangeListener method was generated to support the
* propertyChange field.
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
getPropertyChange().addPropertyChangeListener(listener);
}

/**
* Returns the BuildInfo information as String. The BuildInfo can
* be rebuilt from that String by calling parse().
* @return String
*/
public String asDataString() {
String result = getOutputMessageLevel() + "|" + getBuildFileName()
+ "|" + getTarget();
for (Enumeration e = getProjectTargets().elements();
e.hasMoreElements();) {
result = result + "|" + e.nextElement();
}

return result;
}

/**
* Search for the insert position to keep names a sorted list of Strings
* This method has been copied from org.apache.tools.ant.Main
*/
private static int findTargetPosition(Vector names, String name) {
int res = names.size();
for (int i = 0; i < names.size() && res == names.size(); i++) {
if (name.compareTo((String) names.elementAt(i)) < 0) {
res = i;
}
}
return res;
}

/**
* The firePropertyChange method was generated to support the propertyChange field.
*/
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
getPropertyChange().firePropertyChange(propertyName, oldValue, newValue);
}

/**
* Returns the build file name.
* @return build file name.
*/
public String getBuildFileName() {
return buildFileName;
}

/**
* Returns the log level
* @return log level.
*/
public int getOutputMessageLevel() {
return outputMessageLevel;
}

/**
* Returns the Ant project
* @return org.apache.tools.ant.Project
*/
private Project getProject() {
if (project == null) {
project = new Project();
}
return project;
}

/**
* return a list of all targets in the current buildfile
*/
public Vector getProjectTargets() {
return projectTargets;
}

/**
* Accessor for the propertyChange field.
*/
protected PropertyChangeSupport getPropertyChange() {
if (propertyChange == null) {
propertyChange = new PropertyChangeSupport(this);
}
return propertyChange;
}

/**
* returns the selected target.
*/
public String getTarget() {
return target;
}

/**
* returns the VA project name
*/
public String getVAJProjectName() {
return vajProjectName;
}

/**
* Initializes the Ant project. Assumes that the
* project attribute is already set.
*/
private void initProject() {
try {
project.init();
File buildFile = new File(getBuildFileName());
project.setUserProperty("ant.file", buildFile.getAbsolutePath());
ProjectHelper.configureProject(project, buildFile);
setProjectInitialized(true);
} catch (RuntimeException exc) {
setProjectInitialized(false);
throw exc;
} catch (Error err) {
setProjectInitialized(false);
throw err;
}
}

/**
* Returns true, if the Ant project is initialized.
* (i.e., if the buildfile loaded).
*/
public boolean isProjectInitialized() {
return projectInitialized;
}

/**
* Creates a BuildInfo object from a String
* The String must be in the format
* outputMessageLevel'|'buildFileName'|'defaultTarget'|'(project target'|')*
*
* @return org.apache.tools.ant.taskdefs.optional.vaj.BuildInfo
* @param data String
*/
public static VAJBuildInfo parse(String data) {
VAJBuildInfo result = new VAJBuildInfo();

try {
StringTokenizer tok = new StringTokenizer(data, "|");
result.setOutputMessageLevel(tok.nextToken());
result.setBuildFileName(tok.nextToken());
result.setTarget(tok.nextToken());
while (tok.hasMoreTokens()) {
result.projectTargets.addElement(tok.nextToken());
}
} catch (Throwable t) {
// if parsing the info fails, just return
// an empty VAJBuildInfo
}
return result;
}

/**
* The removePropertyChangeListener method was generated
* to support the propertyChange field.
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
getPropertyChange().removePropertyChangeListener(listener);
}

/**
* Sets the build file name
* @param buildFileName build file name
*/
public void setBuildFileName(String newBuildFileName) {
String oldValue = buildFileName;
buildFileName = newBuildFileName;
setProjectInitialized(false);
firePropertyChange("buildFileName", oldValue, buildFileName);
}

/**
* Sets the log level (value must be one of the constants in Project)
* @param outputMessageLevel log level.
*/
public void setOutputMessageLevel(int newOutputMessageLevel) {
int oldValue = outputMessageLevel;
outputMessageLevel = newOutputMessageLevel;
firePropertyChange("outputMessageLevel",
new Integer(oldValue), new Integer(outputMessageLevel));
}

/**
* Sets the log level (value must be one of the constants in Project)
* @param outputMessageLevel log level as String.
*/
private void setOutputMessageLevel(String outputMessageLevel) {
int level = Integer.parseInt(outputMessageLevel);
setOutputMessageLevel(level);
}

/**
* sets the initialized flag
*/
private void setProjectInitialized(boolean initialized) {
Boolean oldValue = new Boolean(projectInitialized);
projectInitialized = initialized;
firePropertyChange("projectInitialized", oldValue, new Boolean(projectInitialized));
}

/**
* Sets the target to execute when executeBuild is called
* @param newTarget build target
*/
public void setTarget(String newTarget) {
String oldValue = target;
target = newTarget;
firePropertyChange("target", oldValue, target);
}

/**
* Sets the name of the Visual Age for Java project where
* this BuildInfo belongs to
* @param newProjectName VAJ project
*/
public void setVAJProjectName(String newVAJProjectName) {
String oldValue = vajProjectName;
vajProjectName = newVAJProjectName;
firePropertyChange("VAJProjectName", oldValue, vajProjectName);
}

/**
* reloads the build file and updates the target list
*/
public void updateTargetList() {
project = new Project();
initProject();
projectTargets.removeAllElements();
Enumeration ptargets = project.getTargets().elements();
while (ptargets.hasMoreElements()) {
Target currentTarget = (Target) ptargets.nextElement();
if (currentTarget.getDescription() != null) {
String targetName = currentTarget.getName();
int pos = findTargetPosition(projectTargets, targetName);
projectTargets.insertElementAt(targetName, pos);
}
}
}


/**
* cancels a build.
*/
public void cancelBuild() {
buildThread.interrupt();
}

/**
* Executes the target set by setTarget().
* @param listener BuildListener for the output of the build
*/
public void executeProject(BuildListener logger) {
projectLogger = logger;
buildThread = new Thread(this);
buildThread.setPriority(Thread.MIN_PRIORITY);
buildThread.start();
}

/**
* Executes a build. This method is executed by
* the Ant execution thread
*/
public void run() {
try {
InterruptedChecker ic = new InterruptedChecker(projectLogger);
BuildEvent e = new BuildEvent(getProject());
try {
ic.buildStarted(e);

if (!isProjectInitialized()) {
initProject();
}

project.addBuildListener(ic);
project.executeTarget(target);

ic.buildFinished(e);
} catch (Throwable t) {
e.setException(t);
ic.buildFinished(e);
} finally {
project.removeBuildListener(ic);
}
} catch (Throwable t2) {
System.out.println("unexpected exception!");
t2.printStackTrace();
}
}
}

+ 0
- 234
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java View File

@@ -1,234 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;


import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.PatternSet;

/**
* Export packages from the Visual Age for Java workspace.
* The packages are specified similar to all other MatchingTasks.
* Since the VA Workspace is not file based, this task is simulating
* a directory hierarchy for the workspace:
* The 'root' contains all project 'dir's, and the projects contain
* their respective package 'dir's.
* Example:
* <blockquote>
* &lt;vajexport destdir=&quot;C:/builddir/source&quot;&gt;
* &nbsp;&lt;include name=&quot;/MyVAProject/org/foo/subsystem1/**&quot; /&gt;
* &nbsp;&lt;exclude name=&quot;/MyVAProject/org/foo/subsystem1/test/**&quot;/&gt;
* &lt;/vajexport&gt;
* </blockquote>
* exports all packages in the project MyVAProject which start with
* 'org.foo.subsystem1' except of these starting with
* 'org.foo.subsystem1.test'.
*
* <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&#x2f;**,
* Java class libraries&#x2f;**, Sun class libraries&#x2f;**,
* JSP Page Compile Generated Code&#x2f;**, Visual Age*&#x2f;**</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: &lt;servername&gt; : &lt;port no&gt;)</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>
*
*/

public class VAJExport extends VAJTask {
//set set... method comments for description
protected File destDir;
protected boolean exportSources = true;
protected boolean exportResources = true;
protected boolean exportClasses = false;
protected boolean exportDebugInfo = false;
protected boolean useDefaultExcludes = true;
protected boolean overwrite = true;

protected PatternSet patternSet = new PatternSet();

/**
* add a name entry on the exclude list
*/
public PatternSet.NameEntry createExclude() {
return patternSet.createExclude();
}

/**
* add a name entry on the include list
*/
public PatternSet.NameEntry createInclude() {
return patternSet.createInclude();
}

/**
* do the export
*/
public void execute() throws BuildException {
// first off, make sure that we've got a destdir
if (destDir == null) {
throw new BuildException("destdir attribute must be set!");
}

// delegate the export to the VAJUtil object.
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());
}
}
}

/**
* Sets whether default exclusions should be used or not; default true.
*
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* should be used, "false"|"off"|"no" when they
* shouldn't be used.
*/
public void setDefaultexcludes(boolean useDefaultExcludes) {
this.useDefaultExcludes = useDefaultExcludes;
}

/**
* Set the destination directory into which the selected
* items should be exported; required.
*/
public void setDestdir(File destDir) {
this.destDir = destDir;
}

/**
* Sets the set of exclude patterns. Patterns may be separated by a comma
* or a space. Currently only patterns denoting packages are
* supported
*
* @param excludes the string containing the exclude patterns
*/
public void setExcludes(String excludes) {
patternSet.setExcludes(excludes);
}

/**
* optional flag to export the class files; default false.
*/
public void setExportClasses(boolean doExport) {
exportClasses = doExport;
}

/**
* optional flag to export the debug info; default false.
* debug info
*/
public void setExportDebugInfo(boolean doExport) {
exportDebugInfo = doExport;
}

/**
* optional flag to export the resource file; default true.
*/
public void setExportResources(boolean doExport) {
exportResources = doExport;
}

/**
* optional flag to export the Java files; default true.
*/
public void setExportSources(boolean doExport) {
exportSources = doExport;
}

/**
* Sets the set of include patterns. Patterns may be separated by a comma
* or a space. Currently only patterns denoting packages are
* supported
*
* @param includes the string containing the include patterns
*/
public void setIncludes(String includes) {
patternSet.setIncludes(includes);
}

/**
* if Overwrite is set, files will be overwritten during export
*/
public void setOverwrite(boolean doOverwrite) {
overwrite = doOverwrite;
}

}

+ 0
- 133
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java View File

@@ -1,133 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;


import java.io.File;

/**
* A Remote Access to Tools Servlet to extract package
* sets from the Workbench to the local file system.
* The following table describes the servlet parameters.
*
* <table border="1">
* <tr>
* <td><strong>Parameter</strong></td>
* <td><strong>Values</strong></td>
* <td><strong>Description</strong></td>
* </tr>
* <tr>
* <td>dir</td>
* <td>Any valid directory name on the server.</td>
* <td>The directory to export the files to on the machine
* where the servlet is being run. If the directory
* doesn't exist, it will be created.<p>
* Relative paths are relative to
* IBMVJava/ide/tools/com-ibm-ivj-toolserver,
* where IBMVJava is the VisualAge for Java installation
* directory.</td>
* </tr>
* <tr>
* <td>include</td>
* <td>See below.</td>
* <td>The pattern used to indicate which projects and
* packages to export.</td>
* </tr>
* <tr>
* <td>exclude</td>
* <td>See below</td>
* <td>The pattern used to indicate which projects and
* packages <em>not</em> to export.</td>
* </tr>
* <tr>
* <td>cls</td>
* <td>"yes" or "no" (without the quotes)</td>
* <td>Export class files. Defaults to "no".</td>
* </tr>
* <tr>
* <td>src</td>
* <td>"yes" or "no" (without the quotes)</td>
* <td>Export source files. Defaults to "yes".</td>
* </tr>
* <tr>
* <td>res</td>
* <td>"yes" or "no" (without the quotes)</td>
* <td>Export resource files associated with the included project(s).
* Defaults to "yes".</td>
* </tr>
* <tr>
* <td>dex</td>
* <td>"yes" or "no" (without the quotes)</td>
* <td>Use the default exclusion patterns. Defaults to "yes".
* See below for an explanation of default excludes.</td>
* </tr>
* <tr>
* <td>owr</td>
* <td>"yes" or "no" (without the quotes)</td>
* <td>Overwrite any existing files. Defaults to "yes".</td>
* </tr>
* </table>
*
* <p>The vajexport servlet uses include and exclude parameters to form
* the criteria for selecting packages to export. The parameter is
* broken up into ProjectName/packageNameSegments, where ProjectName
* is what you expect, and packageNameSegments is a partial (or complete)
* package name, separated by forward slashes, rather than periods.
* Each packageNameSegment can have wildcard characters.</p>
*
* <table border="1">
* <tr>
* <td><strong>Wildcard Characters</strong></td>
* <td><strong>Description</strong></td>
* </tr>
* <tr>
* <td>*</td>
* <td>Match zero or more characters in that segment.</td>
* </tr>
* <tr>
* <td>?</td>
* <td>Match one character in that segment.</td>
* </tr>
* <tr>
* <td>**</td>
* <td>Matches all characters in zero or more segments.</td>
* </tr>
* </table>
*
*/
public class VAJExportServlet extends VAJToolsServlet {
// constants for servlet param names
public static final String WITH_DEBUG_INFO = "deb";
public static final String OVERWRITE_PARAM = "owr";

/**
* Respond to a request to export packages from the Workbench.
*/
protected void executeRequest() {
getUtil().exportPackages(
new File(getFirstParamValueString(DIR_PARAM)),
getParamValues(INCLUDE_PARAM),
getParamValues(EXCLUDE_PARAM),
getBooleanParam(CLASSES_PARAM, false),
getBooleanParam(WITH_DEBUG_INFO, false),
getBooleanParam(RESOURCES_PARAM, true),
getBooleanParam(SOURCES_PARAM, true),
getBooleanParam(DEFAULT_EXCLUDES_PARAM, true),
getBooleanParam(OVERWRITE_PARAM, true));
}
}

+ 0
- 210
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java View File

@@ -1,210 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional.ide;


import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;

/**
* Import source, class files, and resources to the Visual Age for Java
* workspace.
* <p>
* Example:
* <pre>
* &lt;vajimport project="MyVAProject"&gt;
* &lt;fileset dir="src"&gt;
* &lt;include name="org/foo/subsystem1/**" /&gt;
* &lt;exclude name="/org/foo/subsystem1/test/**" /&gt;
* &lt;/fileset&gt;
* &lt;/vajexport&gt;
* </pre>
* import all source and resource files from the "src" directory
* which start with 'org.foo.subsystem1', except of these starting with
* 'org.foo.subsystem1.test' into the project MyVAProject.
* </p>
* <p>If MyVAProject isn't loaded into the Workspace, a new edition is
* created in the repository and automatically loaded into the Workspace.
* There has to be at least one nested FileSet element.
* </p>
* <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">project</td>
* <td valign="top">the name of the Project to import to</td>
* <td align="center" valign="top">Yes</td>
* </tr>
* <tr>
* <td valign="top">importSources</td>
* <td valign="top">import Java sources, defaults to "yes"</td>
* <td align="center" valign="top">No</td>
* </tr>
* <tr>
* <td valign="top">importResources</td>
* <td valign="top">import resource files (anything that doesn't
* end with .java or .class), defaults to "yes"</td>
* <td align="center" valign="top">No</td>
* </tr>
* <tr>
* <td valign="top">importClasses</td>
* <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: &lt;servername&gt; : &lt;port no&gt;)</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>
*
*/
public class VAJImport extends VAJTask {
protected Vector filesets = new Vector();
protected boolean importSources = true;
protected boolean importResources = true;
protected boolean importClasses = false;
protected String importProject = null;
protected boolean useDefaultExcludes = true;


/**
* 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) {
this.importProject = projectName;
}

/**
* Adds a set of files (nested fileset attribute).
*/
public void addFileset(FileSet set) {
filesets.addElement(set);
}

/**
* Flag to import .class files; optional, default false.
*/
public void setImportClasses(boolean importClasses) {
this.importClasses = importClasses;
}

/**
* Import resource files (anything that doesn't end in
* .class or .java); optional, default true.
*/
public void setImportResources(boolean importResources) {
this.importResources = importResources;
}

/**
* Import .java files; optional, default true.
*/
public void setImportSources(boolean importSources) {
this.importSources = importSources;
}

/**
* Sets whether default exclusions should be used or not.
*
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
* should be used, "false"|"off"|"no" when they
* shouldn't be used.
*/
public void setDefaultexcludes(boolean useDefaultExcludes) {
this.useDefaultExcludes = useDefaultExcludes;
}

/**
* Do the import.
*/
public void execute() throws BuildException {
if (filesets.size() == 0) {
throw new BuildException("At least one fileset is required!");
}

if (importProject == null || "".equals(importProject)) {
throw new BuildException("The VisualAge for Java Project name is required!");
}

try {
for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
importFileset((FileSet) e.nextElement());
}
} catch (BuildException ex) {
if (haltOnError) {
throw ex;
} else {
log(ex.toString());
}
}
}

/**
* Import all files from the fileset into the Project in the
* Workspace.
*/
protected void importFileset(FileSet fileset) {
LocalDirectoryScanner ds = new LocalDirectoryScanner();
fileset.setupDirectoryScanner(ds, this.getProject());
ds.scan();
if (ds.getIncludedFiles().length == 0) {
return;
}

String[] includes = ds.getIncludes();
String[] excludes = ds.getExcludes();

getUtil().importFiles(importProject, ds.getBasedir(),
includes, excludes,
importClasses, importResources, importSources,
useDefaultExcludes);
}
}

+ 0
- 65
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java View File

@@ -1,65 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;


/**
* A Remote Access to Tools Servlet to import a Project
* from files into the Repository. The following
* table describes the servlet parameters.
*
* <table>
* <tr>
* <td>Parameter</td>
* <td>Description</td>
* </tr>
* <tr>
* <td>project</td>
* <td>The name of the project where you want the imported
* items to go.
* </td>
* </tr>
* <tr>
* <td>dir</td>
* <td>The directory you want to import from.</td>
* </tr>
* </table>
*
*/
public class VAJImportServlet extends VAJToolsServlet {
/**
* Respond to a request to import files to the Repository
*/
protected void executeRequest() {
getUtil().importFiles(
getFirstParamValueString(PROJECT_NAME_PARAM),
new File(getFirstParamValueString(DIR_PARAM)),
getParamValues(INCLUDE_PARAM),
getParamValues(EXCLUDE_PARAM),
getBooleanParam(CLASSES_PARAM, false),
getBooleanParam(RESOURCES_PARAM, true),
getBooleanParam(SOURCES_PARAM, true),
false);
// no default excludes, because they
// are already added on client side
// getBooleanParam(DEFAULT_EXCLUDES_PARAM, true)

}
}

+ 0
- 92
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java View File

@@ -1,92 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.Vector;
import org.apache.tools.ant.BuildException;

/**
* 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>
* &lt;vajload&gt;
* &nbsp;&lt;project name=&quot;MyVAProject&quot; version=&quot;*&quot;/&gt;
* &nbsp;&lt;project name=&quot;Apache Xerces&quot; version=&quot;1.2.0&quot;/&gt;
* &nbsp;&lt;project name=&quot;Brand New Stuff&quot; version=&quot;**&quot;/&gt;
* &lt;/vajload&gt;
* </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: &lt;servername&gt; : &lt;port no&gt;)</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>
*
*/

public class VAJLoad extends VAJTask {
Vector projectDescriptions = new Vector();

/**
* Load specified projects.
*/
public void execute() {
try {
getUtil().loadProjects(projectDescriptions);
} catch (BuildException ex) {
if (haltOnError) {
throw ex;
} else {
log(ex.toString());
}
}
}

/**
* Add a project description entry on the project list.
* @return a project description
*/
public VAJProjectDescription createVAJProject() {
VAJProjectDescription d = new VAJProjectDescription();
projectDescriptions.addElement(d);
return d;
}
}

+ 0
- 48
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java View File

@@ -1,48 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional.ide;










/**
* This is only there for backward compatibility with the default task list
* and will be removed soon
*
* @ant.task ignore="true"
*/

public class VAJLoadProjects extends VAJLoad {
}













+ 0
- 71
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java View File

@@ -1,71 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.Vector;

/**
* A Remote Access to Tools Servlet to load a Project
* from the Repository into the Workbench. The following
* table describes the servlet parameters.
*
* <table>
* <tr>
* <td>Parameter</td>
* <td>Description</td>
* </tr>
* <tr>
* <td>project</td>
* <td>The name of the Project you want to load into
* the Workbench.</td>
* </tr>
* <tr>
* <td>version</td>
* <td>The version of the package you want to load into
* the Workbench.</td>
* </tr>
* </table>
*
*/
public class VAJLoadServlet extends VAJToolsServlet {

// constants for servlet param names
/**
* the version param string
*/
public static final String VERSION_PARAM = "version";

/**
* Respond to a request to load a project from the Repository
* into the Workbench.
*/
protected void executeRequest() {
String[] projectNames = getParamValues(PROJECT_NAME_PARAM);
String[] versionNames = getParamValues(VERSION_PARAM);

Vector projectDescriptions = new Vector(projectNames.length);
for (int i = 0; i < projectNames.length && i < versionNames.length; i++) {
VAJProjectDescription desc = new VAJProjectDescription();
desc.setName(projectNames[i]);
desc.setVersion(versionNames[i]);
projectDescriptions.addElement(desc);
}

util.loadProjects(projectDescriptions);
}
}

+ 0
- 459
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java View File

@@ -1,459 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import com.ibm.ivj.util.base.ExportCodeSpec;
import com.ibm.ivj.util.base.ImportCodeSpec;
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;


/**
* Helper class for VAJ tasks. Holds Workspace singleton and
* wraps IvjExceptions into BuildExceptions
*
*/
abstract class VAJLocalUtil implements VAJUtil {
// singleton containing the VAJ workspace
private static Workspace workspace;

/**
* Wraps IvjException into a BuildException
*
* @return org.apache.tools.ant.BuildException
* @param errMsg Additional error message
* @param e IvjException which is wrapped
*/
static BuildException createBuildException(
String errMsg, IvjException e) {
errMsg = errMsg + "\n" + e.getMessage();
String[] errors = e.getErrors();
if (errors != null) {
for (int i = 0; i < errors.length; i++) {
errMsg = errMsg + "\n" + errors[i];
}
}
return new BuildException(errMsg, e);
}

/**
* returns the current VAJ workspace.
* @return com.ibm.ivj.util.base.Workspace
*/
static Workspace getWorkspace() {
if (workspace == null) {
workspace = ToolEnv.connectToWorkspace();
if (workspace == null) {
throw new BuildException(
"Unable to connect to Workspace! "
+ "Make sure you are running in VisualAge for Java.");
}
}

return workspace;
}


//-----------------------------------------------------------
// export
//-----------------------------------------------------------

/**
* export packages
*/
public void exportPackages(File dest,
String[] includePatterns, String[] excludePatterns,
boolean exportClasses, boolean exportDebugInfo,
boolean exportResources, boolean exportSources,
boolean useDefaultExcludes, boolean overwrite) {
if (includePatterns == null || includePatterns.length == 0) {
log("You must specify at least one include attribute. "
+ "Not exporting", MSG_ERR);
} else {
try {
VAJWorkspaceScanner scanner = new VAJWorkspaceScanner();
scanner.setIncludes(includePatterns);
scanner.setExcludes(excludePatterns);
if (useDefaultExcludes) {
scanner.addDefaultExcludes();
}
scanner.scan();

Package[] packages = scanner.getIncludedPackages();

log("Exporting " + packages.length + " package(s) to "
+ dest, MSG_INFO);
for (int i = 0; i < packages.length; i++) {
log(" " + packages[i].getName(), MSG_VERBOSE);
}

ExportCodeSpec exportSpec = new ExportCodeSpec();
exportSpec.setPackages(packages);
exportSpec.includeJava(exportSources);
exportSpec.includeClass(exportClasses);
exportSpec.includeResources(exportResources);
exportSpec.includeClassDebugInfo(exportDebugInfo);
exportSpec.useSubdirectories(true);
exportSpec.overwriteFiles(overwrite);
exportSpec.setExportDirectory(dest.getAbsolutePath());

getWorkspace().exportData(exportSpec);
} catch (IvjException ex) {
throw createBuildException("Exporting failed!", ex);
}
}
}


//-----------------------------------------------------------
// load
//-----------------------------------------------------------

/**
* Load specified projects.
*/
public void loadProjects(Vector projectDescriptions) {
Vector expandedDescs = getExpandedDescriptions(projectDescriptions);

// output warnings for projects not found
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) {
VAJProjectDescription d = (VAJProjectDescription) e.nextElement();
if (!d.projectFound()) {
log("No Projects match the name " + d.getName(), MSG_WARN);
}
}

log("Loading " + expandedDescs.size()
+ " project(s) into workspace", MSG_INFO);

for (Enumeration e = expandedDescs.elements();
e.hasMoreElements();) {
VAJProjectDescription d = (VAJProjectDescription) e.nextElement();

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 '" + pe.getName() + "', Version '"
+ ((pe.getVersionName() != null) ? pe.getVersionName()
: "(" + pe.getVersionStamp() + ")")
+ "' into Workspace", MSG_VERBOSE);
pe.loadIntoWorkspace();
} catch (IvjException ex) {
throw createBuildException("Project '" + d.getName()
+ "' could not be loaded.", ex);
}
}
}

/**
* return project descriptions containing full project names instead
* of patterns with wildcards.
*/
private Vector getExpandedDescriptions(Vector projectDescs) {
Vector expandedDescs = new Vector(projectDescs.size());
try {
String[] projectNames =
getWorkspace().getRepository().getProjectNames();
for (int i = 0; i < projectNames.length; i++) {
for (Enumeration e = projectDescs.elements();
e.hasMoreElements();) {
VAJProjectDescription d = (VAJProjectDescription) e.nextElement();
String pattern = d.getName();
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) {
d.setProjectFound();
expandedDescs.addElement(new VAJProjectDescription(projectNames[i],
d.getVersion()));
break;
}
}
}
} catch (IvjException e) {
throw createBuildException("VA Exception occurred: ", e);
}

return expandedDescs;
}

/**
* Finds a specific project edition in the repository.
*
* @param name project name
* @param versionName project version name
* @return com.ibm.ivj.util.base.ProjectEdition the specified edition
*/
private ProjectEdition findProjectEdition(
String name, String versionName) {
try {
ProjectEdition[] editions = null;
editions = getWorkspace().getRepository().getProjectEditions(name);

if (editions == null) {
throw new BuildException("Project " + name + " doesn't exist");
}

ProjectEdition pe = null;
for (int i = 0; i < editions.length && pe == null; i++) {
if (versionName.equals(editions[i].getVersionName())) {
pe = editions[i];
}
}
if (pe == null) {
throw new BuildException("Version " + versionName
+ " of Project " + name + " doesn't exist");
}
return pe;

} catch (IvjException e) {
throw createBuildException("VA Exception occurred: ", 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 occurred: ", e);
}

}



//-----------------------------------------------------------
// import
//-----------------------------------------------------------


/**
* Do the import.
*/
public void importFiles(
String importProject, File srcDir,
String[] includePatterns, String[] excludePatterns,
boolean importClasses, boolean importResources,
boolean importSources, boolean useDefaultExcludes)
throws BuildException {

if (importProject == null || "".equals(importProject)) {
throw new BuildException("The VisualAge for Java project "
+ "name is required!");
}

ImportCodeSpec importSpec = new ImportCodeSpec();
importSpec.setDefaultProject(getVAJProject(importProject));

DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(srcDir);
ds.setIncludes(includePatterns);
ds.setExcludes(excludePatterns);
if (useDefaultExcludes) {
ds.addDefaultExcludes();
}
ds.scan();

Vector classes = new Vector();
Vector sources = new Vector();
Vector resources = new Vector();

scanForImport(srcDir, ds.getIncludedFiles(), classes, sources, resources);

StringBuffer summaryLog = new StringBuffer("Importing ");
addFilesToImport(importSpec, importClasses, classes, "Class", summaryLog);
addFilesToImport(importSpec, importSources, sources, "Java", summaryLog);
addFilesToImport(importSpec, importResources, resources, "Resource", summaryLog);
importSpec.setResourcePath(srcDir.getAbsolutePath());

summaryLog.append(" into the project '");
summaryLog.append(importProject);
summaryLog.append("'.");

log(summaryLog.toString(), MSG_INFO);

try {
Type[] importedTypes = getWorkspace().importData(importSpec);
if (importedTypes == null) {
throw new BuildException("Unable to import into Workspace!");
} else {
log(importedTypes.length + " types imported", MSG_DEBUG);
for (int i = 0; i < importedTypes.length; i++) {
log(importedTypes[i].getPackage().getName()
+ "." + importedTypes[i].getName()
+ " into " + importedTypes[i].getProject().getName(),
MSG_DEBUG);
}
}
} catch (IvjException ivje) {
throw createBuildException("Error while importing into workspace: ",
ivje);
}
}

/**
* get a project from the Workspace.
*/
static Project getVAJProject(String importProject) {
Project found = null;
Project[] currentProjects = getWorkspace().getProjects();

for (int i = 0; i < currentProjects.length; i++) {
Project p = currentProjects[i];
if (p.getName().equals(importProject)) {
found = p;
break;
}
}


if (found == null) {
try {
found = getWorkspace().createProject(importProject, true);
} catch (IvjException e) {
throw createBuildException("Error while creating Project "
+ importProject + ": ", e);
}
}

return found;
}


/**
* Sort the files into classes, sources, and resources.
*/
private void scanForImport(
File dir,
String[] files,
Vector classes,
Vector sources,
Vector resources) {
for (int i = 0; i < files.length; i++) {
String file = (new File(dir, files[i])).getAbsolutePath();
if (file.endsWith(".java") || file.endsWith(".JAVA")) {
sources.addElement(file);
} else
if (file.endsWith(".class") || file.endsWith(".CLASS")) {
classes.addElement(file);
} else {
// for resources VA expects the path relative to the resource path
resources.addElement(files[i]);
}
}
}

/**
* Adds files to an import specification. Helper method
* for importFiles()
*
* @param spec import specification
* @param doImport only add files if doImport is true
* @param files the files to add
* @param fileType type of files (Source/Class/Resource)
* @param summaryLog buffer for logging
*/
private void addFilesToImport(ImportCodeSpec spec, boolean doImport,
Vector files, String fileType,
StringBuffer summaryLog) {

if (doImport) {
String[] fileArr = new String[files.size()];
files.copyInto(fileArr);
try {
// here it is assumed that fileType is one of the
// following strings: // "Java", "Class", "Resource"
String methodName = "set" + fileType + "Files";
Class[] methodParams = new Class[]{fileArr.getClass()};
java.lang.reflect.Method method =
spec.getClass().getDeclaredMethod(methodName, methodParams);
method.invoke(spec, new Object[]{fileArr});
} catch (Exception e) {
throw new BuildException(e);
}
if (files.size() > 0) {
logFiles(files, fileType);
summaryLog.append(files.size());
summaryLog.append(" " + fileType.toLowerCase() + " file");
summaryLog.append(files.size() > 1 ? "s, " : ", ");
}
}
}

/**
* Logs a list of file names to the message log
* @param fileNames java.util.Vector file names to be logged
* @param type java.lang.String file type
*/
private void logFiles(Vector fileNames, String fileType) {
log(fileType + " files found for import:", MSG_VERBOSE);
for (Enumeration e = fileNames.elements(); e.hasMoreElements();) {
log(" " + e.nextElement(), MSG_VERBOSE);
}
}
}

+ 0
- 79
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java View File

@@ -1,79 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import org.apache.tools.ant.BuildException;

/**
* Type class. Holds information about a project edition.
*/
public class VAJProjectDescription {
private String name;
private String version;
private boolean projectFound;

public VAJProjectDescription() {
}

public VAJProjectDescription(String n, String v) {
name = n;
version = v;
}

public String getName() {
return name;
}

public String getVersion() {
return version;
}

public boolean projectFound() {
return projectFound;
}

/**
* name of the VAJ project to load into
* the workspace; required
*/
public void setName(String newName) {
if (newName == null || newName.equals("")) {
throw new BuildException("name attribute must be set");
}
name = newName;
}

/**
* name of the requested version; required.
*/
public void setVersion(String newVersion) {
if (newVersion == null || newVersion.equals("")) {
throw new BuildException("version attribute must be set");
}
version = newVersion;
}

/**
* this may be a helper method, and is being ignored for now

* @ant.attribute ignore="true"
*/
public void setProjectFound() {
projectFound = true;
}
}

+ 0
- 242
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java View File

@@ -1,242 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

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.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;

/**
* Helper class for VAJ tasks. Holds Workspace singleton and
* wraps IvjExceptions into BuildExceptions
*
*/
class VAJRemoteUtil implements VAJUtil {
// calling task
Task caller;

// VAJ remote tool server
String remoteServer;

public VAJRemoteUtil(Task caller, String remote) {
this.caller = caller;
this.remoteServer = remote;
}

/**
* export the array of Packages
*/
public void exportPackages(File destDir,
String[] includePatterns, String[] excludePatterns,
boolean exportClasses, boolean exportDebugInfo,
boolean exportResources, boolean exportSources,
boolean useDefaultExcludes, boolean overwrite) {
try {
String request = "http://" + remoteServer + "/servlet/vajexport";
Vector parameters = new Vector();
parameters.addElement(new URLParam(VAJExportServlet.WITH_DEBUG_INFO, exportDebugInfo));
parameters.addElement(new URLParam(VAJExportServlet.OVERWRITE_PARAM, overwrite));
assembleImportExportParams(parameters, destDir,
includePatterns, excludePatterns,
exportClasses, exportResources,
exportSources, useDefaultExcludes);
sendRequest(request, parameters);
} catch (Exception ex) {
throw new BuildException(ex);
}
}

/**
* Do the import.
*/
public void importFiles(
String importProject, File srcDir,
String[] includePatterns, String[] excludePatterns,
boolean importClasses, boolean importResources,
boolean importSources, boolean useDefaultExcludes) {
try {
String request = "http://" + remoteServer + "/servlet/vajimport";
Vector parameters = new Vector();
parameters.addElement(new
URLParam(VAJImportServlet.PROJECT_NAME_PARAM, importProject));
assembleImportExportParams(parameters, srcDir,
includePatterns, excludePatterns,
importClasses, importResources,
importSources, useDefaultExcludes);
sendRequest(request, parameters);
} catch (Exception ex) {
throw new BuildException(ex);
}

}

/**
* Add parameters common for import and export to vector
* Helper method to remove double code.
*/
private void assembleImportExportParams(Vector parameters,
File dir,
String[] includePatterns, String[] excludePatterns,
boolean includeClasses, boolean includeResources,
boolean includeSources, boolean useDefaultExcludes) {
parameters.addElement(new URLParam(VAJToolsServlet.DIR_PARAM, dir.getPath()));
parameters.addElement(new URLParam(VAJToolsServlet.CLASSES_PARAM, includeClasses));
parameters.addElement(new URLParam(VAJToolsServlet.RESOURCES_PARAM, includeResources));
parameters.addElement(new URLParam(VAJToolsServlet.SOURCES_PARAM, includeSources));
parameters.addElement(new URLParam(VAJToolsServlet.DEFAULT_EXCLUDES_PARAM, useDefaultExcludes));

if (includePatterns != null) {
for (int i = 0; i < includePatterns.length; i++) {
parameters.addElement(new
URLParam(VAJExportServlet.INCLUDE_PARAM, includePatterns[i]));
}
}
if (excludePatterns != null) {
for (int i = 0; i < excludePatterns.length; i++) {
parameters.addElement(new
URLParam(VAJExportServlet.EXCLUDE_PARAM, excludePatterns[i]));
}
}
}

/**
* Load specified projects.
*/
public void loadProjects(Vector projectDescriptions) {
try {
String request = "http://" + remoteServer + "/servlet/vajload";
Vector parameters = new Vector();
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) {
VAJProjectDescription pd = (VAJProjectDescription) e.nextElement();
parameters.addElement(new
URLParam(VAJLoadServlet.PROJECT_NAME_PARAM, pd.getName()));
parameters.addElement(new
URLParam(VAJLoadServlet.VERSION_PARAM, pd.getVersion()));
}
sendRequest(request, parameters);
} catch (Exception ex) {
throw new BuildException(ex);
}
}

/**
* logs a message.
*/
public void log(String msg, int level) {
caller.log(msg, level);
}

private class URLParam {
private String name;
private String value;
public URLParam(String name, String value) {
this.name = name;
this.value = value;
}
public URLParam(String name, boolean value) {
this.name = name;
this.value = (new Boolean(value)).toString();
}
public void setValue(String value) { this.value = value; }
public void setName(String name) { this.name = name; }
public String getName() { return name; }
public String getValue() { return value; }
}
/**
* Sends a servlet request.
*
* The passed URL and parameter list are combined into a
* valid URL (with proper URL encoding for the parameters)
* and the URL is requested.
*
* @param request Request URL without trailing characters (no ?)
* @param parameters Vector of URLParam objects to append as parameters.
*/
private void sendRequest(String request, Vector parameters) {
boolean requestFailed = false;
// Build request & URL encode parameters
String url = request + "?";
for (int i=0; i<parameters.size(); i++) {
URLParam p = (URLParam)parameters.elementAt(i);
url += p.getName() + "=" + URLEncoder.encode(p.getValue());
url += (i==parameters.size()-1)?"":"&";
}


try {
log("Request: " + url, MSG_DEBUG);

//must be HTTP connection
URL requestUrl = new URL(url);
HttpURLConnection connection =
(HttpURLConnection) requestUrl.openConnection();

InputStream is = null;
// retry three times
for (int i = 0; i < 3; i++) {
try {
is = connection.getInputStream();
break;
} catch (IOException ex) {
// ignore
}
}
if (is == null) {
log("Can't get " + url, MSG_ERR);
throw new BuildException("Couldn't execute " + url);
}

// log the response
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = br.readLine();
while (line != null) {
int level = MSG_ERR;
try {
// the first char of each line contains the log level
level = Integer.parseInt(line.substring(0, 1));
if (level == MSG_ERR) {
requestFailed = true;
}
} catch (Exception e) {
log("Response line doesn't contain log level!", MSG_ERR);
}
log(line.substring(2), level);
line = br.readLine();
}

} catch (IOException ex) {
log("Error sending tool request to VAJ" + ex, MSG_ERR);
throw new BuildException("Couldn't execute " + url);
}
if (requestFailed) {
throw new BuildException("VAJ tool request failed");
}
}
}

+ 0
- 81
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java View File

@@ -1,81 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

/**
* Super class for all VAJ tasks. Contains common
* attributes (remoteServer) and util methods
*
*/
import org.apache.tools.ant.Task;


public class VAJTask extends Task {
/**
* Adaption of VAJLocalUtil to Task context.
*/
class VAJLocalToolUtil extends VAJLocalUtil {
public void log(String msg, int level) {
VAJTask.this.log(msg, level);
}
}

// server name / port of VAJ remote tool api server
protected String remoteServer = null;

// 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
*/
protected VAJUtil getUtil() {
if (util == null) {
if (remoteServer == null) {
util = new VAJLocalToolUtil();
} else {
util = new VAJRemoteUtil(this, remoteServer);
}
}
return util;
}

/**
* Name and port of a remote tool server, optiona.
* Format: &lt;servername&gt;:&lt;port no&gt;.
* If this attribute is set, the tasks will be executed on the specified tool
* server.
*/
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;
}
}

+ 0
- 182
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java View File

@@ -1,182 +0,0 @@
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

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 org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.StringUtils;

/**
* Abstract base class to provide common services for the
* VAJ tool API servlets
*
*/
public abstract class VAJToolsServlet extends HttpServlet {
/**
* Adaptation of VAJUtil for servlet context.
*/
class VAJLocalServletUtil extends VAJLocalUtil {
public void log(String msg, int level) {
try {
if (msg != null) {
msg = msg.replace('\r', ' ');
int i = 0;
while (i < msg.length()) {
int nlPos = msg.indexOf('\n', i);
if (nlPos == -1) {
nlPos = msg.length();
}
response.getWriter().println(Integer.toString(level)
+ " " + msg.substring(i, nlPos));
i = nlPos + 1;
}
}
} catch (IOException e) {
throw new BuildException("logging failed. msg was: "
+ e.getMessage());
}
}
}

// constants for servlet param names
public static final String DIR_PARAM = "dir";
public static final String INCLUDE_PARAM = "include";
public static final String EXCLUDE_PARAM = "exclude";
public static final String CLASSES_PARAM = "cls";
public static final String SOURCES_PARAM = "src";
public static final String RESOURCES_PARAM = "res";
public static final String DEFAULT_EXCLUDES_PARAM = "dex";
public static final String PROJECT_NAME_PARAM = "project";


// current request
HttpServletRequest request;

// response to current request
HttpServletResponse response;

// implementation of VAJUtil used by the servlet
VAJUtil util;


/**
* Execute the request by calling the appropriate
* VAJ tool API methods. This method must be implemented
* by the concrete servlets
*/
protected abstract void executeRequest();

/**
* Respond to a HTTP request. This method initializes
* the servlet and handles errors.
* The real work is done in the abstract method executeRequest()
*/
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
try {
response = res;
request = req;
initRequest();
executeRequest();
} catch (BuildException e) {
util.log("Error occurred: " + e.getMessage(), VAJUtil.MSG_ERR);
} catch (Exception e) {
try {
if (!(e instanceof BuildException)) {
String trace = StringUtils.getStackTrace(e);
util.log("Program error in " + this.getClass().getName()
+ ":\n" + trace, VAJUtil.MSG_ERR);
}
} catch (Throwable t) {
t.printStackTrace();
} finally {
if (!(e instanceof BuildException)) {
throw new ServletException(e.getMessage());
}
}
}
}

/**
* initialize the servlet.
*/
protected void initRequest() throws IOException {
response.setContentType("text/ascii");
if (util == null) {
util = new VAJLocalServletUtil();
}
}

/**
* Get the VAJUtil implementation
*/
VAJUtil getUtil() {
return util;
}

/**
* Get the boolean value of a parameter.
*/
protected boolean getBooleanParam(String param) {
return getBooleanParam(param, false);
}

/**
* Get the boolean value of a parameter, with a default value if
* the parameter hasn't been passed to the servlet.
*/
protected boolean getBooleanParam(String param, boolean defaultValue) {
String value = getFirstParamValueString(param);
if (value != null) {
return toBoolean(value);
} else {
return defaultValue;
}
}

/**
* Returns the first encountered value for a parameter.
*/
protected String getFirstParamValueString(String param) {
String[] paramValuesArray = request.getParameterValues(param);
if (paramValuesArray == null) {
return null;
}
return paramValuesArray[0];
}

/**
* Returns all values for a parameter.
*/
protected String[] getParamValues(String param) {
return request.getParameterValues(param);
}

/**
* A utility method to translate the strings "yes", "true", and "ok"
* to boolean true, and everything else to false.
*/
protected boolean toBoolean(String string) {
String lower = string.toLowerCase();
return (lower.equals("yes") || lower.equals("true") || lower.equals("ok"));
}
}

+ 0
- 64
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java View File

@@ -1,64 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;
import java.util.Vector;

/**
* Helper interface for VAJ tasks. Encapsulates
* the interface to the VAJ tool API.
*
*/
interface VAJUtil {
// log levels
static final int MSG_DEBUG = 4;
static final int MSG_ERR = 0;
static final int MSG_INFO = 2;
static final int MSG_VERBOSE = 3;
static final int MSG_WARN = 1;

/**
* export the array of Packages
*/
void exportPackages(
File dest,
String[] includePatterns, String[] excludePatterns,
boolean exportClasses, boolean exportDebugInfo,
boolean exportResources, boolean exportSources,
boolean useDefaultExcludes, boolean overwrite);

/**
* Do the import.
*/
void importFiles(
String importProject, File srcDir,
String[] includePatterns, String[] excludePatterns,
boolean importClasses, boolean importResources,
boolean importSources, boolean useDefaultExcludes);

/**
* Load specified projects.
*/
void loadProjects(Vector projectDescriptions);

/**
* Logs a message with the specified log level.
*/
void log(String msg, int level);
}

+ 0
- 187
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java View File

@@ -1,187 +0,0 @@
/*
* Copyright 2001-2002,2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import com.ibm.ivj.util.base.IvjException;
import com.ibm.ivj.util.base.Package;
import com.ibm.ivj.util.base.Project;
import java.io.File;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.DirectoryScanner;

/**
* Class for scanning a Visual Age for Java workspace for packages matching
* a certain criteria.
* <p>
* These criteria consist of a set of include and exclude patterns. With these
* patterns, you can select which packages you want to have included, and which
* packages you want to have excluded. You can add patterns to be excluded by
* default with the addDefaultExcludes method. The patters that are excluded
* by default include
* <ul>
* <li>IBM*\**</li>
* <li>Java class libraries\**</li>
* <li>Sun class libraries*\**</li>
* <li>JSP Page Compile Generated Code\**</li>
* <li>VisualAge*\**</li>
* </ul>
* <p>
* This class works like DirectoryScanner.
*
* @see org.apache.tools.ant.DirectoryScanner
*
*/
class VAJWorkspaceScanner extends DirectoryScanner {

// Patterns that should be excluded by default.
private static final String[] DEFAULTEXCLUDES = {
"IBM*/**",
"Java class libraries/**",
"Sun class libraries*/**",
"JSP Page Compile Generated Code/**",
"VisualAge*/**",
};

// The packages that where found and matched at least
// one includes, and matched no excludes.
private Vector packagesIncluded = new Vector();

/**
* Adds the array with default exclusions to the current exclusions set.
*/
public void addDefaultExcludes() {
int excludesLength = excludes == null ? 0 : excludes.length;
String[] newExcludes;
newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length];
if (excludesLength > 0) {
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
}
for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].
replace('/', File.separatorChar).
replace('\\', File.separatorChar);
}
excludes = newExcludes;
}

/**
* Finds all Projects specified in include patterns.
*
* @return the projects
*/
public Vector findMatchingProjects() {
Project[] projects = VAJLocalUtil.getWorkspace().getProjects();

Vector matchingProjects = new Vector();

boolean allProjectsMatch = false;
for (int i = 0; i < projects.length; i++) {
Project project = projects[i];
for (int j = 0; j < includes.length && !allProjectsMatch; j++) {
StringTokenizer tok =
new StringTokenizer(includes[j], File.separator);
String projectNamePattern = tok.nextToken();
if (projectNamePattern.equals("**")) {
// if an include pattern starts with '**',
// all projects match
allProjectsMatch = true;
} else
if (match(projectNamePattern, project.getName())) {
matchingProjects.addElement(project);
break;
}
}
}

if (allProjectsMatch) {
matchingProjects = new Vector();
for (int i = 0; i < projects.length; i++) {
matchingProjects.addElement(projects[i]);
}
}

return matchingProjects;
}

/**
* Get the names of the packages that matched at least one of the include
* patterns, and didn't match one of the exclude patterns.
*
* @return the matching packages
*/
public Package[] getIncludedPackages() {
int count = packagesIncluded.size();
Package[] packages = new Package[count];
for (int i = 0; i < count; i++) {
packages[i] = (Package) packagesIncluded.elementAt(i);
}
return packages;
}

/**
* Scans the workspace for packages that match at least one include
* pattern, and don't match any exclude patterns.
*
*/
public void scan() {
if (includes == null) {
// No includes supplied, so set it to 'matches all'
includes = new String[1];
includes[0] = "**";
}
if (excludes == null) {
excludes = new String[0];
}

// only scan projects which are included in at least one include pattern
Vector matchingProjects = findMatchingProjects();
for (Enumeration e = matchingProjects.elements(); e.hasMoreElements();) {
Project project = (Project) e.nextElement();
scanProject(project);
}
}

/**
* Scans a project for packages that match at least one include
* pattern, and don't match any exclude patterns.
*
*/
public void scanProject(Project project) {
try {
Package[] packages = project.getPackages();
if (packages != null) {
for (int i = 0; i < packages.length; i++) {
Package item = packages[i];
// replace '.' by file seperator because the patterns are
// using file seperator syntax (and we can use the match
// methods this way).
String name =
project.getName()
+ File.separator
+ item.getName().replace('.', File.separatorChar);
if (isIncluded(name) && !isExcluded(name)) {
packagesIncluded.addElement(item);
}
}
}
} catch (IvjException e) {
throw VAJLocalUtil.createBuildException("VA Exception occurred: ", e);
}
}
}

+ 0
- 4
src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini View File

@@ -1,4 +0,0 @@
Name=Ant
Version=0.1
Help-Item=Ant Help,doc/VAJAntTool.html
Menu-Items=Ant Build,org.apache.tools.ant.taskdefs.optional.ide.VAJAntTool,-P;

Loading…
Cancel
Save