Browse Source

Too tightly coupled to ant1 to run in ant2 so zap them for now and come back to it later.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271235 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
fedc2287b5
38 changed files with 0 additions and 9978 deletions
  1. +0
    -115
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
  2. +0
    -1852
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
  3. +0
    -585
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
  4. +0
    -187
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
  5. +0
    -257
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java
  6. +0
    -269
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
  7. +0
    -78
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java
  8. +0
    -45
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java
  9. +0
    -25
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java
  10. +0
    -84
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java
  11. +0
    -27
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java
  12. +0
    -528
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java
  13. +0
    -71
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java
  14. +0
    -271
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java
  15. +0
    -59
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java
  16. +0
    -231
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java
  17. +0
    -80
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java
  18. +0
    -221
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java
  19. +0
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini
  20. +0
    -115
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
  21. +0
    -1852
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
  22. +0
    -585
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
  23. +0
    -187
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
  24. +0
    -257
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java
  25. +0
    -269
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
  26. +0
    -78
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java
  27. +0
    -45
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java
  28. +0
    -25
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java
  29. +0
    -84
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java
  30. +0
    -27
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java
  31. +0
    -528
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java
  32. +0
    -71
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java
  33. +0
    -271
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java
  34. +0
    -59
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java
  35. +0
    -231
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java
  36. +0
    -80
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java
  37. +0
    -221
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java
  38. +0
    -4
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/default.ini

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

@@ -1,115 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.myrmidon.api.TaskException;

/**
* 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
*
* @author RT
* @author: Wolf Siberski
*/
public class VAJAntTool
{
private final static 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
*
* @param projectName String project name
* @return BuildInfo buildInfo build info for the specified project
*/
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 TaskException( "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 TaskException( "BuildInfo for Project "
+ info.getVAJProjectName() + " could not be saved", t );
}
}
}

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


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

@@ -1,585 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
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
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

class VAJBuildInfo implements Runnable
{

// 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 ArrayList projectTargets = new ArrayList();

// target selected for execution
private java.lang.String target = "";

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

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

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

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

/**
* Creates a BuildInfo object from a String The String must be in the format
* outputMessageLevel'|'buildFileName'|'defaultTarget'|'(project target'|')*
*
* @param data java.lang.String
* @return org.apache.tools.ant.taskdefs.optional.vaj.BuildInfo
*/
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.add( tok.nextToken() );
}
}
catch( Throwable t )
{
// if parsing the info fails, just return
// an empty VAJBuildInfo
}
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
*
* @param names Description of Parameter
* @param name Description of Parameter
* @return Description of the Returned Value
*/
private static int findTargetPosition( ArrayList names, String name )
{
int res = names.size();
for( int i = 0; i < names.size() && res == names.size(); i++ )
{
if( name.compareTo( (String)names.get( i ) ) < 0 )
{
res = i;
}
}
return res;
}

/**
* Sets the build file name
*
* @param newBuildFileName The new BuildFileName value
*/
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 newOutputMessageLevel The new OutputMessageLevel value
*/
public void setOutputMessageLevel( int newOutputMessageLevel )
{
int oldValue = outputMessageLevel;
outputMessageLevel = newOutputMessageLevel;
firePropertyChange( "outputMessageLevel",
new Integer( oldValue ), new Integer( outputMessageLevel ) );
}

/**
* 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 newVAJProjectName The new VAJProjectName value
*/
public void setVAJProjectName( String newVAJProjectName )
{
String oldValue = vajProjectName;
vajProjectName = newVAJProjectName;
firePropertyChange( "VAJProjectName", oldValue, vajProjectName );
}

/**
* 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;
}

/**
* return a list of all targets in the current buildfile
*
* @return The ProjectTargets value
*/
public ArrayList getProjectTargets()
{
return projectTargets;
}

/**
* returns the selected target.
*
* @return The Target value
*/
public java.lang.String getTarget()
{
return target;
}

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

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

/**
* The addPropertyChangeListener method was generated to support the
* propertyChange field.
*
* @param listener The feature to be added to the PropertyChangeListener
* attribute
*/
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 java.lang.String
*/
public String asDataString()
{
String result = getOutputMessageLevel() + "|" + getBuildFileName()
+ "|" + getTarget();
for( Iterator e = getProjectTargets().iterator();
e.hasNext(); )
{
result = result + "|" + e.next();
}

return result;
}

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

/**
* Executes the target set by setTarget().
*
* @param logger Description of Parameter
*/
public void executeProject( BuildListener logger )
{
Throwable error;
projectLogger = logger;
try
{
buildThread = new Thread( this );
buildThread.setPriority( Thread.MIN_PRIORITY );
buildThread.start();
}
catch( RuntimeException exc )
{
error = exc;
throw exc;
}
catch( Error err )
{
error = err;
throw err;
}
}

/**
* The firePropertyChange method was generated to support the propertyChange
* field.
*
* @param propertyName Description of Parameter
* @param oldValue Description of Parameter
* @param newValue Description of Parameter
*/
public void firePropertyChange( java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue )
{
getPropertyChange().firePropertyChange( propertyName, oldValue, newValue );
}

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

/**
* 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();
}
}

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

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

/**
* 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
*
* @param initialized The new ProjectInitialized value
*/
private void setProjectInitialized( boolean initialized )
{
Boolean oldValue = new Boolean( projectInitialized );
projectInitialized = initialized;
firePropertyChange( "projectInitialized", oldValue, new Boolean( projectInitialized ) );
}

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

/**
* 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() );

//FIXME: Need to convert to Myrmidon style
//ProjectHelper.configureProject( project, buildFile );
setProjectInitialized( true );
}
catch( RuntimeException exc )
{
setProjectInitialized( false );
throw exc;
}
catch( Error err )
{
setProjectInitialized( false );
throw err;
}
}

/**
* This exception is thrown when a build is interrupted
*
* @author RT
*/
public static class BuildInterruptedException extends TaskException
{
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.
*
* @author RT
*/
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;
}

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

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

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

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

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

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

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

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

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

@@ -1,187 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Pattern;
import org.apache.myrmidon.framework.PatternSet;
import org.apache.myrmidon.framework.PatternUtil;

/**
* Export packages from the Visual Age for Java workspace. The packages are
* specified similar to all other MatchingTasks. Since the VA Workspace is not
* file based, this task is simulating a directory hierarchy for the workspace:
* The 'root' contains all project 'dir's, and the projects contain their
* respective package 'dir's. Example: <blockquote> &lt;vajexport
* destdir="C:/builddir/source"> &nbsp;&lt;include
* name="/MyVAProject/org/foo/subsystem1/**" /> &nbsp;&lt;exclude
* name="/MyVAProject/org/foo/subsystem1/test/**"/> &lt;/vajexport>
* </blockquote> exports all packages in the project MyVAProject which start
* with 'org.foo.subsystem1' except of these starting with
* 'org.foo.subsystem1.test'. There are flags to choose which items to export:
* exportSources: export Java sources exportResources: export project resources
* exportClasses: export class files exportDebugInfo: export class files with
* debug info (use with exportClasses) default is exporting Java files and
* resources.
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

public class VAJExport extends VAJTask
{
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();
//set set... method comments for description
protected File destDir;

/**
* 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;
}

/**
* Set the destination directory into which the selected items should be
* exported
*
* @param destDir The new Destdir value
*/
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 );
}

/**
* if exportClasses is set, class files are exported
*
* @param doExport The new ExportClasses value
*/
public void setExportClasses( boolean doExport )
{
exportClasses = doExport;
}

/**
* if exportDebugInfo is set, the exported class files contain debug info
*
* @param doExport The new ExportDebugInfo value
*/
public void setExportDebugInfo( boolean doExport )
{
exportDebugInfo = doExport;
}

/**
* if exportResources is set, resource file will be exported
*
* @param doExport The new ExportResources value
*/
public void setExportResources( boolean doExport )
{
exportResources = doExport;
}

