diff --git a/WHATSNEW b/WHATSNEW index fca5d6951..e985c7466 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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: ----------- diff --git a/build.xml b/build.xml index 94b2b5a19..ef3fd03e0 100644 --- a/build.xml +++ b/build.xml @@ -264,10 +264,6 @@ - - - - @@ -302,10 +298,6 @@ - - - - @@ -445,9 +437,6 @@ - @@ -463,9 +452,6 @@ - @@ -687,7 +673,6 @@ - - @@ -867,14 +851,12 @@ - - @@ -914,11 +896,9 @@ - - diff --git a/docs/manual/Integration/VAJAntTool.html b/docs/manual/Integration/VAJAntTool.html deleted file mode 100644 index e08d1fe4a..000000000 --- a/docs/manual/Integration/VAJAntTool.html +++ /dev/null @@ -1,568 +0,0 @@ - - - - - - Visual Age for Java Tasks and Plugin User Manual - - - -

Visual Age for Java Tasks and Plugin User Manual

- by
    -
  • Wolf Siberski - (siberski at kbs.uni-hannover.de) -
  • Christoph Wilhelms - (christoph.wilhelms at tui.de)
  • -
  • Martin Landers - (martin.landers at bea.de)
  • -
  • François Rey - (francois dot rey at capco dot com)
-Version 1.2.1 - 2003/01/16
-
-

Table of Contents

- - -
-

Introduction

-

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

-

What's new

- - - - - - -
2003/01/16 -
    -
  • Now works outside of VAJ. -
  • Added attribute haltonerror, "*" and "**" version qualifiers. -
  • Amended documentation (this file) accordingly. -
2001/06/14 -
    -
  • 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 - - http://www7.software.ibm.com/vad.nsf/Data/Document4366.  - -
  • It is possible to cancel a running build - executed from the plugin -
  • Improved error handling in the plugin. Now all - errors should show up either in the log window or in the - console.
- -

The Tasks

-At the moment there are three tasks which help integrating the VAJ repository -contents into an external build process: - - - - - - - - - - - -
VAJLoad
loads specified versions into the workspace
VAJExport
exports specified packages into the file system
VAJImport
imports specified files into the workspace
-

These tasks are described in detail below.

- - -
- -

-

VAJLoad

-

Description:

-

Loads a specified VAJ project version into the -workspace.

- -

Parameters

- - - - - - - - - - - - - -
AttributeDescriptionRequired
remote -

name and port of a remote tool server. (format: - <servername>:<port no>).
If this - attribute is set, the tasks will be executed on the specified tool - server. 

no
haltonerror -

Stop the build process if an error occurs, - (default: "yes")

no
- -

Parameters specified as nested elements

-

vajproject

- - - - - - - - - - - - - - -
AttributeDescriptionRequired
namename of the VAJ project to load into - the workspaceyes
version

name of the requested version, - or one of the special qualifiers "*" or "**"
- "*" loads the latest versioned edition of the project
- "**" will load the latest version (including open editions)

yes
- -

Example

-
<vajload remote="localhost:32767">
-    <vajproject name="My App" version="*"/>
-    <vajproject name="My Testcases" version="**"/>
-    <vajproject name="JUnit" version="3.2"/>
-</vajload>
-
- -
-

VAJExport

- -

Description:

-

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

- -

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
destdirlocation to store the exported -filesyes
exportSourcesexport source files (default: -"yes")no
exportResourcesexport resource files (default: - "yes")no
exportClassesexport class files (default: "no")no
exportDebugInfoinclude debug info in exported class - files (default: "no")no
defaultexcludes -

use default excludes when exporting (default: "yes").
Default excludes are: IBM*/**, Java - class libraries/**, Sun class libraries*/**, JSP Page Compile Generated - Code/**, VisualAge*/** 

no
overwrite overwrite existing files (default: - "yes")no
remote -

name and port of a remote tool server. (format: - <servername>:<port no>).
If this - attribute is set, the tasks will be executed on the specified tool - server. 

no
haltonerror -

Stop the build process if an error occurs, - (default: "yes")

no
- -

Parameters specified as nested elements

- -

include

-specifies the packages to include into the export - - - - - - - - - - -
AttributeDescriptionRequired
namename of the VAJ project and package to export.
- The first element of the name must be the project name,
- then the package name elements - separated by '/'.
yes
- -

exclude

-specifies the packages to exclude from the export
- - - - - - - - - - -
AttributeDescriptionRequired
namename of the VAJ project/package not to - exportyes
- -

Example

-
<vajexport destdir="${src.dir}" exportResources="no">
-    <include name="MyProject/**"/>
-    <exclude name="MyProject/test/**"/>
-</vajexport>
-
-This example exports all packages in the VAJ project 'MyProject', except -packages starting with 'test'. -

Default Excludes

-The default excludes are:
-
   IBM*/**
-    Java class libraries/**
-    Sun class libraries*/**
-    JSP Page Compile Generated Code/**
-    VisualAge*/**
-
-
-

VAJImport

- -

Description:

-

Imports Java source files, class files and/or resources -from the file system into VAJ. These imports can be specified with a fileset. -

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
projectimported files are added to this VAJ - projectyes
importSourcesimport source files (default: -"yes")no
importResourcesimport resource files (default: - "yes")no
importClassesimport class files (default: "no")no
remote -

name and port of a remote tool server. (format: - <servername>:<port no>).
If this - attribute is set, the tasks will be executed on the specified tool - server. 

no
haltonerror -

Stop the build process if an error occurs, - (default: "yes")

no
- -

Parameters specified as nested elements

- -

fileset

-A FileSet specifies the files to import. - -

Example

-
<vajimport project="Test" importClasses="true">
-    <fileset dir="${import.dir}">
-        <include name="com/sample/**/*.class"/>
-        <exclude name="com/sample/test/**"/>
-    </fileset>
-</vajimport>
-
-This example imports all class files in the directory ${import.dir}/com/sample -excluding those in the subdirectory test
- -
-

The -Plugin

-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 Usage). - -
-

Installation

-

We assume C:\IBMVJava as VAJ -install directory. If You have installed it elsewhere, adapt the pathes below. -

Plugin

-
    -
  • Create the directory - C:\IBMVJava\ide\tools\org-apache-tools-ant. -
  • Expand in that directory all the jars contained in the lib - directory of your Ant installation. -
  • copy default.ini (in - org\apache\tools\ant\taskdefs\optional\ide) to - C:\IBMVJava\ide\tools\org-apache-tools-ant\default.ini. - -
  • if you want to access this help from the Workbench, create the - directory C:\IBMVJava\ide\tools\org-apache-tools-ant\doc - and copy the files VAJAntTool.html, - toolmenu.gif and - anttool1.gif to it. -
  • VAJ has to be restarted to recognize the new tool. -
  • Now if You open the context menu of a project, You should see the entry - 'Ant Build' in the Tools submenu (see Usage). -
  • Make sure the tool works as expected.
-

Servlets for Remote Tool Access

-
    -
  • - For - a good introduction into the VAJ Remote Tool Access see the - great introduction from Glenn McAllister at - - http://www7.software.ibm.com/vad.nsf/Data/Document4366. It - is highly recommended to read this article before doing the installation (to - understand what you do :-) ). -
  • insert the following lines into - C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\servlet.properties. - Typically this file is empty. If not, be careful not to delete the other lines. - - -
    -
    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
    -
    -
  • Expand the Ant libraries (ant.jar and optional.jar - contained in the lib directory of your Ant installation) to the directory - C:\IBMVJava\ide\tools\com-ibm-ivj-toolserver\servlets\. -
  • configure the Remote Access (via - Window->Options..., then choose 'Remote Access To Tool API') as shown in - the following picture:
-

-

Now you should be able to execute VAJ Tasks from the -command line.

- -
-

Usage

-

Plugin

-

- When the tool is installed correctly and your Ant build -file is configured, it is really easy to use.
-Go to your Workbench, select the project you want to deploy and -open its context menu. In the submenu Tools you should find -the new entry Ant Build. Klick it to start the tool!

- -
- After a short time this frame should pop up: -
- This frame contains the following elements: -
    -
  • A menubar with some options described later -
  • The name of your selected VAJ project -
  • An entry field for the Ant XML buildfile with a browse - [...] button. The full qualified filename, including the directory is needed - here. -
  • 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 ( Re)Load  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 - Execute  button. -
  • A pulldown box for specifying the log level. -
  • Four buttons. Two of them I have already - described. The other are the Stop button to cancel a running build - and the third one is just the Close button to exit our small tool! -
  • Note that the build is canceled on the next console - output after pressing the Stop button, not - directly after pressing it.
-

-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 -Save -BuildInfo To Repository from the File menu. -Now your information is saved to this edition of your project and will -be loaded automatically the next time you start Ant Build.
-If you have closed the log window accidentally, it can be reopened -with the Log item in the File menu, and if you want to -know who developed this, just select About in the Help menu.

-

Servlets for Remote Tool Access

-

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.

-
-

Frequently Asked -Questions

-

Q: If I try to load a build -file, I get the error "Can't load default task list". Why?
-A: Ant not only contains class files, but also resource -files. This messsage appears if the file -
.../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.

-

Q: If I try to re-load a build -file, I get the error "XML parser factory has not been configured correctly". Why?
-A: Make sure the META-INF/services directory of the xercesImpl.jar has also been expanded -into the C:\IBMVJava\ide\tools\org-apache-tools-ant directory.

-

Q: I want to load, export -and build more then one Visual Age project to one jar! How to?
-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

-

Q: When I load my build -file, the list of targets is empty. Why?
-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.

-

Q: Is there a sample build -file available?
-A: Now you can find an example in this manual

-

Q: Why does it export my -entire workspace when I've already implicitly selected a project when starting -the Tool?
-A: This selection does not carry into -the buildfile you are using. Set the Project name at the beginning of the -"includes" parameter.

-

Q: When I import Ant into -my Workspace, I get Problems reported. Can I ignore them?
-A: It depends on the problems reported, and what you want to do with Ant. -Problems you can't ignore: -

    -
  • Classes from javax.xml.parser missing - install a compatible parser - (see installation) -
  • Classes from com.ibm.ivj.util missing - install the Visual Age IDE - Utility feature (see installation). -
  • Errors in optional tasks you use within your build - file
-
- -

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

- -

Q: I can export packages -from project 'ABC', but not from project 'XYZ'! Why?
-A: Common reasons are:

-
    -
  • The project is excluded by the default excludes (see - attribute 'defaultexcludes' of VAJExport) -
  • 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.
-

Q: How do I control the -import/export of sourcefiles, compiled files and project resources -explicity?
-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).

-
-

Known -Problems

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

VisualAge -for Java Versions

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

History

- - - - - - - - - - - - - - - - -
1.02000/09/11Initial Version
1.12001/02/14Added Task documentation and more FAQs - (thanks to Richard Bourke for the FAQ additions)
1.22001/07/02 -

Added documentation of new remote feature.
Minor corrections.

1.2.12003/01/16 -

Added documentation for haltonerror, "*" and "**" version qualifiers.

-
-
Copyright © 2001-2004 The Apache Software -Foundation. All rights Reserved.
- - diff --git a/docs/manual/OptionalTasks/icontract.html b/docs/manual/OptionalTasks/icontract.html deleted file mode 100644 index d08e370e7..000000000 --- a/docs/manual/OptionalTasks/icontract.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - -IContract Task - - - - -

icontract

-

Description

- -

-Instruments Java classes with iContract - DBC preprocessor.
- The task can generate a properties file for iControl, - 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. -

- -

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcdirLocation of the java files.Yes
instrumentdirIndicates where the instrumented source files should go.Yes
repositorydirIndicates where the repository source files should go.Yes
builddirIndicates where the compiled instrumented classes should go. - Defaults to the value of instrumentdir. - NOTE: 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).No
repbuilddirIndicates where the compiled repository classes should go. - Defaults to the value of repositorydir.No
preIndicates whether or not to instrument for preconditions. - Defaults to true unless controlfile is specified, in which case it - defaults to false.No
postIndicates whether or not to instrument for postconditions. - Defaults to true unless controlfile is specified, in which case it - defaults to false.No
invariantIndicates whether or not to instrument for invariants. - Defaults to true unless controlfile is specified, in which case it - defaults to false.No
failthrowableThe full name of the Throwable (Exception) that should be - thrown when an assertion is violated. Defaults to java.lang.ErrorNo
verbosityIndicates the verbosity level of iContract. Any combination - of error*,warning*,note*,info*,progress*,debug* (comma separated) can be - used. Defaults to error*No
quietIndicates 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 falseNo
updateicontrolIf 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 false.No
controlfileThe name of the control file to pass to iContract. Consider using iControl to generate the file. - Default is not to pass a file. Only if updateicontrol=true
classdirIndicates where compiled (uninstrumented) classes are located. - This is required in order to properly update the icontrol.properties file, not - for instrumentation.Only if updateicontrol=true
targetsName 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.No
- -

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

- -

Example:

- -

- Note: iContract will use the java compiler indicated by the project's - build.compiler property. See documentation of the Javac task for - more information.

-

- Nested includes and excludes can be done very much the same way as any subclass - of MatchingTask.

- -

Example:

- -
- <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">
-    <classpath refid="compile-classpath"/>
- </icontract>
-
- -
-

Copyright © 2001-2002,2004-2005 The Apache Software Foundation. All rights -Reserved.

- - - - diff --git a/docs/manual/OptionalTasks/test.html b/docs/manual/OptionalTasks/test.html deleted file mode 100644 index abcc27b53..000000000 --- a/docs/manual/OptionalTasks/test.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - -Test Task - - - - -

Test

-

Description

-

This is a primitive task to execute a unit test in the org.apache.testlet framework.

-

This task is deprecated as the Testlet framework has been -abandoned in favor of JUnit by the Avalon community.

-

Note: This task depends on external libraries not included -in the Ant distribution. See -Library Dependencies for more information. -

- -

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
showSuccessa boolean value indicating whether tests should display a - message on success - No
showBannera boolean value indicating whether a banner should be displayed - when starting testlet engine - No
forceShowTracea boolean indicating that a stack trace is displayed on any failure - No
showTracea boolean indicating that a stack trace is displayed on - error (but not normal failure) - No
-

-The user can also specify the nested <classpath> 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.

- -

Examples

-
-
-<test showSuccess="false" showBanner="false" showTrace="true" forceShowTrace="true">
-   <classpath refid="test.classpath"/>
-   <testlet>org.foo.MyTestlet</testlet>
-   <testlet>org.foo.MyOtherTestlet</testlet>
-</test>
-
-
-The above will run the testlets org.foo.MyTestlet and org.foo.MyOtherTestlet - -
-

Copyright © 2001-2005 The Apache Software Foundation. All rights -Reserved.

- - - - diff --git a/docs/manual/dirtasks.html b/docs/manual/dirtasks.html index 38b17d7e5..f335a6fd3 100644 --- a/docs/manual/dirtasks.html +++ b/docs/manual/dirtasks.html @@ -50,6 +50,7 @@ either:

<includesfile> and <excludesfile>. +

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.

@@ -128,8 +129,9 @@ For example, mypackage/test/ is interpreted as if it were But not:
       org/apache/CVS/foo/bar/Entries (foo/bar/
-      part does not match)
+      part does not match)
       