/**
* if exportSources is set, java files will be exported
*
* @param doExport The new ExportSources value
*/
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
*
* @param doOverwrite The new Overwrite value
*/
public void setOverwrite( boolean doOverwrite )
{
overwrite = doOverwrite;
}

/**
* add a name entry on the exclude list
*
* @return Description of the Returned Value
*/
public void addExclude( final Pattern pattern )
{
patternSet.addExclude( pattern );
}

/**
* add a name entry on the include list
*/
public void addInclude( final Pattern pattern )
{
patternSet.addInclude( pattern );
}

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

// delegate the export to the VAJUtil object.
final TaskContext context = getContext();
final TaskContext context1 = getContext();
getUtil().exportPackages( destDir,
PatternUtil.getIncludePatterns( patternSet, context ),
PatternUtil.getExcludePatterns( patternSet, context1 ),
exportClasses, exportDebugInfo,
exportResources, exportSources,
useDefaultExcludes, overwrite );
}

}

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

@@ -1,257 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.
* <tableborder="1">
*
* <tr>
*
* <td>
* <strong>Parameter</strong>
* </td>
*
* <td>
* <strong>Values</strong>
* </td>
*
* <td>
* <strong>Description</strong>
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* dir
* </td>
*
* <td>
* Any valid directory name on the server.
* </td>
*
* <td>
* The directory to export the files to on the machine where the servlet
* is being run. If the directory doesn't exist, it will be created.<p>
*
* Relative paths are relative to IBMVJava/ide/tools/com-ibm-ivj-toolserver,
* where IBMVJava is the VisualAge for Java installation directory.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* include
* </td>
*
* <td>
* See below.
* </td>
*
* <td>
* The pattern used to indicate which projects and packages to export.
*
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* exclude
* </td>
*
* <td>
* See below
* </td>
*
* <td>
* The pattern used to indicate which projects and packages <em>not</em>
* to export.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* cls
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export class files. Defaults to "no".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* src
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export source files. Defaults to "yes".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* res
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export resource files associated with the included project(s). Defaults
* to "yes".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* dex
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Use the default exclusion patterns. Defaults to "yes". See below for an
* explanation of default excludes.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* owr
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Overwrite any existing files. Defaults to "yes".
* </td>
*
* </tr>
*
* </table>
* <p>
*
* The vajexport servlet uses include and exclude parameters to form the
* criteria for selecting packages to export. The parameter is broken up into
* ProjectName/packageNameSegments, where ProjectName is what you expect, and
* packageNameSegments is a partial (or complete) package name, separated by
* forward slashes, rather than periods. Each packageNameSegment can have
* wildcard characters.</p>
* <tableborder="1">
*
* <tr>
*
* <td>
* <strong>Wildcard Characters</strong>
* </td>
*
* <td>
* <strong>Description</strong>
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* *
* </td>
*
* <td>
* Match zero or more characters in that segment.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* ?
* </td>
*
* <td>
* Match one character in that segment.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* **
* </td>
*
* <td>
* Matches all characters in zero or more segments.
* </td>
*
* </tr>
*
* </table>
*
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public class VAJExportServlet extends VAJToolsServlet
{
// constants for servlet param names
public final static String WITH_DEBUG_INFO = "deb";
public final static String OVERWRITE_PARAM = "owr";

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

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

@@ -1,269 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.ScannerUtil;

/**
* Import source, class files, and resources to the Visual Age for Java
* workspace using FileSets. <p>
*
* Example: <pre>
* &lt;vajimport project="MyVAProject"&gt;
* &lt;fileset dir="src"&gt;
* &lt;include name="org/foo/subsystem1/**" /&gt;
* &lt;exclude name="/org/foo/subsystem1/test/**" /&gt;
* &lt;/fileset&gt;
* &lt;/vajexport&gt;
* </pre> import all source and resource files from the "src" directory which
* start with 'org.foo.subsystem1', except of these starting with
* 'org.foo.subsystem1.test' into the project MyVAProject. </p> <p>
*
* If MyVAProject isn't loaded into the Workspace, a new edition is created in
* the repository and automatically loaded into the Workspace. There has to be
* at least one nested FileSet element. </p> <p>
*
* There are attributes to choose which items to export:
* <tableborder="1" cellpadding="2" cellspacing="0">
*
* <tr>
*
* <tdvalign="top">
* <b>Attribute</b>
* </td>
*
* <tdvalign="top">
* <b>Description</b>
* </td>
*
* <tdalign="center" valign="top">
* <b>Required</b>
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* project
* </td>
*
* <tdvalign="top">
* the name of the Project to import to
* </td>
*
* <tdalign="center" valign="top">
* Yes
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importSources
* </td>
*
* <tdvalign="top">
* import Java sources, defaults to "yes"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importResources
* </td>
*
* <tdvalign="top">
* import resource files (anything that doesn't end with .java or .class),
* defaults to "yes"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importClasses
* </td>
*
* <tdvalign="top">
* import class files, defaults to "no"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* </table>
*
*
* @author RT
* @author: Glenn McAllister, inspired by a similar task written by Peter Kelley
*/
public class VAJImport extends VAJTask
{
protected ArrayList filesets = new ArrayList();
protected boolean importSources = true;
protected boolean importResources = true;
protected boolean importClasses = false;
protected String importProject = null;
protected boolean useDefaultExcludes = true;

/**
* 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;
}

/**
* Import .class files.
*
* @param importClasses The new ImportClasses value
*/
public void setImportClasses( boolean importClasses )
{
this.importClasses = importClasses;
}

/**
* Import resource files (anything that doesn't end in .class or .java)
*
* @param importResources The new ImportResources value
*/
public void setImportResources( boolean importResources )
{
this.importResources = importResources;
}

/**
* Import .java files
*
* @param importSources The new ImportSources value
*/
public void setImportSources( boolean importSources )
{
this.importSources = importSources;
}

/**
* The VisualAge for Java Project name to import into.
*
* @param projectName The new Project value
*/
public void setProject( String projectName )
{
this.importProject = projectName;
}

/**
* Adds a set of files (nested fileset attribute).
*
* @param set The feature to be added to the Fileset attribute
*/
public void addFileset( FileSet set )
{
filesets.add( set );
}

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

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

for( Iterator e = filesets.iterator(); e.hasNext(); )
{
importFileset( (FileSet)e.next() );
}
}

/**
* Import all files from the fileset into the Project in the Workspace.
*
* @param fileset Description of Parameter
*/
protected void importFileset( FileSet fileset )
{
DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fileset );
if( ds.getIncludedFiles().length == 0 )
{
return;
}

String[] includes = null;
String[] excludes = null;

// Hack to get includes and excludes. We could also use getIncludedFiles,
// but that would result in very long HTTP-requests.
// Therefore we want to send the patterns only to the remote tool server
// and let him figure out the files.
try
{
Class directoryScanner = ds.getClass();

Field includesField = directoryScanner.getDeclaredField( "includes" );
includesField.setAccessible( true );
includes = (String[])includesField.get( ds );

Field excludesField = directoryScanner.getDeclaredField( "excludes" );
excludesField.setAccessible( true );
excludes = (String[])excludesField.get( ds );
}
catch( NoSuchFieldException nsfe )
{
throw new TaskException(
"DirectoryScanner.includes or .excludes missing" + nsfe.getMessage() );
}
catch( IllegalAccessException iae )
{
throw new TaskException(
"Access to DirectoryScanner.includes or .excludes not allowed" );
}

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

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

@@ -1,78 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;

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

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

@@ -1,45 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.ArrayList;

/**
* Load specific project versions into the Visual Age for Java workspace. Each
* project and version name has to be specified completely. Example:
* <blockquote> &lt;vajload> &nbsp;&lt;project name="MyVAProject"
* version="2.1"/> &nbsp;&lt;project name="Apache Xerces" version="1.2.0"/>
* &lt;/vajload> </blockquote>
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

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

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

/**
* Load specified projects.
*/
public void execute()
{
getUtil().loadProjects( projectDescriptions );
}
}

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

@@ -1,25 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

public class VAJLoadProjects extends VAJLoad
{
}







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

@@ -1,84 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.ArrayList;