+ org/apache/jakarta/** @@ -201,7 +203,6 @@ tasks that can act as an implicit fileset:

  • <ejbjar>
  • <ejbc>
  • <cab>
  • -
  • <icontract>
  • <native2ascii>
  • <netrexxc>
  • @@ -212,10 +213,7 @@ tasks that can act as an implicit fileset:

  • <csc>
  • <vbc>
  • <translate>
  • -
  • - <vajexport> -
  • -
  • <image>
  • +
  • <image>
  • <jlink> (deprecated)
  • <jspc>
  • <wljspc>
  • @@ -280,7 +278,7 @@ default excludes by using the defaultexcludes task.


    -

    Copyright © 2000-2005 The Apache Software Foundation. All +

    Copyright © 2000-2006 The Apache Software Foundation. All rights Reserved.

    diff --git a/docs/manual/install.html b/docs/manual/install.html index faaa40237..37950c11f 100644 --- a/docs/manual/install.html +++ b/docs/manual/install.html @@ -469,13 +469,6 @@ you need jakarta-oro 2.0.1 or later, and commons-net< stylebook task CVS repository of http://xml.apache.org/cvs.html - - testlet.jar - deprecated test task - Build from the gzip compress tar archive in http://avalon.apache.org/historiccvs/testlet/ - antlr.jar antlr task @@ -627,15 +620,6 @@ Already included in jdk 1.4 http://java.sun.com/products/java-media/jai/ - - IContract - icontract task
    - Warning : the icontract jar file contains also antlr classes.
    - To make the antlr task work properly, remove antlr/ANTLRGrammarParseBehavior.class - from the icontract jar file installed under $ANT_HOME/lib. - http://www.reliable-systems.com/tools/ -

    Troubleshooting

    diff --git a/docs/manual/optionaltasklist.html b/docs/manual/optionaltasklist.html index af027ac82..2a7e6e4ce 100644 --- a/docs/manual/optionaltasklist.html +++ b/docs/manual/optionaltasklist.html @@ -28,7 +28,6 @@ EJB Tasks
    Echoproperties
    FTP
    -IContract
    Image
    Jarlib-available
    Jarlib-display
    @@ -71,9 +70,7 @@ Stylebook
    Symlink
    Telnet
    -Test
    Translate
    -Visual Age for Java Tasks
    Microsoft Visual SourceSafe Tasks
    Weblogic JSP Compiler
    XmlValidate
    diff --git a/docs/manual/running.html b/docs/manual/running.html index 1f3bea437..831ea3e69 100644 --- a/docs/manual/running.html +++ b/docs/manual/running.html @@ -345,7 +345,6 @@ org.apache.tools.ant.Executor implementation specified here. see javac, EJB Tasks (compiler attribute), - IContract, javah diff --git a/docs/manual/tasksoverview.html b/docs/manual/tasksoverview.html index 82f4a19f1..0dd597795 100644 --- a/docs/manual/tasksoverview.html +++ b/docs/manual/tasksoverview.html @@ -868,15 +868,6 @@ documentation.

    about all tasks currently known to Ant.

    - - IContract -

    Instruments Java classes using the - iContract DBC - preprocessor. This task can generate a properties file for - iControl, - a graphical user interface that lets you turn on/off assertions.

    - - Import

    Import another build file and potentially override targets @@ -1244,40 +1235,11 @@ documentation.

    report of the testcases results.

    - - Test -

    Executes a unit test in the org.apache.testlet - framework.

    - - - -

    - - - - - -
    - -Visual Age for Java Tasks -[Back to top]
    - - - - - - - - - -
    Task NameDescription
    - Visual Age for Java Tasks

    (See the documentation describing the Visual Age for Java - tasks.)


    -

    Copyright © 2001-2005 The Apache Software Foundation. +

    Copyright © 2001-2006 The Apache Software Foundation. All rights Reserved.

    diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 89675ef1b..4a00a8836 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -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 diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java b/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java deleted file mode 100644 index b8bd6d6cd..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java +++ /dev/null @@ -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. - *
    - * The task can generate a properties file for - * iControl, - * 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 - * - * http://www.reliable-systems.com/tools/ - *

    - * Thanks to Rainer Schmitz for enhancements and comments. - * - * - *

    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    AttributeDescriptionRequired
    srcdirLocation of the java files.Yes
    instrumentdirIndicates where the instrumented source - * files should go.Yes
    repositorydirIndicates where the repository source - * files should go.Yes
    builddirIndicates where the compiled instrumented - * classes should go. Defaults to the value of - * instrumentdir. - *

    - * NOTE: 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).
    No
    repbuilddirIndicates where the compiled repository classes - * should go. Defaults to the value of repositorydir.No
    preIndicates whether or not to instrument for - * preconditions. Defaults to true unless - * controlfile is specified, in which case it defaults - * to false.No
    postIndicates whether or not to instrument for - * postconditions. Defaults to true unless - * controlfile is specified, in which case it defaults - * to false.No
    invariantIndicates whether or not to instrument for invariants. - * Defaults to true unless controlfile is - * specified, in which case it defaults to - * false.No
    failthrowableThe full name of the Throwable (Exception) that - * should be thrown when an assertion is violated. - * Defaults to java.lang.ErrorNo
    verbosityIndicates the verbosity level of iContract. - * Any combination of - * error*,warning*,note*,info*,progress*,debug* - * (comma separated) can be used. Defaults to error*No
    quietIndicates 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 falseNo
    updateicontrolIf 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 false. - * No
    controlfileThe name of the control file to pass to iContract. - * Consider using iControl to generate the file. - * Default is not to pass a file. - * Only if updateicontrol=true
    classdirIndicates where compiled (unistrumented) classes are - * located. This is required in order to properly update - * the icontrol.properties file, not for instrumentation. - * Only if - * updateicontrol=true
    targetsName 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.No
    - * - *

    - * Note: iContract will use the java compiler indicated by the project's - * build.compiler property. See documentation of the Javac task for - * more information. - *

    - * Nested includes and excludes are also supported. - * - *

    Example:

    - *
    - * <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"
    - * >
    - *    <classpath refid="compile-classpath"/>
    - * </icontract>
    - * 
    - * - */ -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.
    - * 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; - } - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Test.java b/src/main/org/apache/tools/ant/taskdefs/optional/Test.java deleted file mode 100644 index 1ef97bd1d..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Test.java +++ /dev/null @@ -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 TestletEntry 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 boolean 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 String 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 boolean 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 boolean 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(); - } -} - - diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java deleted file mode 100644 index 48341cb0a..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java +++ /dev/null @@ -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); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java deleted file mode 100644 index 337ef217d..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java +++ /dev/null @@ -1,1385 +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.awt.BorderLayout; -import java.awt.Button; -import java.awt.Choice; -import java.awt.Dialog; -import java.awt.FileDialog; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Label; -import java.awt.List; -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.Panel; -import java.awt.SystemColor; -import java.awt.TextArea; -import java.awt.TextField; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.TextEvent; -import java.awt.event.TextListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.beans.PropertyChangeListener; -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.util.DateUtils; -import org.apache.tools.ant.util.StringUtils; - -/** - * This is a simple grafical user interface to provide the information needed - * by ANT and to start the build-process within IBM VisualAge for Java. - *

    - * I was using AWT to make it independent from the JDK-version. Please don't - * ask me for a Swing-version:I am very familiar with Swing and I really think - * that it's not necessary for such a simple gui! - *

    - * It is completely developed in VAJ using the visual composition editor. - * About 90% of the code is generated by VAJ, - * but in fact I did a lot of code-beautification ;-). - *

    - * @version 1.0 h - */ -public class VAJAntToolGUI extends Frame { - /** - * Members - */ - private VAJBuildLogger logger = new VAJBuildLogger(); - private static final String lineSeparator = "\r\n"; - private PrivateEventHandler iEventHandler = new PrivateEventHandler(); - - /** - * Members of the main-window - */ - // main model - private VAJBuildInfo iBuildInfo = null; - // Menue - private MenuBar iAntMakeMenuBar = null; - private Menu iFileMenu = null; - private MenuItem iSaveMenuItem = null; - private MenuItem iMenuSeparator = null; - private MenuItem iShowLogMenuItem = null; - private Menu iHelpMenu = null; - private MenuItem iAboutMenuItem = null; - // Container - private Panel iContentsPane = null; - private Panel iOptionenPanel = null; - private Panel iCommandButtonPanel = null; - // Project name - private Label iProjectLabel = null; - private Label iProjectText = null; - // XML-file - private Label iBuildFileLabel = null; - private TextField iBuildFileTextField = null; - private boolean iConnPtoP2Aligning = false; - private Button iBrowseButton = null; - private FileDialog iFileDialog = null; - // Options - private Choice iMessageOutputLevelChoice = null; - private Label iMessageOutputLevelLabel = null; - private Label iTargetLabel = null; - private List iTargetList = null; - // Command-buttons - private Button iBuildButton = null; - private Button iReloadButton = null; - private Button iCloseButton = null; - /** - * log-Window - */ - // Container - private Frame iMessageFrame = null; - private Panel iMessageCommandPanel = null; - private Panel iMessageContentPanel = null; - // Components - private TextArea iMessageTextArea = null; - private Button iMessageOkButton = null; - private Button iMessageClearLogButton = null; - /** - * About-dialog - */ - // Container - private Dialog iAboutDialog = null; - private Panel iAboutDialogContentPanel = null; - private Panel iAboutInfoPanel = null; - private Panel iAboutCommandPanel = null; - // Labels - private Label iAboutTitleLabel = null; - private Label iAboutDevLabel = null; - private Label iAboutContactLabel = null; - // Buttons - private Button iAboutOkButton = null; - - /** - * This internal BuildLogger, to be honest, is just a BuildListener. - * It does nearly the same as the DefaultLogger, but uses the Loggin-Window for output. - */ - private class VAJBuildLogger implements BuildListener { - private long startTime = System.currentTimeMillis(); - - /** - * VAJBuildLogger constructor comment. - */ - public VAJBuildLogger() { - super(); - } - - /** - * Fired after the last target has finished. This event - * will still be thrown if an error occurred during the build. - * - * @see BuildEvent#getException() - */ - public void buildFinished(BuildEvent event) { - getStopButton().setEnabled(false); - getBuildButton().setEnabled(true); - getBuildButton().requestFocus(); - - Throwable error = event.getException(); - - if (error == null) { - getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL"); - } else { - logException(error); - } - - getMessageTextArea().append(lineSeparator + "Total time: " - + DateUtils.formatElapsedTime(System.currentTimeMillis() - startTime)); - } - - - /** - * Outputs an exception. - */ - public void logException(Throwable error) { - getMessageTextArea().append(lineSeparator + "BUILD FAILED" + lineSeparator); - - if (error instanceof BuildException) { - getMessageTextArea().append(error.toString()); - - Throwable nested = ((BuildException) error).getException(); - if (nested != null) { - nested.printStackTrace(System.err); - } - } else { - error.printStackTrace(System.err); - } - } - - /** - * Fired before any targets are started. - */ - public void buildStarted(BuildEvent event) { - getStopButton().setEnabled(true); - getBuildButton().setEnabled(false); - getStopButton().requestFocus(); - - startTime = System.currentTimeMillis(); - getMessageTextArea().append(lineSeparator); - } - - /** - * Fired whenever a message is logged. - * - * @see BuildEvent#getMessage() - * @see BuildEvent#getPriority() - */ - public void messageLogged(BuildEvent event) { - if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) { - String msg = ""; - if (event.getTask() != null) { - msg = "[" + event.getTask().getTaskName() + "] "; - } - getMessageTextArea().append(lineSeparator + msg + event.getMessage()); - } - } - - /** - * Fired when a target has finished. This event will - * still be thrown if an error occurred during the build. - * - * @see BuildEvent#getException() - */ - public void targetFinished(BuildEvent event) { - } - - /** - * Fired when a target is started. - * - * @see BuildEvent#getTarget() - */ - public void targetStarted(BuildEvent event) { - if (getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO) { - getMessageTextArea().append(lineSeparator + event.getTarget().getName() + ":"); - } - } - - /** - * Fired when a task has finished. This event will still - * be throw if an error occurred during the build. - * - * @see BuildEvent#getException() - */ - public void taskFinished(BuildEvent event) { - } - - /** - * Fired when a task is started. - * - * @see BuildEvent#getTask() - */ - public void taskStarted(BuildEvent event) { - } - } - - /** - * Eventhandler to handle all AWT-events - */ - private class PrivateEventHandler - implements ActionListener, ItemListener, TextListener, - WindowListener, PropertyChangeListener { - /** - * ActionListener method - */ - public void actionPerformed(ActionEvent e) { - try { - /* #### Main App-Frame #### */ - // browse XML-File with filechooser - if (e.getSource() == VAJAntToolGUI.this.getBrowseButton()) { - getFileDialog().setDirectory(getBuildFileTextField().getText().substring(0, getBuildFileTextField().getText().lastIndexOf('\\') + 1)); - getFileDialog().setFile("*.xml"); - getFileDialog().show(); - if (!getFileDialog().getFile().equals("")) { - getBuildFileTextField().setText(getFileDialog().getDirectory() - + getFileDialog().getFile()); - } - } - // dispose and exit application - if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) { - dispose(); - System.exit(0); - } - // start build-process - if (e.getSource() == VAJAntToolGUI.this.getBuildButton()) { - executeTarget(); - } - if (e.getSource() == VAJAntToolGUI.this.getStopButton()) { - getBuildInfo().cancelBuild(); - } - if (e.getSource() == VAJAntToolGUI.this.getReloadButton()) { - try { - getBuildInfo().updateTargetList(); - fillList(); - } catch (Throwable fileNotFound) { - handleException(fileNotFound); - getTargetList().removeAll(); - getBuildButton().setEnabled(false); - } - } - // MenuItems - if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) { - saveBuildInfo(); - } - if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) { - getAboutDialog().show(); - } - if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) { - getMessageFrame().show(); - } - /* #### About dialog #### */ - if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) { - getAboutDialog().dispose(); - } - /* #### Log frame #### */ - if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) { - getMessageFrame().dispose(); - } - if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) { - getMessageTextArea().setText(""); - } - if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) { - getMessageFrame().dispose(); - } - } catch (Throwable exc) { - handleException(exc); - } - } - - /** - * ItemListener method - */ - public void itemStateChanged(ItemEvent e) { - try { - if (e.getSource() == VAJAntToolGUI.this.getTargetList()) { - getBuildButton().setEnabled(true); - } - if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) { - getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex()); - } - if (e.getSource() == VAJAntToolGUI.this.getTargetList()) { - getBuildInfo().setTarget(getTargetList().getSelectedItem()); - } - } catch (Throwable exc) { - handleException(exc); - } - } - - /** - * PropertyChangeListener method - */ - public void propertyChange(java.beans.PropertyChangeEvent evt) { - if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() - && (evt.getPropertyName().equals("projectName"))) { - connectProjectNameToLabel(); - } - if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() - && (evt.getPropertyName().equals("buildFileName"))) { - connectBuildFileNameToTextField(); - } - } - - /** - * TextListener method - */ - public void textValueChanged(TextEvent e) { - if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) { - connectTextFieldToBuildFileName(); - } - } - - /** - * WindowListener methods - */ - public void windowClosing(WindowEvent e) { - try { - if (e.getSource() == VAJAntToolGUI.this) { - dispose(); - System.exit(0); - } - if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) { - getAboutDialog().dispose(); - } - if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) { - getMessageFrame().dispose(); - } - } catch (Throwable exc) { - handleException(exc); - } - } - public void windowActivated(WindowEvent e) { - } - public void windowClosed(WindowEvent e) { - } - public void windowDeactivated(WindowEvent e) { - } - public void windowDeiconified(WindowEvent e) { - } - public void windowIconified(WindowEvent e) { - } - public void windowOpened(WindowEvent e) { - } - } - - /** - * AntMake default-constructor. - */ - private VAJAntToolGUI() { - super(); - initialize(); - } - /** - * AntMake constructor called by VAJAntTool integration. - * @param newBuildInfo VAJBuildInfo - */ - public VAJAntToolGUI(VAJBuildInfo newBuildInfo) { - super(); - setBuildInfo(newBuildInfo); - initialize(); - } - /** - * This method is used to center dialogs. - */ - public static void centerDialog(Dialog dialog) { - dialog.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (dialog.getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (dialog.getSize().height / 2)); - } - /** - * connectBuildFileNameToTextField: (BuildInfo.buildFileName <--> BuildFileTextField.text) - */ - private void connectBuildFileNameToTextField() { - /* Set the target from the source */ - try { - if (iConnPtoP2Aligning == false) { - iConnPtoP2Aligning = true; - if ((getBuildInfo() != null)) { - getBuildFileTextField().setText(getBuildInfo().getBuildFileName()); - } - iConnPtoP2Aligning = false; - } - } catch (Throwable iExc) { - iConnPtoP2Aligning = false; - handleException(iExc); - } - } - /** - * connectProjectNameToLabel: (BuildInfo.vajProjectName <--> ProjectText.text) - */ - private void connectProjectNameToLabel() { - /* Set the target from the source */ - try { - if ((getBuildInfo() != null)) { - getProjectText().setText(getBuildInfo().getVAJProjectName()); - } - } catch (Throwable iExc) { - handleException(iExc); - } - } - /** - * connectTextFieldToBuildFileName: (BuildInfo.buildFileName <--> BuildFileTextField.text) - */ - private void connectTextFieldToBuildFileName() { - /* Set the source from the target */ - try { - if (iConnPtoP2Aligning == false) { - iConnPtoP2Aligning = true; - if ((getBuildInfo() != null)) { - getBuildInfo().setBuildFileName(getBuildFileTextField().getText()); - } - iConnPtoP2Aligning = false; - } - } catch (Throwable iExc) { - iConnPtoP2Aligning = false; - handleException(iExc); - } - } - /** - * external build of a .jar-file - */ - private void executeTarget() { - try { - getMessageFrame().show(); - getBuildInfo().executeProject(logger); - } catch (Throwable exc) { - logger.logException(exc); - } - return; - } - /** - * Fills the taget-list with project-targets - */ - private void fillList() { - getTargetList().removeAll(); - Vector targets = getBuildInfo().getProjectTargets(); - for (int i = 0; i < targets.size(); i++) { - getTargetList().add(targets.elementAt(i).toString()); - } - getTargetList().select(iBuildInfo.getProjectTargets().indexOf(iBuildInfo.getTarget())); - if (getTargetList().getSelectedIndex() >= 0) { - getBuildButton().setEnabled(true); - } - } - - /** - * Return the AboutCommandPanel property value. - * @return java.awt.Panel - */ - private Panel getAboutCommandPanel() { - if (iAboutCommandPanel == null) { - try { - iAboutCommandPanel = new Panel(); - iAboutCommandPanel.setName("AboutCommandPanel"); - iAboutCommandPanel.setLayout(new java.awt.FlowLayout()); - getAboutCommandPanel().add(getAboutOkButton(), getAboutOkButton().getName()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutCommandPanel; - } - /** - * Return the AboutContactLabel property value. - * @return java.awt.Label - */ - private Label getAboutContactLabel() { - if (iAboutContactLabel == null) { - try { - iAboutContactLabel = new Label(); - iAboutContactLabel.setName("AboutContactLabel"); - iAboutContactLabel.setAlignment(java.awt.Label.CENTER); - iAboutContactLabel.setText("contact: wolf.siberski@tui.de or " - + "christoph.wilhelms@tui.de"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutContactLabel; - } - /** - * Return the AboutDevLabel property value. - * @return java.awt.Label - */ - private Label getAboutDevLabel() { - if (iAboutDevLabel == null) { - try { - iAboutDevLabel = new Label(); - iAboutDevLabel.setName("AboutDevLabel"); - iAboutDevLabel.setAlignment(java.awt.Label.CENTER); - iAboutDevLabel.setText("developed by Wolf Siberski & Christoph Wilhelms"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutDevLabel; - } - /** - * Return the AboutDialog property value. - * @return java.awt.Dialog - */ - private Dialog getAboutDialog() { - if (iAboutDialog == null) { - try { - iAboutDialog = new Dialog(this); - iAboutDialog.setName("AboutDialog"); - iAboutDialog.setResizable(false); - iAboutDialog.setLayout(new java.awt.BorderLayout()); - iAboutDialog.setBounds(550, 14, 383, 142); - iAboutDialog.setModal(true); - iAboutDialog.setTitle("About..."); - getAboutDialog().add(getAboutDialogContentPanel(), "Center"); - iAboutDialog.pack(); - centerDialog(iAboutDialog); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutDialog; - } - /** - * Return the AboutDialogContentPanel property value. - * @return java.awt.Panel - */ - private Panel getAboutDialogContentPanel() { - if (iAboutDialogContentPanel == null) { - try { - iAboutDialogContentPanel = new Panel(); - iAboutDialogContentPanel.setName("AboutDialogContentPanel"); - iAboutDialogContentPanel.setLayout(new java.awt.BorderLayout()); - getAboutDialogContentPanel().add(getAboutCommandPanel(), "South"); - getAboutDialogContentPanel().add(getAboutInfoPanel(), "Center"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutDialogContentPanel; - } - /** - * Return the AboutInfoPanel property value. - * @return java.awt.Panel - */ - private Panel getAboutInfoPanel() { - if (iAboutInfoPanel == null) { - try { - iAboutInfoPanel = new Panel(); - iAboutInfoPanel.setName("AboutInfoPanel"); - iAboutInfoPanel.setLayout(new GridBagLayout()); - - GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints(); - constraintsAboutTitleLabel.gridx = 0; constraintsAboutTitleLabel.gridy = 0; - constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutTitleLabel.weightx = 1.0; - constraintsAboutTitleLabel.weighty = 1.0; - constraintsAboutTitleLabel.insets = new Insets(4, 0, 4, 0); - getAboutInfoPanel().add(getAboutTitleLabel(), constraintsAboutTitleLabel); - - GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints(); - constraintsAboutDevLabel.gridx = 0; constraintsAboutDevLabel.gridy = 1; - constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutDevLabel.weightx = 1.0; - constraintsAboutDevLabel.insets = new Insets(4, 0, 0, 0); - getAboutInfoPanel().add(getAboutDevLabel(), constraintsAboutDevLabel); - - GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints(); - constraintsAboutContactLabel.gridx = 0; constraintsAboutContactLabel.gridy = 2; - constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutContactLabel.weightx = 1.0; - constraintsAboutContactLabel.insets = new Insets(2, 0, 4, 0); - getAboutInfoPanel().add(getAboutContactLabel(), constraintsAboutContactLabel); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutInfoPanel; - } - /** - * Return the AboutMenuItem property value. - * @return java.awt.MenuItem - */ - private MenuItem getAboutMenuItem() { - if (iAboutMenuItem == null) { - try { - iAboutMenuItem = new MenuItem(); - iAboutMenuItem.setLabel("About..."); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutMenuItem; - } - /** - * Return the AboutOkButton property value. - * @return java.awt.Button - */ - private Button getAboutOkButton() { - if (iAboutOkButton == null) { - try { - iAboutOkButton = new Button(); - iAboutOkButton.setName("AboutOkButton"); - iAboutOkButton.setLabel("OK"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutOkButton; - } - /** - * Return the AboutTitleLabel property value. - * @return java.awt.Label - */ - private Label getAboutTitleLabel() { - if (iAboutTitleLabel == null) { - try { - iAboutTitleLabel = new Label(); - iAboutTitleLabel.setName("AboutTitleLabel"); - iAboutTitleLabel.setFont(new Font("Arial", 1, 12)); - iAboutTitleLabel.setAlignment(Label.CENTER); - iAboutTitleLabel.setText("Ant VisualAge for Java Tool-Integration"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAboutTitleLabel; - } - /** - * Return the AntMakeMenuBar property value. - * @return java.awt.MenuBar - */ - private MenuBar getAntMakeMenuBar() { - if (iAntMakeMenuBar == null) { - try { - iAntMakeMenuBar = new MenuBar(); - iAntMakeMenuBar.add(getFileMenu()); - iAntMakeMenuBar.add(getHelpMenu()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iAntMakeMenuBar; - } - /** - * Return the BrowseButton property value. - * @return Button - */ - private Button getBrowseButton() { - if (iBrowseButton == null) { - try { - iBrowseButton = new Button(); - iBrowseButton.setName("BrowseButton"); - iBrowseButton.setLabel("..."); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iBrowseButton; - } - /** - * Return the BuildButton property value. - * @return java.awt.Button - */ - private Button getBuildButton() { - if (iBuildButton == null) { - try { - iBuildButton = new Button(); - iBuildButton.setName("BuildButton"); - iBuildButton.setLabel("Execute"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iBuildButton; - } - /** - * Return the BuildFileLabel property value. - * @return java.awt.Label - */ - private Label getBuildFileLabel() { - if (iBuildFileLabel == null) { - try { - iBuildFileLabel = new Label(); - iBuildFileLabel.setName("BuildFileLabel"); - iBuildFileLabel.setText("Ant-Buildfile:"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iBuildFileLabel; - } - /** - * Return the BuildFileTextField property value. - * @return java.awt.TextField - */ - private TextField getBuildFileTextField() { - if (iBuildFileTextField == null) { - try { - iBuildFileTextField = new TextField(); - iBuildFileTextField.setName("BuildFileTextField"); - iBuildFileTextField.setBackground(SystemColor.textHighlightText); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iBuildFileTextField; - } - /** - * Return the BuildInfo property value. - * @return org.apache.tools.ant.taskdefs.optional.ide.VAJBuildInfo - */ - private VAJBuildInfo getBuildInfo() { - return iBuildInfo; - } - /** - * Return the CloseButton property value. - * @return java.awt.Button - */ - private Button getCloseButton() { - if (iCloseButton == null) { - try { - iCloseButton = new Button(); - iCloseButton.setName("CloseButton"); - iCloseButton.setLabel("Close"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iCloseButton; - } - /** - * Return the CommandButtonPanel property value. - * @return java.awt.Panel - */ - private Panel getCommandButtonPanel() { - if (iCommandButtonPanel == null) { - try { - iCommandButtonPanel = new Panel(); - iCommandButtonPanel.setName("CommandButtonPanel"); - iCommandButtonPanel.setLayout(getCommandButtonPanelFlowLayout()); - iCommandButtonPanel.setBackground(SystemColor.control); - iCommandButtonPanel.add(getReloadButton()); - iCommandButtonPanel.add(getBuildButton()); - iCommandButtonPanel.add(getStopButton()); - iCommandButtonPanel.add(getCloseButton()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iCommandButtonPanel; - } - /** - * Return the CommandButtonPanelFlowLayout property value. - * @return java.awt.FlowLayout - */ - private FlowLayout getCommandButtonPanelFlowLayout() { - FlowLayout iCommandButtonPanelFlowLayout = null; - try { - /* Create part */ - iCommandButtonPanelFlowLayout = new FlowLayout(); - iCommandButtonPanelFlowLayout.setAlignment(FlowLayout.RIGHT); - } catch (Throwable iExc) { - handleException(iExc); - } - return iCommandButtonPanelFlowLayout; - } - /** - * Return the ContentsPane property value. - * @return java.awt.Panel - */ - private Panel getContentsPane() { - if (iContentsPane == null) { - try { - iContentsPane = new Panel(); - iContentsPane.setName("ContentsPane"); - iContentsPane.setLayout(new BorderLayout()); - getContentsPane().add(getCommandButtonPanel(), "South"); - getContentsPane().add(getOptionenPanel(), "Center"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iContentsPane; - } - /** - * Return the FileDialog property value. - * @return java.awt.FileDialog - */ - private FileDialog getFileDialog() { - if (iFileDialog == null) { - try { - iFileDialog = new FileDialog(this); - iFileDialog.setName("FileDialog"); - iFileDialog.setLayout(null); - centerDialog(iFileDialog); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iFileDialog; - } - /** - * Return the FileMenu property value. - * @return java.awt.Menu - */ - private Menu getFileMenu() { - if (iFileMenu == null) { - try { - iFileMenu = new Menu(); - iFileMenu.setLabel("File"); - iFileMenu.add(getSaveMenuItem()); - iFileMenu.add(getMenuSeparator()); - iFileMenu.add(getShowLogMenuItem()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iFileMenu; - } - /** - * Return the HelpMenu property value. - * @return java.awt.Menu - */ - private Menu getHelpMenu() { - if (iHelpMenu == null) { - try { - iHelpMenu = new Menu(); - iHelpMenu.setLabel("Help"); - iHelpMenu.add(getAboutMenuItem()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iHelpMenu; - } - /** - * Return the MenuSeparator1 property value. - * @return java.awt.MenuItem - */ - private MenuItem getMenuSeparator() { - if (iMenuSeparator == null) { - try { - iMenuSeparator = new MenuItem(); - iMenuSeparator.setLabel("-"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMenuSeparator; - } - /** - * Return the MessageClearLogButton property value. - * @return java.awt.Button - */ - private Button getMessageClearLogButton() { - if (iMessageClearLogButton == null) { - try { - iMessageClearLogButton = new Button(); - iMessageClearLogButton.setName("MessageClearLogButton"); - iMessageClearLogButton.setLabel("Clear Log"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageClearLogButton; - } - /** - * Return the MessageCommandPanel property value. - * @return java.awt.Panel - */ - private Panel getMessageCommandPanel() { - if (iMessageCommandPanel == null) { - try { - iMessageCommandPanel = new Panel(); - iMessageCommandPanel.setName("MessageCommandPanel"); - iMessageCommandPanel.setLayout(new FlowLayout()); - getMessageCommandPanel().add(getMessageClearLogButton(), - getMessageClearLogButton().getName()); - getMessageCommandPanel().add(getMessageOkButton(), - getMessageOkButton().getName()); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageCommandPanel; - } - /** - * Return the MessageContentPanel property value. - * @return java.awt.Panel - */ - private Panel getMessageContentPanel() { - if (iMessageContentPanel == null) { - try { - iMessageContentPanel = new Panel(); - iMessageContentPanel.setName("MessageContentPanel"); - iMessageContentPanel.setLayout(new BorderLayout()); - iMessageContentPanel.setBackground(SystemColor.control); - getMessageContentPanel().add(getMessageTextArea(), "Center"); - getMessageContentPanel().add(getMessageCommandPanel(), "South"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageContentPanel; - } - /** - * Return the MessageFrame property value. - * @return java.awt.Frame - */ - private Frame getMessageFrame() { - if (iMessageFrame == null) { - try { - iMessageFrame = new Frame(); - iMessageFrame.setName("MessageFrame"); - iMessageFrame.setLayout(new BorderLayout()); - iMessageFrame.setBounds(0, 0, 750, 250); - iMessageFrame.setTitle("Message Log"); - iMessageFrame.add(getMessageContentPanel(), "Center"); - iMessageFrame.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - - (iMessageFrame.getSize().width / 2), - (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2)); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageFrame; - } - /** - * Return the MessageOkButton property value. - * @return java.awt.Button - */ - private Button getMessageOkButton() { - if (iMessageOkButton == null) { - try { - iMessageOkButton = new Button(); - iMessageOkButton.setName("MessageOkButton"); - iMessageOkButton.setLabel("Close"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageOkButton; - } - /** - * Return the MessageOutputLevelChoice property value. - * @return java.awt.Choice - */ - private Choice getMessageOutputLevelChoice() { - if (iMessageOutputLevelChoice == null) { - try { - iMessageOutputLevelChoice = new Choice(); - iMessageOutputLevelChoice.setName("MessageOutputLevelChoice"); - iMessageOutputLevelChoice.add("Error"); - iMessageOutputLevelChoice.add("Warning"); - iMessageOutputLevelChoice.add("Info"); - iMessageOutputLevelChoice.add("Verbose"); - iMessageOutputLevelChoice.add("Debug"); - iMessageOutputLevelChoice.select(2); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageOutputLevelChoice; - } - /** - * Return the MessageOutputLevelLabel property value. - * @return java.awt.Label - */ - private Label getMessageOutputLevelLabel() { - if (iMessageOutputLevelLabel == null) { - try { - iMessageOutputLevelLabel = new Label(); - iMessageOutputLevelLabel.setName("MessageOutputLevelLabel"); - iMessageOutputLevelLabel.setText("Message Level:"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageOutputLevelLabel; - } - /** - * Return the MessageTextArea property value. - * @return java.awt.TextArea - */ - private TextArea getMessageTextArea() { - if (iMessageTextArea == null) { - try { - iMessageTextArea = new TextArea(); - iMessageTextArea.setName("MessageTextArea"); - iMessageTextArea.setFont(new Font("monospaced", 0, 12)); - iMessageTextArea.setText(""); - iMessageTextArea.setEditable(false); - iMessageTextArea.setEnabled(true); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iMessageTextArea; - } - /** - * Return the Panel1 property value. - * @return java.awt.Panel - */ - private Panel getOptionenPanel() { - if (iOptionenPanel == null) { - try { - iOptionenPanel = new Panel(); - iOptionenPanel.setName("OptionenPanel"); - iOptionenPanel.setLayout(new GridBagLayout()); - iOptionenPanel.setBackground(SystemColor.control); - - GridBagConstraints constraintsProjectLabel = new GridBagConstraints(); - constraintsProjectLabel.gridx = 0; constraintsProjectLabel.gridy = 0; - constraintsProjectLabel.anchor = GridBagConstraints.WEST; - constraintsProjectLabel.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getProjectLabel(), constraintsProjectLabel); - - GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints(); - constraintsBuildFileLabel.gridx = 0; constraintsBuildFileLabel.gridy = 1; - constraintsBuildFileLabel.anchor = GridBagConstraints.WEST; - constraintsBuildFileLabel.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getBuildFileLabel(), constraintsBuildFileLabel); - - GridBagConstraints constraintsTargetLabel = new GridBagConstraints(); - constraintsTargetLabel.gridx = 0; constraintsTargetLabel.gridy = 2; - constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST; - constraintsTargetLabel.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getTargetLabel(), constraintsTargetLabel); - - GridBagConstraints constraintsProjectText = new GridBagConstraints(); - constraintsProjectText.gridx = 1; constraintsProjectText.gridy = 0; - constraintsProjectText.gridwidth = 2; - constraintsProjectText.fill = GridBagConstraints.HORIZONTAL; - constraintsProjectText.anchor = GridBagConstraints.WEST; - constraintsProjectText.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getProjectText(), constraintsProjectText); - - GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints(); - constraintsBuildFileTextField.gridx = 1; constraintsBuildFileTextField.gridy = 1; - constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL; - constraintsBuildFileTextField.anchor = GridBagConstraints.WEST; - constraintsBuildFileTextField.weightx = 1.0; - constraintsBuildFileTextField.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getBuildFileTextField(), constraintsBuildFileTextField); - - GridBagConstraints constraintsBrowseButton = new GridBagConstraints(); - constraintsBrowseButton.gridx = 2; constraintsBrowseButton.gridy = 1; - constraintsBrowseButton.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getBrowseButton(), constraintsBrowseButton); - - GridBagConstraints constraintsTargetList = new GridBagConstraints(); - constraintsTargetList.gridx = 1; constraintsTargetList.gridy = 2; - constraintsTargetList.gridheight = 2; - constraintsTargetList.fill = GridBagConstraints.BOTH; - constraintsTargetList.weightx = 1.0; - constraintsTargetList.weighty = 1.0; - constraintsTargetList.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getTargetList(), constraintsTargetList); - - GridBagConstraints constraintsMessageOutputLevelLabel - = new GridBagConstraints(); - constraintsMessageOutputLevelLabel.gridx = 0; - constraintsMessageOutputLevelLabel.gridy = 4; - constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelLabel.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getMessageOutputLevelLabel(), - constraintsMessageOutputLevelLabel); - - GridBagConstraints constraintsMessageOutputLevelChoice - = new GridBagConstraints(); - constraintsMessageOutputLevelChoice.gridx = 1; - constraintsMessageOutputLevelChoice.gridy = 4; - constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL; - constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelChoice.weightx = 1.0; - constraintsMessageOutputLevelChoice.insets = new Insets(4, 4, 4, 4); - getOptionenPanel().add(getMessageOutputLevelChoice(), - constraintsMessageOutputLevelChoice); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iOptionenPanel; - } - /** - * Return the ProjectLabel property value. - * @return java.awt.Label - */ - private Label getProjectLabel() { - if (iProjectLabel == null) { - try { - iProjectLabel = new Label(); - iProjectLabel.setName("ProjectLabel"); - iProjectLabel.setText("Projectname:"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iProjectLabel; - } - /** - * Return the ProjectText property value. - * @return java.awt.Label - */ - private Label getProjectText() { - if (iProjectText == null) { - try { - iProjectText = new Label(); - iProjectText.setName("ProjectText"); - iProjectText.setText(" "); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iProjectText; - } - /** - * Return the ReloadButton property value. - * @return java.awt.Button - */ - private Button getReloadButton() { - if (iReloadButton == null) { - try { - iReloadButton = new Button(); - iReloadButton.setName("ReloadButton"); - iReloadButton.setLabel("(Re)Load"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iReloadButton; - } - /** - * Return the SaveMenuItem property value. - * @return java.awt.MenuItem - */ - private MenuItem getSaveMenuItem() { - if (iSaveMenuItem == null) { - try { - iSaveMenuItem = new MenuItem(); - iSaveMenuItem.setLabel("Save BuildInfo To Repository"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iSaveMenuItem; - } - /** - * Return the ShowLogMenuItem property value. - * @return java.awt.MenuItem - */ - private MenuItem getShowLogMenuItem() { - if (iShowLogMenuItem == null) { - try { - iShowLogMenuItem = new MenuItem(); - iShowLogMenuItem.setLabel("Log"); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iShowLogMenuItem; - } - /** - * Return the TargetLabel property value. - * @return java.awt.Label - */ - private Label getTargetLabel() { - if (iTargetLabel == null) { - try { - iTargetLabel = new Label(); - iTargetLabel.setName("TargetLabel"); - iTargetLabel.setText("Target:"); - iTargetLabel.setEnabled(true); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iTargetLabel; - } - /** - * Return the TargetList property value. - * @return java.awt.List - */ - private List getTargetList() { - if (iTargetList == null) { - try { - iTargetList = new List(); - iTargetList.setName("TargetList"); - iTargetList.setEnabled(true); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iTargetList; - } - /** - * Called whenever the part throws an exception. - * @param exception Throwable - */ - private void handleException(Throwable exception) { - // Write exceptions to the log-window - String trace = StringUtils.getStackTrace(exception); - - getMessageTextArea().append(lineSeparator + lineSeparator + trace); - getMessageFrame().show(); - - } - /** - * Initializes connections - * @exception Exception The exception description. - */ - private void initConnections() throws Exception { - this.addWindowListener(iEventHandler); - getBrowseButton().addActionListener(iEventHandler); - getCloseButton().addActionListener(iEventHandler); - getBuildButton().addActionListener(iEventHandler); - getStopButton().addActionListener(iEventHandler); - getSaveMenuItem().addActionListener(iEventHandler); - getAboutOkButton().addActionListener(iEventHandler); - getAboutMenuItem().addActionListener(iEventHandler); - getMessageOkButton().addActionListener(iEventHandler); - getMessageClearLogButton().addActionListener(iEventHandler); - getMessageOkButton().addActionListener(iEventHandler); - getShowLogMenuItem().addActionListener(iEventHandler); - getAboutDialog().addWindowListener(iEventHandler); - getMessageFrame().addWindowListener(iEventHandler); - getReloadButton().addActionListener(iEventHandler); - getTargetList().addItemListener(iEventHandler); - getMessageOutputLevelChoice().addItemListener(iEventHandler); - getBuildFileTextField().addTextListener(iEventHandler); - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - } - /** - * Initialize the class. - */ - private void initialize() { - try { - setName("AntMake"); - setMenuBar(getAntMakeMenuBar()); - setLayout(new java.awt.BorderLayout()); - setSize(389, 222); - setTitle("Ant VisualAge for Java Tool-Integration"); - add(getContentsPane(), "Center"); - initConnections(); - } catch (Throwable iExc) { - handleException(iExc); - } - setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - - (getSize().width / 2), - (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - - (getSize().height)); - if ((getTargetList().getItemCount() == 0) || (getTargetList().getSelectedIndex() < 0)) { - getBuildButton().setEnabled(false); - } - } - /** - * Saves the build-informations to repository - */ - private void saveBuildInfo() { - try { - VAJAntTool.saveBuildData(getBuildInfo()); - } catch (Throwable exc) { - // This Exception occurs when you try to write into a versioned project - handleException(exc); - } - return; - } - /** - * Set the BuildInfo to a new value. - * @param newValue org.apache.tools.ant.taskdefs.optional.vaj.VAJBuildInfo - */ - private void setBuildInfo(VAJBuildInfo newValue) { - if (iBuildInfo != newValue) { - try { - /* Stop listening for events from the current object */ - if (iBuildInfo != null) { - iBuildInfo.removePropertyChangeListener(iEventHandler); - } - iBuildInfo = newValue; - - /* Listen for events from the new object */ - if (iBuildInfo != null) { - iBuildInfo.addPropertyChangeListener(iEventHandler); - } - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - - // Select the log-level given by BuildInfo - getMessageOutputLevelChoice().select(iBuildInfo.getOutputMessageLevel()); - fillList(); - // BuildInfo can conly be saved to a VAJ project if tool API - // is called via the projects context-menu - if ((iBuildInfo.getVAJProjectName() == null) - || (iBuildInfo.getVAJProjectName().equals(""))) { - getSaveMenuItem().setEnabled(false); - } - } catch (Throwable iExc) { - handleException(iExc); - } - } - } - - private Button iStopButton = null; - - /** - * Return the StopButton property value. - * @return java.awt.Button - */ - private Button getStopButton() { - if (iStopButton == null) { - try { - iStopButton = new Button(); - iStopButton.setName("StopButton"); - iStopButton.setLabel("Stop"); - iStopButton.setEnabled(false); - } catch (Throwable iExc) { - handleException(iExc); - } - } - return iStopButton; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java deleted file mode 100644 index f8d08c17c..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java +++ /dev/null @@ -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(); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java deleted file mode 100644 index 00733377e..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java +++ /dev/null @@ -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: - *

    - * <vajexport destdir="C:/builddir/source"> - *  <include name="/MyVAProject/org/foo/subsystem1/**" /> - *  <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/> - * </vajexport> - *
    - * exports all packages in the project MyVAProject which start with - * 'org.foo.subsystem1' except of these starting with - * 'org.foo.subsystem1.test'. - * - *

    Parameters: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    AttributeDescriptionRequired
    destdirlocation to store the exported filesYes
    exportSourcesexport Java sources, defaults to "yes"No
    exportResourcesexport resource files, defaults to "yes"No
    exportClassesexport class files, defaults to "no"No
    exportDebugInfoinclude debug info in exported class files, - * defaults to "no"No
    defaultexcludesuse default excludes when exporting, - * defaults to "yes". - * Default excludes are: IBM/**, - * Java class libraries/**, Sun class libraries/**, - * JSP Page Compile Generated Code/**, Visual Age*/**No
    overwriteoverwrite existing files, defaults to "yes"No
    remoteremote tool server to run this command against - * (format: <servername> : <port no>)No
    haltonerrorstop the build process if an error occurs, - * defaults to "yes"No
    - * - */ - -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; - } - -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java deleted file mode 100644 index 63ffcfb5a..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java +++ /dev/null @@ -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. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    ParameterValuesDescription
    dirAny valid directory name on the server.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.

    - * Relative paths are relative to - * IBMVJava/ide/tools/com-ibm-ivj-toolserver, - * where IBMVJava is the VisualAge for Java installation - * directory.

    includeSee below.The pattern used to indicate which projects and - * packages to export.
    excludeSee belowThe pattern used to indicate which projects and - * packages not to export.
    cls"yes" or "no" (without the quotes)Export class files. Defaults to "no".
    src"yes" or "no" (without the quotes)Export source files. Defaults to "yes".
    res"yes" or "no" (without the quotes)Export resource files associated with the included project(s). - * Defaults to "yes".
    dex"yes" or "no" (without the quotes)Use the default exclusion patterns. Defaults to "yes". - * See below for an explanation of default excludes.
    owr"yes" or "no" (without the quotes)Overwrite any existing files. Defaults to "yes".
    - * - *

    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.

    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    Wildcard CharactersDescription
    *Match zero or more characters in that segment.
    ?Match one character in that segment.
    **Matches all characters in zero or more segments.
    - * - */ -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)); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java deleted file mode 100644 index 6dbf70566..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ /dev/null @@ -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. - *

    - * Example: - *

    - * <vajimport project="MyVAProject">
    - *   <fileset dir="src">
    - *     <include name="org/foo/subsystem1/**" />
    - *     <exclude name="/org/foo/subsystem1/test/**" />
    - *  </fileset>
    - * </vajexport>
    - * 
    - * 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. - *

    - *

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

    - *

    Parameters: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    AttributeDescriptionRequired
    projectthe name of the Project to import toYes
    importSourcesimport Java sources, defaults to "yes"No
    importResourcesimport resource files (anything that doesn't - * end with .java or .class), defaults to "yes"No
    importClassesimport class files, defaults to "no"No
    remoteremote tool server to run this command against - * (format: <servername> : <port no>)No
    haltonerrorstop the build process if an error occurs, - * defaults to "yes"No
    - * - */ -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); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java deleted file mode 100644 index 316b763c1..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java +++ /dev/null @@ -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. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    ParameterDescription
    projectThe name of the project where you want the imported - * items to go. - *
    dirThe directory you want to import from.
    - * - */ -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) - - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java deleted file mode 100644 index 28ab23734..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java +++ /dev/null @@ -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: - *

      - *
    • Any valid Visual Age version name
    • - *
    • * (loads the latest versioned edition)
    • - *
    • ** (loads the latest edition, including open editions)
    • - *
    - * Example: - *
    - * <vajload> - *  <project name="MyVAProject" version="*"/> - *  <project name="Apache Xerces" version="1.2.0"/> - *  <project name="Brand New Stuff" version="**"/> - * </vajload> - *
    - * - *

    Parameters:

    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    AttributeDescriptionRequired
    remoteremote tool server to run this command against - * (format: <servername> : <port no>)No
    haltonerrorstop the build process if an error occurs, - * defaults to "yes"No
    - *

    - * - */ - -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; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java deleted file mode 100644 index 43af22e53..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java +++ /dev/null @@ -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 { -} - - - - - - - - - - - - diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java deleted file mode 100644 index 78f72b68f..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java +++ /dev/null @@ -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. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    ParameterDescription
    projectThe name of the Project you want to load into - * the Workbench.
    versionThe version of the package you want to load into - * the Workbench.
    - * - */ -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); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java deleted file mode 100644 index 403980654..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java +++ /dev/null @@ -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); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java deleted file mode 100644 index 018e2ab7e..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java deleted file mode 100644 index 6c3df0f93..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java +++ /dev/null @@ -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 - * 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 - *
      - *
    • IBM*\**
    • - *
    • Java class libraries\**
    • - *
    • Sun class libraries*\**
    • - *
    • JSP Page Compile Generated Code\**
    • - *
    • VisualAge*\**
    • - *
    - *

    - * 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); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini b/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini deleted file mode 100644 index 1ccb8944f..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini +++ /dev/null @@ -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;