/**
* A Remote Access to Tools Servlet to load a Project from the Repository into
* the Workbench. The following table describes the servlet parameters.
* <table>
*
* <tr>
*
* <td>
* Parameter
* </td>
*
* <td>
* Description
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* project
* </td>
*
* <td>
* The name of the Project you want to load into the Workbench.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* version
* </td>
*
* <td>
* The version of the package you want to load into the Workbench.
* </td>
*
* </tr>
*
* </table>
*
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public class VAJLoadServlet extends VAJToolsServlet
{

// constants for servlet param names
public final static 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 );

ArrayList projectDescriptions = new ArrayList( 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.add( desc );
}

util.loadProjects( projectDescriptions );
}
}

+ 0
- 27
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

/**
* Adaption of VAJLocalUtil to Task context.
*/
class VAJLocalToolUtil
extends VAJLocalUtil
{
private VAJTask m_task;

public VAJLocalToolUtil( final VAJTask task )
{
m_task = task;
}

public void log( final String msg, final int level )
{
m_task.log( msg, level );
}
}

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

@@ -1,528 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.DirectoryScanner;

/**
* Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions
* into TaskExceptions
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
abstract class VAJLocalUtil
implements VAJUtil
{
// singleton containing the VAJ workspace
private static Workspace workspace;

/**
* get a project from the Workspace.
*
* @param importProject Description of Parameter
* @return The VAJProject value
*/
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 createTaskException( "Error while creating Project "
+ importProject + ": ", e );
}
}

return found;
}

/**
* 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 TaskException(
"Unable to connect to Workspace! "
+ "Make sure you are running in VisualAge for Java." );
}
}

return workspace;
}

/**
* Wraps IvjException into a TaskException
*
* @param errMsg Additional error message
* @param e IvjException which is wrapped
* @return org.apache.tools.ant.TaskException
*/
static TaskException createTaskException(
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 TaskException( errMsg, e );
}


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

/**
* export packages
*
* @param dest Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param exportClasses Description of Parameter
* @param exportDebugInfo Description of Parameter
* @param exportResources Description of Parameter
* @param exportSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @param overwrite Description of Parameter
*/
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++ )
{
getLogger().debug( " " + packages[ i ].getName() );
}

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 createTaskException( "Exporting failed!", ex );
}
}
}


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


/**
* Do the import.
*
* @param importProject Description of Parameter
* @param srcDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param importClasses Description of Parameter
* @param importResources Description of Parameter
* @param importSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @exception TaskException Description of Exception
*/
public void importFiles(
String importProject, File srcDir,
String[] includePatterns, String[] excludePatterns,
boolean importClasses, boolean importResources,
boolean importSources, boolean useDefaultExcludes )
throws TaskException
{

if( importProject == null || "".equals( importProject ) )
{
throw new TaskException( "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();

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

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( "'." );

getLogger().info( summaryLog.toString() );

try
{
Type[] importedTypes = getWorkspace().importData( importSpec );
if( importedTypes == null )
{
throw new TaskException( "Unable to import into Workspace!" );
}
else
{
getLogger().debug( importedTypes.length + " types imported" );
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 createTaskException( "Error while importing into workspace: ",
ivje );
}
}


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

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
public void loadProjects( ArrayList projectDescriptions )
{
ArrayList expandedDescs = getExpandedDescriptions( projectDescriptions );

// output warnings for projects not found
for( Iterator e = projectDescriptions.iterator(); e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();
if( !d.projectFound() )
{
getLogger().warn( "No Projects match the name " + d.getName() );
}
}

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

for( Iterator e = expandedDescs.iterator();
e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();

ProjectEdition pe = findProjectEdition( d.getName(), d.getVersion() );
try
{
log( "Loading '" + d.getName() + "', Version '" + d.getVersion()
+ "', into Workspace", MSG_VERBOSE );
pe.loadIntoWorkspace();
}
catch( IvjException ex )
{
throw createTaskException( "Project '" + d.getName()
+ "' could not be loaded.", ex );
}
}
}

/**
* return project descriptions containing full project names instead of
* patterns with wildcards.
*
* @param projectDescs Description of Parameter
* @return The ExpandedDescriptions value
*/
private ArrayList getExpandedDescriptions( ArrayList projectDescs )
{
ArrayList expandedDescs = new ArrayList( projectDescs.size() );
try
{
String[] projectNames =
getWorkspace().getRepository().getProjectNames();
for( int i = 0; i < projectNames.length; i++ )
{
for( Iterator e = projectDescs.iterator();
e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();
String pattern = d.getName();
if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) )
{
d.setProjectFound();
expandedDescs.add( new VAJProjectDescription(
projectNames[ i ], d.getVersion() ) );
break;
}
}
}
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

return expandedDescs;
}

/**
* 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,
ArrayList 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 TaskException( "Error", e );
}
if( files.size() > 0 )
{
logFiles( files, fileType );
summaryLog.append( files.size() );
summaryLog.append( " " + fileType.toLowerCase() + " file" );
summaryLog.append( files.size() > 1 ? "s, " : ", " );
}
}
}

/**
* returns a list of project names matching the given pattern
*
* @param pattern Description of Parameter
* @return Description of the Returned Value
*/
private ArrayList findMatchingProjects( String pattern )
{
String[] projectNames;
try
{
projectNames = getWorkspace().getRepository().getProjectNames();
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

ArrayList matchingProjects = new ArrayList();
for( int i = 0; i < projectNames.length; i++ )
{
if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) )
{
matchingProjects.add( projectNames[ i ] );
}
}

return matchingProjects;
}

/**
* 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 TaskException( "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 TaskException( "Version " + versionName
+ " of Project " + name + " doesn't exist" );
}
return pe;
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

}

/**
* Logs a list of file names to the message log
*
* @param fileNames java.util.ArrayList file names to be logged
* @param fileType Description of Parameter
*/
private void logFiles( ArrayList fileNames, String fileType )
{
getLogger().debug( fileType + " files found for import:" );
for( Iterator e = fileNames.iterator(); e.hasNext(); )
{
getLogger().debug( " " + e.next() );
}
}

/**
* Sort the files into classes, sources, and resources.
*
* @param dir Description of Parameter
* @param files Description of Parameter
* @param classes Description of Parameter
* @param sources Description of Parameter
* @param resources Description of Parameter
*/
private void scanForImport(
File dir,
String[] files,
ArrayList classes,
ArrayList sources,
ArrayList 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.add( file );
}
else if( file.endsWith( ".class" ) || file.endsWith( ".CLASS" ) )
{
classes.add( file );
}
else
{
// for resources VA expects the path relative to the resource path
resources.add( files[ i ] );
}
}
}
}

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

@@ -1,71 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import org.apache.myrmidon.api.TaskException;

/**
* Type class. Holds information about a project edition.
*
* @author RT
* @author: Wolf Siberski
*/
public class VAJProjectDescription
{
private String name;
private boolean projectFound;
private String version;

public VAJProjectDescription()
{
}

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

public void setName( String newName )
{
if( newName == null || newName.equals( "" ) )
{
throw new TaskException( "name attribute must be set" );
}
name = newName;
}

public void setProjectFound()
{
projectFound = true;
}

public void setVersion( String newVersion )
{
if( newVersion == null || newVersion.equals( "" ) )
{
throw new TaskException( "version attribute must be set" );
}
version = newVersion;
}

public String getName()
{
return name;
}

public String getVersion()
{
return version;
}

public boolean projectFound()
{
return projectFound;
}
}

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

@@ -1,271 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
* Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions
* into TaskExceptions
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
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
*
* @param destDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param exportClasses Description of Parameter
* @param exportDebugInfo Description of Parameter
* @param exportResources Description of Parameter
* @param exportSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @param overwrite Description of Parameter
*/
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?"
+ VAJExportServlet.WITH_DEBUG_INFO + "=" + exportDebugInfo + "&"
+ VAJExportServlet.OVERWRITE_PARAM + "=" + overwrite + "&"
+ assembleImportExportParams( destDir,
includePatterns, excludePatterns,
exportClasses, exportResources,
exportSources, useDefaultExcludes );
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}
}

/**
* Do the import.
*
* @param importProject Description of Parameter
* @param srcDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param importClasses Description of Parameter
* @param importResources Description of Parameter
* @param importSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
*/
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?"
+ VAJImportServlet.PROJECT_NAME_PARAM + "="
+ importProject + "&"
+ assembleImportExportParams( srcDir,
includePatterns, excludePatterns,
importClasses, importResources,
importSources, useDefaultExcludes );
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}

}

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
public void loadProjects( ArrayList projectDescriptions )
{
try
{
String request = "http://" + remoteServer + "/servlet/vajload?";
String delimiter = "";
for( Iterator e = projectDescriptions.iterator(); e.hasNext(); )
{
VAJProjectDescription pd = (VAJProjectDescription)e.next();
request = request
+ delimiter + VAJLoadServlet.PROJECT_NAME_PARAM
+ "=" + pd.getName().replace( ' ', '+' )
+ "&" + VAJLoadServlet.VERSION_PARAM
+ "=" + pd.getVersion().replace( ' ', '+' );
//the first param needs no delimiter, but all other
delimiter = "&";
}
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}
}

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

/**
* Assemble string for parameters common for import and export Helper method
* to remove double code.
*
* @param dir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param includeClasses Description of Parameter
* @param includeResources Description of Parameter
* @param includeSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @return Description of the Returned Value
*/
private String assembleImportExportParams(
File dir,
String[] includePatterns, String[] excludePatterns,
boolean includeClasses, boolean includeResources,
boolean includeSources, boolean useDefaultExcludes )
{
String result =
VAJToolsServlet.DIR_PARAM + "="
+ dir.getAbsolutePath().replace( '\\', '/' ) + "&"
+ VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&"
+ VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&"
+ VAJToolsServlet.SOURCES_PARAM + "=" + includeSources + "&"
+ VAJToolsServlet.DEFAULT_EXCLUDES_PARAM + "=" + useDefaultExcludes;

if( includePatterns != null )
{
for( int i = 0; i < includePatterns.length; i++ )
{
result = result + "&" + VAJExportServlet.INCLUDE_PARAM + "="
+ includePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' );
}
}
if( excludePatterns != null )
{
for( int i = 0; i < excludePatterns.length; i++ )
{
result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "="
+ excludePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' );
}
}

return result;
}

/**
* Sends a servlet request.
*
* @param request Description of Parameter
*/
private void sendRequest( String request )
{
boolean requestFailed = false;
try
{
getLogger().debug( "Request: " + request );

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

InputStream is = null;
// retry three times
for( int i = 0; i < 3; i++ )
{
try
{
is = connection.getInputStream();
break;
}
catch( IOException ex )
{
}
}
if( is == null )
{
getLogger().error( "Can't get " + request );
throw new TaskException( "Couldn't execute " + request );
}

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

}
catch( IOException ex )
{
getLogger().error( "Error sending tool request to VAJ" + ex );
throw new TaskException( "Couldn't execute " + request );
}
if( requestFailed )
{
throw new TaskException( "VAJ tool request failed" );
}
}
}

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

@@ -1,59 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

/**
* Super class for all VAJ tasks. Contains common attributes (remoteServer) and
* util methods
*
* @author: Wolf Siberski
*/

import org.apache.tools.ant.Task;

public class VAJTask extends Task
{

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

// holds the appropriate VAJUtil implementation
private VAJUtil util = null;

/**
* Set remote server attribute
*
* @param remoteServer The new Remote value
*/
public void setRemote( String remoteServer )
{
this.remoteServer = remoteServer;
}

/**
* returns the VAJUtil implementation
*
* @return The Util value
*/
protected VAJUtil getUtil()
{
if( util == null )
{
if( remoteServer == null )
{
util = new VAJLocalToolUtil( this );
}
else
{
util = new VAJRemoteUtil( this, remoteServer );
}
}
return util;
}

}

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

@@ -1,231 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.myrmidon.api.TaskException;

/**
* Abstract base class to provide common services for the VAJ tool API servlets
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public abstract class VAJToolsServlet
extends HttpServlet
{
// constants for servlet param names
public final static String DIR_PARAM = "dir";
public final static String INCLUDE_PARAM = "include";
public final static String EXCLUDE_PARAM = "exclude";
public final static String CLASSES_PARAM = "cls";
public final static String SOURCES_PARAM = "src";
public final static String RESOURCES_PARAM = "res";
public final static String DEFAULT_EXCLUDES_PARAM = "dex";
public final static String PROJECT_NAME_PARAM = "project";

// current request
HttpServletRequest request;

// response to current request
HttpServletResponse response;

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

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

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

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

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

/**
* Returns all values for a parameter.
*
* @param param Description of Parameter
* @return The ParamValues value
*/
protected String[] getParamValues( String param )
{
return request.getParameterValues( param );
}

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

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

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

/**
* Get the VAJUtil implementation
*
* @return The Util value
*/
VAJUtil getUtil()
{
return util;
}

/**
* Adaptation of VAJUtil for servlet context.
*/
class VAJLocalServletUtil
extends VAJLocalUtil
{
public void log( String msg, int level )
{
try
{
if( msg != null )
{
msg = msg.replace( '\r', ' ' );
int i = 0;
while( i < msg.length() )
{
int nlPos = msg.indexOf( '\n', i );
if( nlPos == -1 )
{
nlPos = msg.length();
}
response.getWriter().println( Integer.toString( level )
+ " " + msg.substring( i, nlPos ) );
i = nlPos + 1;
}
}
}
catch( IOException e )
{
throw new TaskException( "logging failed. msg was: "
+ e.getMessage() );
}
}
}
}

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

@@ -1,80 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;
import java.util.ArrayList;

/**
* Helper interface for VAJ tasks. Encapsulates the interface to the VAJ tool
* API.
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
interface VAJUtil
{
// log levels
public final static int MSG_DEBUG = 4;
public final static int MSG_ERR = 0;
public final static int MSG_INFO = 2;
public final static int MSG_VERBOSE = 3;
public final static int MSG_WARN = 1;

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

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

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
void loadProjects( ArrayList projectDescriptions );

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

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

@@ -1,221 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import com.ibm.ivj.util.base.IvjException;
import com.ibm.ivj.util.base.Package;
import com.ibm.ivj.util.base.Project;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.ScannerUtil;

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

// Patterns that should be excluded by default.
private final static 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 ArrayList packagesIncluded = new ArrayList();

/**
* Matches a string against a pattern. The pattern contains two special
* characters: '*' which means zero or more characters, '?' which means one
* and only one character.
*
* @param pattern the (non-null) pattern to match against
* @param str the (non-null) string that must be matched against the pattern
* @return <code>true</code> when the string matches against the pattern,
* <code>false</code> otherwise.
*/
protected static boolean match( String pattern, String str )
{
return ScannerUtil.match( pattern, str );
}

/**
* 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.get( i );
}
return packages;
}

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

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

ArrayList matchingProjects = new ArrayList();

boolean allProjectsMatch = false;
for( int i = 0; i < projects.length; i++ )
{
Project project = projects[ i ];
for( int j = 0; j < getIncludes().length && !allProjectsMatch; j++ )
{
StringTokenizer tok =
new StringTokenizer( getIncludes()[ 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.add( project );
break;
}
}
}

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

return matchingProjects;
}

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

// only scan projects which are included in at least one include pattern
ArrayList matchingProjects = findMatchingProjects();
for( Iterator e = matchingProjects.iterator(); e.hasNext(); )
{
Project project = (Project)e.next();
scanProject( project );
}
}

/**
* Scans a project for packages that match at least one include pattern, and
* don't match any exclude patterns.
*
* @param project Description of Parameter
*/
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.add( item );
}
}
}
}
catch( IvjException e )
{
throw VAJLocalUtil.createTaskException( "VA Exception occured: ", e );
}
}
}

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

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

+ 0
- 115
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java View File

@@ -1,115 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.myrmidon.api.TaskException;

/**
* 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
*
* @author RT
* @author: Wolf Siberski
*/
public class VAJAntTool
{
private final static 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
*
* @param projectName String project name
* @return BuildInfo buildInfo build info for the specified project
*/
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 TaskException( "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 TaskException( "BuildInfo for Project "
+ info.getVAJProjectName() + " could not be saved", t );
}
}
}

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


+ 0
- 585
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java View File

@@ -1,585 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
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
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

class VAJBuildInfo implements Runnable
{

// 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 ArrayList projectTargets = new ArrayList();

// target selected for execution
private java.lang.String target = "";

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

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

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

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

/**
* Creates a BuildInfo object from a String The String must be in the format
* outputMessageLevel'|'buildFileName'|'defaultTarget'|'(project target'|')*
*
* @param data java.lang.String
* @return org.apache.tools.ant.taskdefs.optional.vaj.BuildInfo
*/
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.add( tok.nextToken() );
}
}
catch( Throwable t )
{
// if parsing the info fails, just return
// an empty VAJBuildInfo
}
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
*
* @param names Description of Parameter
* @param name Description of Parameter
* @return Description of the Returned Value
*/
private static int findTargetPosition( ArrayList names, String name )
{
int res = names.size();
for( int i = 0; i < names.size() && res == names.size(); i++ )
{
if( name.compareTo( (String)names.get( i ) ) < 0 )
{
res = i;
}
}
return res;
}

/**
* Sets the build file name
*
* @param newBuildFileName The new BuildFileName value
*/
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 newOutputMessageLevel The new OutputMessageLevel value
*/
public void setOutputMessageLevel( int newOutputMessageLevel )
{
int oldValue = outputMessageLevel;
outputMessageLevel = newOutputMessageLevel;
firePropertyChange( "outputMessageLevel",
new Integer( oldValue ), new Integer( outputMessageLevel ) );
}

/**
* 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 newVAJProjectName The new VAJProjectName value
*/
public void setVAJProjectName( String newVAJProjectName )
{
String oldValue = vajProjectName;
vajProjectName = newVAJProjectName;
firePropertyChange( "VAJProjectName", oldValue, vajProjectName );
}

/**
* 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;
}

/**
* return a list of all targets in the current buildfile
*
* @return The ProjectTargets value
*/
public ArrayList getProjectTargets()
{
return projectTargets;
}

/**
* returns the selected target.
*
* @return The Target value
*/
public java.lang.String getTarget()
{
return target;
}

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

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

/**
* The addPropertyChangeListener method was generated to support the
* propertyChange field.
*
* @param listener The feature to be added to the PropertyChangeListener
* attribute
*/
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 java.lang.String
*/
public String asDataString()
{
String result = getOutputMessageLevel() + "|" + getBuildFileName()
+ "|" + getTarget();
for( Iterator e = getProjectTargets().iterator();
e.hasNext(); )
{
result = result + "|" + e.next();
}

return result;
}

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

/**
* Executes the target set by setTarget().
*
* @param logger Description of Parameter
*/
public void executeProject( BuildListener logger )
{
Throwable error;
projectLogger = logger;
try
{
buildThread = new Thread( this );
buildThread.setPriority( Thread.MIN_PRIORITY );
buildThread.start();
}
catch( RuntimeException exc )
{
error = exc;
throw exc;
}
catch( Error err )
{
error = err;
throw err;
}
}

/**
* The firePropertyChange method was generated to support the propertyChange
* field.
*
* @param propertyName Description of Parameter
* @param oldValue Description of Parameter
* @param newValue Description of Parameter
*/
public void firePropertyChange( java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue )
{
getPropertyChange().firePropertyChange( propertyName, oldValue, newValue );
}

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

/**
* 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();
}
}

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

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

/**
* 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
*
* @param initialized The new ProjectInitialized value
*/
private void setProjectInitialized( boolean initialized )
{
Boolean oldValue = new Boolean( projectInitialized );
projectInitialized = initialized;
firePropertyChange( "projectInitialized", oldValue, new Boolean( projectInitialized ) );
}

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

/**
* 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() );

//FIXME: Need to convert to Myrmidon style
//ProjectHelper.configureProject( project, buildFile );
setProjectInitialized( true );
}
catch( RuntimeException exc )
{
setProjectInitialized( false );
throw exc;
}
catch( Error err )
{
setProjectInitialized( false );
throw err;
}
}

/**
* This exception is thrown when a build is interrupted
*
* @author RT
*/
public static class BuildInterruptedException extends TaskException
{
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.
*
* @author RT
*/
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;
}

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

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

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

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

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

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

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

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

+ 0
- 187
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java View File

@@ -1,187 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Pattern;
import org.apache.myrmidon.framework.PatternSet;
import org.apache.myrmidon.framework.PatternUtil;

/**
* Export packages from the Visual Age for Java workspace. The packages are
* specified similar to all other MatchingTasks. Since the VA Workspace is not
* file based, this task is simulating a directory hierarchy for the workspace:
* The 'root' contains all project 'dir's, and the projects contain their
* respective package 'dir's. Example: <blockquote> &lt;vajexport
* destdir="C:/builddir/source"> &nbsp;&lt;include
* name="/MyVAProject/org/foo/subsystem1/**" /> &nbsp;&lt;exclude
* name="/MyVAProject/org/foo/subsystem1/test/**"/> &lt;/vajexport>
* </blockquote> exports all packages in the project MyVAProject which start
* with 'org.foo.subsystem1' except of these starting with
* 'org.foo.subsystem1.test'. There are flags to choose which items to export:
* exportSources: export Java sources exportResources: export project resources
* exportClasses: export class files exportDebugInfo: export class files with
* debug info (use with exportClasses) default is exporting Java files and
* resources.
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

public class VAJExport extends VAJTask
{
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();
//set set... method comments for description
protected File destDir;

/**
* 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;
}

/**
* Set the destination directory into which the selected items should be
* exported
*
* @param destDir The new Destdir value
*/
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 );
}

/**
* if exportClasses is set, class files are exported
*
* @param doExport The new ExportClasses value
*/
public void setExportClasses( boolean doExport )
{
exportClasses = doExport;
}

/**
* if exportDebugInfo is set, the exported class files contain debug info
*
* @param doExport The new ExportDebugInfo value
*/
public void setExportDebugInfo( boolean doExport )
{
exportDebugInfo = doExport;
}

/**
* if exportResources is set, resource file will be exported
*
* @param doExport The new ExportResources value
*/
public void setExportResources( boolean doExport )
{
exportResources = doExport;
}

/**
* if exportSources is set, java files will be exported
*
* @param doExport The new ExportSources value
*/
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
*
* @param doOverwrite The new Overwrite value
*/
public void setOverwrite( boolean doOverwrite )
{
overwrite = doOverwrite;
}

/**
* add a name entry on the exclude list
*
* @return Description of the Returned Value
*/
public void addExclude( final Pattern pattern )
{
patternSet.addExclude( pattern );
}

/**
* add a name entry on the include list
*/
public void addInclude( final Pattern pattern )
{
patternSet.addInclude( pattern );
}

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

// delegate the export to the VAJUtil object.
final TaskContext context = getContext();
final TaskContext context1 = getContext();
getUtil().exportPackages( destDir,
PatternUtil.getIncludePatterns( patternSet, context ),
PatternUtil.getExcludePatterns( patternSet, context1 ),
exportClasses, exportDebugInfo,
exportResources, exportSources,
useDefaultExcludes, overwrite );
}

}

+ 0
- 257
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java View File

@@ -1,257 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.
* <tableborder="1">
*
* <tr>
*
* <td>
* <strong>Parameter</strong>
* </td>
*
* <td>
* <strong>Values</strong>
* </td>
*
* <td>
* <strong>Description</strong>
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* dir
* </td>
*
* <td>
* Any valid directory name on the server.
* </td>
*
* <td>
* The directory to export the files to on the machine where the servlet
* is being run. If the directory doesn't exist, it will be created.<p>
*
* Relative paths are relative to IBMVJava/ide/tools/com-ibm-ivj-toolserver,
* where IBMVJava is the VisualAge for Java installation directory.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* include
* </td>
*
* <td>
* See below.
* </td>
*
* <td>
* The pattern used to indicate which projects and packages to export.
*
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* exclude
* </td>
*
* <td>
* See below
* </td>
*
* <td>
* The pattern used to indicate which projects and packages <em>not</em>
* to export.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* cls
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export class files. Defaults to "no".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* src
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export source files. Defaults to "yes".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* res
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Export resource files associated with the included project(s). Defaults
* to "yes".
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* dex
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Use the default exclusion patterns. Defaults to "yes". See below for an
* explanation of default excludes.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* owr
* </td>
*
* <td>
* "yes" or "no" (without the quotes)
* </td>
*
* <td>
* Overwrite any existing files. Defaults to "yes".
* </td>
*
* </tr>
*
* </table>
* <p>
*
* The vajexport servlet uses include and exclude parameters to form the
* criteria for selecting packages to export. The parameter is broken up into
* ProjectName/packageNameSegments, where ProjectName is what you expect, and
* packageNameSegments is a partial (or complete) package name, separated by
* forward slashes, rather than periods. Each packageNameSegment can have
* wildcard characters.</p>
* <tableborder="1">
*
* <tr>
*
* <td>
* <strong>Wildcard Characters</strong>
* </td>
*
* <td>
* <strong>Description</strong>
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* *
* </td>
*
* <td>
* Match zero or more characters in that segment.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* ?
* </td>
*
* <td>
* Match one character in that segment.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* **
* </td>
*
* <td>
* Matches all characters in zero or more segments.
* </td>
*
* </tr>
*
* </table>
*
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public class VAJExportServlet extends VAJToolsServlet
{
// constants for servlet param names
public final static String WITH_DEBUG_INFO = "deb";
public final static String OVERWRITE_PARAM = "owr";

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

+ 0
- 269
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java View File

@@ -1,269 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.ScannerUtil;

/**
* Import source, class files, and resources to the Visual Age for Java
* workspace using FileSets. <p>
*
* Example: <pre>
* &lt;vajimport project="MyVAProject"&gt;
* &lt;fileset dir="src"&gt;
* &lt;include name="org/foo/subsystem1/**" /&gt;
* &lt;exclude name="/org/foo/subsystem1/test/**" /&gt;
* &lt;/fileset&gt;
* &lt;/vajexport&gt;
* </pre> import all source and resource files from the "src" directory which
* start with 'org.foo.subsystem1', except of these starting with
* 'org.foo.subsystem1.test' into the project MyVAProject. </p> <p>
*
* If MyVAProject isn't loaded into the Workspace, a new edition is created in
* the repository and automatically loaded into the Workspace. There has to be
* at least one nested FileSet element. </p> <p>
*
* There are attributes to choose which items to export:
* <tableborder="1" cellpadding="2" cellspacing="0">
*
* <tr>
*
* <tdvalign="top">
* <b>Attribute</b>
* </td>
*
* <tdvalign="top">
* <b>Description</b>
* </td>
*
* <tdalign="center" valign="top">
* <b>Required</b>
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* project
* </td>
*
* <tdvalign="top">
* the name of the Project to import to
* </td>
*
* <tdalign="center" valign="top">
* Yes
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importSources
* </td>
*
* <tdvalign="top">
* import Java sources, defaults to "yes"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importResources
* </td>
*
* <tdvalign="top">
* import resource files (anything that doesn't end with .java or .class),
* defaults to "yes"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* <tr>
*
* <tdvalign="top">
* importClasses
* </td>
*
* <tdvalign="top">
* import class files, defaults to "no"
* </td>
*
* <tdalign="center" valign="top">
* No
* </td>
*
* </tr>
*
* </table>
*
*
* @author RT
* @author: Glenn McAllister, inspired by a similar task written by Peter Kelley
*/
public class VAJImport extends VAJTask
{
protected ArrayList filesets = new ArrayList();
protected boolean importSources = true;
protected boolean importResources = true;
protected boolean importClasses = false;
protected String importProject = null;
protected boolean useDefaultExcludes = true;

/**
* 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;
}

/**
* Import .class files.
*
* @param importClasses The new ImportClasses value
*/
public void setImportClasses( boolean importClasses )
{
this.importClasses = importClasses;
}

/**
* Import resource files (anything that doesn't end in .class or .java)
*
* @param importResources The new ImportResources value
*/
public void setImportResources( boolean importResources )
{
this.importResources = importResources;
}

/**
* Import .java files
*
* @param importSources The new ImportSources value
*/
public void setImportSources( boolean importSources )
{
this.importSources = importSources;
}

/**
* The VisualAge for Java Project name to import into.
*
* @param projectName The new Project value
*/
public void setProject( String projectName )
{
this.importProject = projectName;
}

/**
* Adds a set of files (nested fileset attribute).
*
* @param set The feature to be added to the Fileset attribute
*/
public void addFileset( FileSet set )
{
filesets.add( set );
}

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

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

for( Iterator e = filesets.iterator(); e.hasNext(); )
{
importFileset( (FileSet)e.next() );
}
}

/**
* Import all files from the fileset into the Project in the Workspace.
*
* @param fileset Description of Parameter
*/
protected void importFileset( FileSet fileset )
{
DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fileset );
if( ds.getIncludedFiles().length == 0 )
{
return;
}

String[] includes = null;
String[] excludes = null;

// Hack to get includes and excludes. We could also use getIncludedFiles,
// but that would result in very long HTTP-requests.
// Therefore we want to send the patterns only to the remote tool server
// and let him figure out the files.
try
{
Class directoryScanner = ds.getClass();

Field includesField = directoryScanner.getDeclaredField( "includes" );
includesField.setAccessible( true );
includes = (String[])includesField.get( ds );

Field excludesField = directoryScanner.getDeclaredField( "excludes" );
excludesField.setAccessible( true );
excludes = (String[])excludesField.get( ds );
}
catch( NoSuchFieldException nsfe )
{
throw new TaskException(
"DirectoryScanner.includes or .excludes missing" + nsfe.getMessage() );
}
catch( IllegalAccessException iae )
{
throw new TaskException(
"Access to DirectoryScanner.includes or .excludes not allowed" );
}

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

+ 0
- 78
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java View File

@@ -1,78 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;

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

+ 0
- 45
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.ArrayList;

/**
* Load specific project versions into the Visual Age for Java workspace. Each
* project and version name has to be specified completely. Example:
* <blockquote> &lt;vajload> &nbsp;&lt;project name="MyVAProject"
* version="2.1"/> &nbsp;&lt;project name="Apache Xerces" version="1.2.0"/>
* &lt;/vajload> </blockquote>
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

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

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

/**
* Load specified projects.
*/
public void execute()
{
getUtil().loadProjects( projectDescriptions );
}
}

+ 0
- 25
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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
*
* @author Wolf Siberski, TUI Infotec GmbH
*/

public class VAJLoadProjects extends VAJLoad
{
}







+ 0
- 84
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java View File

@@ -1,84 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.util.ArrayList;

/**
* A Remote Access to Tools Servlet to load a Project from the Repository into
* the Workbench. The following table describes the servlet parameters.
* <table>
*
* <tr>
*
* <td>
* Parameter
* </td>
*
* <td>
* Description
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* project
* </td>
*
* <td>
* The name of the Project you want to load into the Workbench.
* </td>
*
* </tr>
*
* <tr>
*
* <td>
* version
* </td>
*
* <td>
* The version of the package you want to load into the Workbench.
* </td>
*
* </tr>
*
* </table>
*
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public class VAJLoadServlet extends VAJToolsServlet
{

// constants for servlet param names
public final static 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 );

ArrayList projectDescriptions = new ArrayList( 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.add( desc );
}

util.loadProjects( projectDescriptions );
}
}

+ 0
- 27
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

/**
* Adaption of VAJLocalUtil to Task context.
*/
class VAJLocalToolUtil
extends VAJLocalUtil
{
private VAJTask m_task;

public VAJLocalToolUtil( final VAJTask task )
{
m_task = task;
}

public void log( final String msg, final int level )
{
m_task.log( msg, level );
}
}

+ 0
- 528
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java View File

@@ -1,528 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.DirectoryScanner;

/**
* Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions
* into TaskExceptions
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
abstract class VAJLocalUtil
implements VAJUtil
{
// singleton containing the VAJ workspace
private static Workspace workspace;

/**
* get a project from the Workspace.
*
* @param importProject Description of Parameter
* @return The VAJProject value
*/
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 createTaskException( "Error while creating Project "
+ importProject + ": ", e );
}
}

return found;
}

/**
* 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 TaskException(
"Unable to connect to Workspace! "
+ "Make sure you are running in VisualAge for Java." );
}
}

return workspace;
}

/**
* Wraps IvjException into a TaskException
*
* @param errMsg Additional error message
* @param e IvjException which is wrapped
* @return org.apache.tools.ant.TaskException
*/
static TaskException createTaskException(
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 TaskException( errMsg, e );
}


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

/**
* export packages
*
* @param dest Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param exportClasses Description of Parameter
* @param exportDebugInfo Description of Parameter
* @param exportResources Description of Parameter
* @param exportSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @param overwrite Description of Parameter
*/
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++ )
{
getLogger().debug( " " + packages[ i ].getName() );
}

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 createTaskException( "Exporting failed!", ex );
}
}
}


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


/**
* Do the import.
*
* @param importProject Description of Parameter
* @param srcDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param importClasses Description of Parameter
* @param importResources Description of Parameter
* @param importSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @exception TaskException Description of Exception
*/
public void importFiles(
String importProject, File srcDir,
String[] includePatterns, String[] excludePatterns,
boolean importClasses, boolean importResources,
boolean importSources, boolean useDefaultExcludes )
throws TaskException
{

if( importProject == null || "".equals( importProject ) )
{
throw new TaskException( "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();

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

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( "'." );

getLogger().info( summaryLog.toString() );

try
{
Type[] importedTypes = getWorkspace().importData( importSpec );
if( importedTypes == null )
{
throw new TaskException( "Unable to import into Workspace!" );
}
else
{
getLogger().debug( importedTypes.length + " types imported" );
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 createTaskException( "Error while importing into workspace: ",
ivje );
}
}


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

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
public void loadProjects( ArrayList projectDescriptions )
{
ArrayList expandedDescs = getExpandedDescriptions( projectDescriptions );

// output warnings for projects not found
for( Iterator e = projectDescriptions.iterator(); e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();
if( !d.projectFound() )
{
getLogger().warn( "No Projects match the name " + d.getName() );
}
}

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

for( Iterator e = expandedDescs.iterator();
e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();

ProjectEdition pe = findProjectEdition( d.getName(), d.getVersion() );
try
{
log( "Loading '" + d.getName() + "', Version '" + d.getVersion()
+ "', into Workspace", MSG_VERBOSE );
pe.loadIntoWorkspace();
}
catch( IvjException ex )
{
throw createTaskException( "Project '" + d.getName()
+ "' could not be loaded.", ex );
}
}
}

/**
* return project descriptions containing full project names instead of
* patterns with wildcards.
*
* @param projectDescs Description of Parameter
* @return The ExpandedDescriptions value
*/
private ArrayList getExpandedDescriptions( ArrayList projectDescs )
{
ArrayList expandedDescs = new ArrayList( projectDescs.size() );
try
{
String[] projectNames =
getWorkspace().getRepository().getProjectNames();
for( int i = 0; i < projectNames.length; i++ )
{
for( Iterator e = projectDescs.iterator();
e.hasNext(); )
{
VAJProjectDescription d = (VAJProjectDescription)e.next();
String pattern = d.getName();
if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) )
{
d.setProjectFound();
expandedDescs.add( new VAJProjectDescription(
projectNames[ i ], d.getVersion() ) );
break;
}
}
}
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

return expandedDescs;
}

/**
* 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,
ArrayList 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 TaskException( "Error", e );
}
if( files.size() > 0 )
{
logFiles( files, fileType );
summaryLog.append( files.size() );
summaryLog.append( " " + fileType.toLowerCase() + " file" );
summaryLog.append( files.size() > 1 ? "s, " : ", " );
}
}
}

/**
* returns a list of project names matching the given pattern
*
* @param pattern Description of Parameter
* @return Description of the Returned Value
*/
private ArrayList findMatchingProjects( String pattern )
{
String[] projectNames;
try
{
projectNames = getWorkspace().getRepository().getProjectNames();
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

ArrayList matchingProjects = new ArrayList();
for( int i = 0; i < projectNames.length; i++ )
{
if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) )
{
matchingProjects.add( projectNames[ i ] );
}
}

return matchingProjects;
}

/**
* 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 TaskException( "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 TaskException( "Version " + versionName
+ " of Project " + name + " doesn't exist" );
}
return pe;
}
catch( IvjException e )
{
throw createTaskException( "VA Exception occured: ", e );
}

}

/**
* Logs a list of file names to the message log
*
* @param fileNames java.util.ArrayList file names to be logged
* @param fileType Description of Parameter
*/
private void logFiles( ArrayList fileNames, String fileType )
{
getLogger().debug( fileType + " files found for import:" );
for( Iterator e = fileNames.iterator(); e.hasNext(); )
{
getLogger().debug( " " + e.next() );
}
}

/**
* Sort the files into classes, sources, and resources.
*
* @param dir Description of Parameter
* @param files Description of Parameter
* @param classes Description of Parameter
* @param sources Description of Parameter
* @param resources Description of Parameter
*/
private void scanForImport(
File dir,
String[] files,
ArrayList classes,
ArrayList sources,
ArrayList 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.add( file );
}
else if( file.endsWith( ".class" ) || file.endsWith( ".CLASS" ) )
{
classes.add( file );
}
else
{
// for resources VA expects the path relative to the resource path
resources.add( files[ i ] );
}
}
}
}

+ 0
- 71
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java View File

@@ -1,71 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import org.apache.myrmidon.api.TaskException;

/**
* Type class. Holds information about a project edition.
*
* @author RT
* @author: Wolf Siberski
*/
public class VAJProjectDescription
{
private String name;
private boolean projectFound;
private String version;

public VAJProjectDescription()
{
}

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

public void setName( String newName )
{
if( newName == null || newName.equals( "" ) )
{
throw new TaskException( "name attribute must be set" );
}
name = newName;
}

public void setProjectFound()
{
projectFound = true;
}

public void setVersion( String newVersion )
{
if( newVersion == null || newVersion.equals( "" ) )
{
throw new TaskException( "version attribute must be set" );
}
version = newVersion;
}

public String getName()
{
return name;
}

public String getVersion()
{
return version;
}

public boolean projectFound()
{
return projectFound;
}
}

+ 0
- 271
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java View File

@@ -1,271 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
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.util.ArrayList;
import java.util.Iterator;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
* Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions
* into TaskExceptions
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
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
*
* @param destDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param exportClasses Description of Parameter
* @param exportDebugInfo Description of Parameter
* @param exportResources Description of Parameter
* @param exportSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @param overwrite Description of Parameter
*/
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?"
+ VAJExportServlet.WITH_DEBUG_INFO + "=" + exportDebugInfo + "&"
+ VAJExportServlet.OVERWRITE_PARAM + "=" + overwrite + "&"
+ assembleImportExportParams( destDir,
includePatterns, excludePatterns,
exportClasses, exportResources,
exportSources, useDefaultExcludes );
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}
}

/**
* Do the import.
*
* @param importProject Description of Parameter
* @param srcDir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param importClasses Description of Parameter
* @param importResources Description of Parameter
* @param importSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
*/
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?"
+ VAJImportServlet.PROJECT_NAME_PARAM + "="
+ importProject + "&"
+ assembleImportExportParams( srcDir,
includePatterns, excludePatterns,
importClasses, importResources,
importSources, useDefaultExcludes );
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}

}

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
public void loadProjects( ArrayList projectDescriptions )
{
try
{
String request = "http://" + remoteServer + "/servlet/vajload?";
String delimiter = "";
for( Iterator e = projectDescriptions.iterator(); e.hasNext(); )
{
VAJProjectDescription pd = (VAJProjectDescription)e.next();
request = request
+ delimiter + VAJLoadServlet.PROJECT_NAME_PARAM
+ "=" + pd.getName().replace( ' ', '+' )
+ "&" + VAJLoadServlet.VERSION_PARAM
+ "=" + pd.getVersion().replace( ' ', '+' );
//the first param needs no delimiter, but all other
delimiter = "&";
}
sendRequest( request );
}
catch( Exception ex )
{
throw new TaskException( "Error", ex );
}
}

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

/**
* Assemble string for parameters common for import and export Helper method
* to remove double code.
*
* @param dir Description of Parameter
* @param includePatterns Description of Parameter
* @param excludePatterns Description of Parameter
* @param includeClasses Description of Parameter
* @param includeResources Description of Parameter
* @param includeSources Description of Parameter
* @param useDefaultExcludes Description of Parameter
* @return Description of the Returned Value
*/
private String assembleImportExportParams(
File dir,
String[] includePatterns, String[] excludePatterns,
boolean includeClasses, boolean includeResources,
boolean includeSources, boolean useDefaultExcludes )
{
String result =
VAJToolsServlet.DIR_PARAM + "="
+ dir.getAbsolutePath().replace( '\\', '/' ) + "&"
+ VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&"
+ VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&"
+ VAJToolsServlet.SOURCES_PARAM + "=" + includeSources + "&"
+ VAJToolsServlet.DEFAULT_EXCLUDES_PARAM + "=" + useDefaultExcludes;

if( includePatterns != null )
{
for( int i = 0; i < includePatterns.length; i++ )
{
result = result + "&" + VAJExportServlet.INCLUDE_PARAM + "="
+ includePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' );
}
}
if( excludePatterns != null )
{
for( int i = 0; i < excludePatterns.length; i++ )
{
result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "="
+ excludePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' );
}
}

return result;
}

/**
* Sends a servlet request.
*
* @param request Description of Parameter
*/
private void sendRequest( String request )
{
boolean requestFailed = false;
try
{
getLogger().debug( "Request: " + request );

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

InputStream is = null;
// retry three times
for( int i = 0; i < 3; i++ )
{
try
{
is = connection.getInputStream();
break;
}
catch( IOException ex )
{
}
}
if( is == null )
{
getLogger().error( "Can't get " + request );
throw new TaskException( "Couldn't execute " + request );
}

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

}
catch( IOException ex )
{
getLogger().error( "Error sending tool request to VAJ" + ex );
throw new TaskException( "Couldn't execute " + request );
}
if( requestFailed )
{
throw new TaskException( "VAJ tool request failed" );
}
}
}

+ 0
- 59
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

/**
* Super class for all VAJ tasks. Contains common attributes (remoteServer) and
* util methods
*
* @author: Wolf Siberski
*/

import org.apache.tools.ant.Task;

public class VAJTask extends Task
{

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

// holds the appropriate VAJUtil implementation
private VAJUtil util = null;

/**
* Set remote server attribute
*
* @param remoteServer The new Remote value
*/
public void setRemote( String remoteServer )
{
this.remoteServer = remoteServer;
}

/**
* returns the VAJUtil implementation
*
* @return The Util value
*/
protected VAJUtil getUtil()
{
if( util == null )
{
if( remoteServer == null )
{
util = new VAJLocalToolUtil( this );
}
else
{
util = new VAJRemoteUtil( this, remoteServer );
}
}
return util;
}

}

+ 0
- 231
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java View File

@@ -1,231 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.myrmidon.api.TaskException;

/**
* Abstract base class to provide common services for the VAJ tool API servlets
*
* @author Wolf Siberski, based on servlets written by Glenn McAllister
*/
public abstract class VAJToolsServlet
extends HttpServlet
{
// constants for servlet param names
public final static String DIR_PARAM = "dir";
public final static String INCLUDE_PARAM = "include";
public final static String EXCLUDE_PARAM = "exclude";
public final static String CLASSES_PARAM = "cls";
public final static String SOURCES_PARAM = "src";
public final static String RESOURCES_PARAM = "res";
public final static String DEFAULT_EXCLUDES_PARAM = "dex";
public final static String PROJECT_NAME_PARAM = "project";

// current request
HttpServletRequest request;

// response to current request
HttpServletResponse response;

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

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

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

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

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

/**
* Returns all values for a parameter.
*
* @param param Description of Parameter
* @return The ParamValues value
*/
protected String[] getParamValues( String param )
{
return request.getParameterValues( param );
}

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

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

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

/**
* Get the VAJUtil implementation
*
* @return The Util value
*/
VAJUtil getUtil()
{
return util;
}

/**
* Adaptation of VAJUtil for servlet context.
*/
class VAJLocalServletUtil
extends VAJLocalUtil
{
public void log( String msg, int level )
{
try
{
if( msg != null )
{
msg = msg.replace( '\r', ' ' );
int i = 0;
while( i < msg.length() )
{
int nlPos = msg.indexOf( '\n', i );
if( nlPos == -1 )
{
nlPos = msg.length();
}
response.getWriter().println( Integer.toString( level )
+ " " + msg.substring( i, nlPos ) );
i = nlPos + 1;
}
}
}
catch( IOException e )
{
throw new TaskException( "logging failed. msg was: "
+ e.getMessage() );
}
}
}
}

+ 0
- 80
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java View File

@@ -1,80 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import java.io.File;
import java.util.ArrayList;

/**
* Helper interface for VAJ tasks. Encapsulates the interface to the VAJ tool
* API.
*
* @author Wolf Siberski, TUI Infotec GmbH
*/
interface VAJUtil
{
// log levels
public final static int MSG_DEBUG = 4;
public final static int MSG_ERR = 0;
public final static int MSG_INFO = 2;
public final static int MSG_VERBOSE = 3;
public final static int MSG_WARN = 1;

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

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

/**
* Load specified projects.
*
* @param projectDescriptions Description of Parameter
*/
void loadProjects( ArrayList projectDescriptions );

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

+ 0
- 221
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java View File

@@ -1,221 +0,0 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.tools.ant.taskdefs.optional.ide;

import com.ibm.ivj.util.base.IvjException;
import com.ibm.ivj.util.base.Package;
import com.ibm.ivj.util.base.Project;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.ScannerUtil;

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

// Patterns that should be excluded by default.
private final static 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 ArrayList packagesIncluded = new ArrayList();

/**
* Matches a string against a pattern. The pattern contains two special
* characters: '*' which means zero or more characters, '?' which means one
* and only one character.
*
* @param pattern the (non-null) pattern to match against
* @param str the (non-null) string that must be matched against the pattern
* @return <code>true</code> when the string matches against the pattern,
* <code>false</code> otherwise.
*/
protected static boolean match( String pattern, String str )
{
return ScannerUtil.match( pattern, str );
}

/**
* 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.get( i );
}
return packages;
}

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

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

ArrayList matchingProjects = new ArrayList();

boolean allProjectsMatch = false;
for( int i = 0; i < projects.length; i++ )
{
Project project = projects[ i ];
for( int j = 0; j < getIncludes().length && !allProjectsMatch; j++ )
{
StringTokenizer tok =
new StringTokenizer( getIncludes()[ 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.add( project );
break;
}
}
}

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

return matchingProjects;
}

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

// only scan projects which are included in at least one include pattern
ArrayList matchingProjects = findMatchingProjects();
for( Iterator e = matchingProjects.iterator(); e.hasNext(); )
{
Project project = (Project)e.next();
scanProject( project );
}
}

/**
* Scans a project for packages that match at least one include pattern, and
* don't match any exclude patterns.
*
* @param project Description of Parameter
*/
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.add( item );
}
}
}
}
catch( IvjException e )
{
throw VAJLocalUtil.createTaskException( "VA Exception occured: ", e );
}
}
}

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

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

Loading…
Cancel
Save