diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheck.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheck.java deleted file mode 100644 index cea739def..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheck.java +++ /dev/null @@ -1,151 +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.todo.taskdefs.ccm; - -import java.io.File; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Class common to all check commands (checkout, checkin,checkin default task); - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMCheck extends Continuus -{ - - /** - * -comment flag -- comment to attach to the file - */ - public final static String FLAG_COMMENT = "/comment"; - - /** - * -task flag -- associate checckout task with task - */ - public final static String FLAG_TASK = "/task"; - - private File _file = null; - private String _comment = null; - private String _task = null; - - public CCMCheck() - { - super(); - } - - /** - * Set the value of comment. - * - * @param v Value to assign to comment. - */ - public void setComment( String v ) - { - this._comment = v; - } - - /** - * Set the value of file. - * - * @param v Value to assign to file. - */ - public void setFile( File v ) - { - this._file = v; - } - - /** - * Set the value of task. - * - * @param v Value to assign to task. - */ - public void setTask( String v ) - { - this._task = v; - } - - /** - * Get the value of comment. - * - * @return value of comment. - */ - public String getComment() - { - return _comment; - } - - /** - * Get the value of file. - * - * @return value of file. - */ - public File getFile() - { - return _file; - } - - /** - * Get the value of task. - * - * @return value of task. - */ - public String getTask() - { - return _task; - } - - /** - * Executes the task.

- * - * Builds a command line to execute ccm and then calls Exec's run method to - * execute the command line.

- * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - Commandline commandLine = new Commandline(); - - // build the command line from what we got the format is - // ccm co /t .. files - // as specified in the CLEARTOOL.EXE help - commandLine.setExecutable( getCcmCommand() ); - commandLine.addArgument( getCcmAction() ); - - checkOptions( commandLine ); - - run( commandLine, null ); - } - - /** - * Check the command line options. - * - * @param cmd Description of Parameter - */ - private void checkOptions( ArgumentList cmd ) - { - if( getComment() != null ) - { - cmd.addArgument( FLAG_COMMENT ); - cmd.addArgument( getComment() ); - } - - if( getTask() != null ) - { - cmd.addArgument( FLAG_TASK ); - cmd.addArgument( getTask() ); - }// end of if () - - if( getFile() != null ) - { - cmd.addArgument( _file ); - }// end of if () - } -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckin.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckin.java deleted file mode 100644 index 4a963c67a..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckin.java +++ /dev/null @@ -1,28 +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.todo.taskdefs.ccm; - -import java.util.Date; - -/** - * Task to perform Checkin command to Continuus - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMCheckin extends CCMCheck -{ - - public CCMCheckin() - { - super(); - setCcmAction( COMMAND_CHECKIN ); - setComment( "Checkin " + new Date() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckinDefault.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckinDefault.java deleted file mode 100644 index ed62a3a76..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckinDefault.java +++ /dev/null @@ -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.todo.taskdefs.ccm; - -/** - * Task to perform Checkin Default task command to Continuus - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMCheckinDefault extends CCMCheck -{ - - public final static String DEFAULT_TASK = "default"; - - public CCMCheckinDefault() - { - super(); - setCcmAction( COMMAND_CHECKIN ); - setTask( DEFAULT_TASK ); - } -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckout.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckout.java deleted file mode 100644 index 67693c058..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCheckout.java +++ /dev/null @@ -1,24 +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.todo.taskdefs.ccm; - -/** - * Task to perform Checkout command to Continuus - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMCheckout extends CCMCheck -{ - - public CCMCheckout() - { - super(); - setCcmAction( COMMAND_CHECKOUT ); - } -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCreateTask.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCreateTask.java deleted file mode 100644 index a075f51f1..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMCreateTask.java +++ /dev/null @@ -1,244 +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.todo.taskdefs.ccm; - -import org.apache.aut.nativelib.ExecOutputHandler; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskContext; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task allows to create new ccm task and set it as the default - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMCreateTask - extends Continuus - implements ExecOutputHandler -{ - /** - * /comment -- comments associated to the task - */ - private final static String FLAG_COMMENT = "/synopsis"; - - /** - * /platform flag -- target platform - */ - private final static String FLAG_PLATFORM = "/plat"; - - /** - * /resolver flag - */ - private final static String FLAG_RESOLVER = "/resolver"; - - /** - * /release flag - */ - private final static String FLAG_RELEASE = "/release"; - - /** - * /release flag - */ - private final static String FLAG_SUBSYSTEM = "/subsystem"; - - /** - * -task flag -- associate checckout task with task - */ - private final static String FLAG_TASK = "/task"; - - private String m_comment; - private String m_platform; - private String m_resolver; - private String m_release; - private String m_subSystem; - private String m_task; - - public CCMCreateTask() - { - setCcmAction( COMMAND_CREATE_TASK ); - } - - /** - * Set the value of comment. - * - * @param v Value to assign to comment. - */ - public void setComment( final String comment ) - { - m_comment = comment; - } - - /** - * Set the value of platform. - * - * @param v Value to assign to platform. - */ - public void setPlatform( final String platform ) - { - m_platform = platform; - } - - /** - * Set the value of release. - * - * @param v Value to assign to release. - */ - public void setRelease( final String release ) - { - m_release = release; - } - - /** - * Set the value of resolver. - * - * @param v Value to assign to resolver. - */ - public void setResolver( final String resolver ) - { - m_resolver = resolver; - } - - /** - * Set the value of subSystem. - * - * @param v Value to assign to subSystem. - */ - public void setSubSystem( final String subSystem ) - { - m_subSystem = subSystem; - } - - /** - * Set the value of task. - * - * @param v Value to assign to task. - */ - public void setTask( final String task ) - { - m_task = task; - } - - /** - * Executes the task.

- * - * Builds a command line to execute ccm and then calls Exec's run method to - * execute the command line.

- * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - final ArgumentList commandLine = determineTask(); - if( null == m_task ) - { - final String message = "Error determining task"; - throw new TaskException( message ); - } - - //create task ok, set this task as the default one - final Commandline cmd = new Commandline(); - cmd.setExecutable( getCcmCommand() ); - cmd.addArgument( COMMAND_DEFAULT_TASK ); - cmd.addArgument( m_task ); - run( cmd, null ); - } - - private ArgumentList determineTask() - throws TaskException - { - final Commandline commandLine = new Commandline(); - - // build the command line from what we got the format - // as specified in the CCM.EXE help - commandLine.setExecutable( getCcmCommand() ); - commandLine.addArgument( getCcmAction() ); - - checkOptions( commandLine ); - - run( commandLine, this ); - return commandLine; - } - - /** - * Check the command line options. - */ - private void checkOptions( final ArgumentList cmd ) - { - if( m_comment != null ) - { - cmd.addArgument( FLAG_COMMENT ); - cmd.addArgument( "\"" + m_comment + "\"" ); - } - - if( m_platform != null ) - { - cmd.addArgument( FLAG_PLATFORM ); - cmd.addArgument( m_platform ); - } - - if( m_resolver != null ) - { - cmd.addArgument( FLAG_RESOLVER ); - cmd.addArgument( m_resolver ); - } - - if( m_subSystem != null ) - { - cmd.addArgument( FLAG_SUBSYSTEM ); - cmd.addArgument( "\"" + m_subSystem + "\"" ); - } - - if( m_release != null ) - { - cmd.addArgument( FLAG_RELEASE ); - cmd.addArgument( m_release ); - } - } - - /** - * Receive notification about the process writing - * to standard output. - */ - public void stdout( final String line ) - { - getContext().debug( "buffer:" + line ); - final String task = getTask( line ); - - setTask( task ); - getContext().debug( "task is " + m_task ); - } - - private String getTask( final String line ) - { - try - { - final String task = line.substring( line.indexOf( ' ' ) ).trim(); - return task.substring( 0, task.lastIndexOf( ' ' ) ).trim(); - } - catch( final Exception e ) - { - final String message = "error procession stream " + e.getMessage(); - getContext().error( message, e ); - } - - return null; - } - - /** - * Receive notification about the process writing - * to standard error. - */ - public void stderr( final String line ) - { - getContext().debug( "err " + line ); - } -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMReconfigure.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMReconfigure.java deleted file mode 100644 index fa47706cc..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/CCMReconfigure.java +++ /dev/null @@ -1,114 +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.todo.taskdefs.ccm; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task allows to reconfigure a project, recurcively or not - * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public class CCMReconfigure - extends Continuus -{ - /** - * /recurse -- - */ - public final static String FLAG_RECURSE = "/recurse"; - - /** - * /recurse -- - */ - public final static String FLAG_VERBOSE = "/verbose"; - - /** - * /project flag -- target project - */ - public final static String FLAG_PROJECT = "/project"; - - private String m_ccmProject; - private boolean m_recurse; - private boolean m_verbose; - - public CCMReconfigure() - { - super(); - setCcmAction( COMMAND_RECONFIGURE ); - } - - /** - * Set the value of project. - */ - public void setCcmProject( final String ccmProject ) - { - m_ccmProject = ccmProject; - } - - /** - * Set the value of recurse. - */ - public void setRecurse( final boolean recurse ) - { - m_recurse = recurse; - } - - /** - * Set the value of verbose. - */ - public void setVerbose( final boolean verbose ) - { - m_verbose = verbose; - } - - /** - * Executes the task.

- * - * Builds a command line to execute ccm and then calls Exec's run method to - * execute the command line.

- */ - public void execute() - throws TaskException - { - final Commandline cmd = new Commandline(); - - // build the command line from what we got the format - // as specified in the CCM.EXE help - cmd.setExecutable( getCcmCommand() ); - cmd.addArgument( getCcmAction() ); - - checkOptions( cmd ); - - run( cmd, null ); - } - - /** - * Build the command line options. - */ - private void checkOptions( final ArgumentList cmd ) - { - if( m_recurse == true ) - { - cmd.addArgument( FLAG_RECURSE ); - } - - if( m_verbose == true ) - { - cmd.addArgument( FLAG_VERBOSE ); - } - - if( m_ccmProject != null ) - { - cmd.addArgument( FLAG_PROJECT ); - cmd.addArgument( m_ccmProject ); - } - } -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/Continuus.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/Continuus.java deleted file mode 100644 index aac89ee87..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/ccm/Continuus.java +++ /dev/null @@ -1,120 +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.todo.taskdefs.ccm; - -import java.io.File; -import org.apache.aut.nativelib.ExecManager; -import org.apache.aut.nativelib.ExecOutputHandler; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.Execute; -import org.apache.tools.todo.types.Commandline; - -/** - * A base class for creating tasks for executing commands on Continuus 5.1

- * - * The class extends the task as it operates by executing the ccm.exe program - * supplied with Continuus/Synergy. By default the task expects the ccm - * executable to be in the path, you can override this be specifying the ccmdir - * attribute.

- * - * @author Benoit Moussaud benoit.moussaud@criltelecom.com - */ -public abstract class Continuus - extends AbstractTask -{ - /** - * Constant for the thing to execute - */ - private final static String CCM_EXE = "ccm"; - - /** - * The 'CreateTask' command - */ - public final static String COMMAND_CREATE_TASK = "create_task"; - /** - * The 'Checkout' command - */ - public final static String COMMAND_CHECKOUT = "co"; - /** - * The 'Checkin' command - */ - public final static String COMMAND_CHECKIN = "ci"; - /** - * The 'Reconfigure' command - */ - public final static String COMMAND_RECONFIGURE = "reconfigure"; - - /** - * The 'Reconfigure' command - */ - public final static String COMMAND_DEFAULT_TASK = "default_task"; - - private String m_ccmDir = ""; - private String m_ccmAction = ""; - - /** - * Set the directory where the ccm executable is located - * - * @param dir the directory containing the ccm executable - */ - public final void setCcmDir( final File dir ) - { - m_ccmDir = dir.toString(); - } - - /** - * Set the value of ccmAction. - * - * @param ccmAction Value to assign to ccmAction. - */ - public void setCcmAction( final String ccmAction ) - { - m_ccmAction = ccmAction; - } - - /** - * Get the value of ccmAction. - * - * @return value of ccmAction. - */ - public String getCcmAction() - { - return m_ccmAction; - } - - /** - * Builds and returns the command string to execute ccm - * - * @return String containing path to the executable - */ - protected final String getCcmCommand() - { - String toReturn = m_ccmDir; - if( !toReturn.equals( "" ) && !toReturn.endsWith( "/" ) ) - { - toReturn += "/"; - } - - toReturn += CCM_EXE; - - return toReturn; - } - - protected void run( final Commandline cmd, final ExecOutputHandler handler ) - throws TaskException - { - final Execute exe = new Execute(); - if( null != handler ) - { - exe.setExecOutputHandler( handler ); - } - exe.setCommandline( cmd ); - exe.execute( getContext() ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckin.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckin.java deleted file mode 100644 index 1e585ad57..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckin.java +++ /dev/null @@ -1,440 +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.todo.taskdefs.clearcase; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task to perform Checkin command to ClearCase.

- * - * The following attributes are interpreted: - * - * - * - * - * - * Attribute - * - * - * - * Values - * - * - * - * Required - * - * - * - * - * - * - * - * viewpath - * - * - * - * Path to the ClearCase view file or directory that the command will - * operate on - * - * - * - * No - * - * - * - * - * - * - * - * comment - * - * - * - * Specify a comment. Only one of comment or cfile may be used. - * - * - * - * No - * - * - * - * - * - * - * - * commentfile - * - * - * - * Specify a file containing a comment. Only one of comment or - * cfile may be used. - * - * - * - * No - * - * - * - * - * - * - * - * nowarn - * - * - * - * Suppress warning messages - * - * - * - * No - * - * - * - * - * - * - * - * preservetime - * - * - * - * Preserve the modification time - * - * - * - * No - * - * - * - * - * - * - * - * keepcopy - * - * - * - * Keeps a copy of the file with a .keep extension - * - * - * - * - * No - * - * - * - * - * - * - * - * identical - * - * - * - * Allows the file to be checked in even if it is - * identical to the original - * - * - * - * No - * - * - * - * - * - * - * - * @author Curtis White - */ -public class CCCheckin extends ClearCase -{ - - /** - * -c flag -- comment to attach to the file - */ - public final static String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public final static String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public final static String FLAG_NOCOMMENT = "-nc"; - /** - * -nwarn flag -- suppresses warning messages - */ - public final static String FLAG_NOWARN = "-nwarn"; - /** - * -ptime flag -- preserves the modification time - */ - public final static String FLAG_PRESERVETIME = "-ptime"; - /** - * -keep flag -- keeps a copy of the file with a .keep extension - */ - public final static String FLAG_KEEPCOPY = "-keep"; - /** - * -identical flag -- allows the file to be checked in even if it is - * identical to the original - */ - public final static String FLAG_IDENTICAL = "-identical"; - private String m_Comment = null; - private String m_Cfile = null; - private boolean m_Nwarn = false; - private boolean m_Ptime = false; - private boolean m_Keep = false; - private boolean m_Identical = true; - - /** - * Set comment string - * - * @param comment the comment string - */ - public void setComment( String comment ) - { - m_Comment = comment; - } - - /** - * Set comment file - * - * @param cfile the path to the comment file - */ - public void setCommentFile( String cfile ) - { - m_Cfile = cfile; - } - - /** - * Set the identical flag - * - * @param identical the status to set the flag to - */ - public void setIdentical( boolean identical ) - { - m_Identical = identical; - } - - /** - * Set the keepcopy flag - * - * @param keep the status to set the flag to - */ - public void setKeepCopy( boolean keep ) - { - m_Keep = keep; - } - - /** - * Set the nowarn flag - * - * @param nwarn the status to set the flag to - */ - public void setNoWarn( boolean nwarn ) - { - m_Nwarn = nwarn; - } - - /** - * Set preservetime flag - * - * @param ptime the status to set the flag to - */ - public void setPreserveTime( boolean ptime ) - { - m_Ptime = ptime; - } - - /** - * Get comment string - * - * @return String containing the comment - */ - public String getComment() - { - return m_Comment; - } - - /** - * Get comment file - * - * @return String containing the path to the comment file - */ - public String getCommentFile() - { - return m_Cfile; - } - - /** - * Get identical flag status - * - * @return boolean containing status of identical flag - */ - public boolean getIdentical() - { - return m_Identical; - } - - /** - * Get keepcopy flag status - * - * @return boolean containing status of keepcopy flag - */ - public boolean getKeepCopy() - { - return m_Keep; - } - - /** - * Get nowarn flag status - * - * @return boolean containing status of nwarn flag - */ - public boolean getNoWarn() - { - return m_Nwarn; - } - - /** - * Get preservetime flag status - * - * @return boolean containing status of preservetime flag - */ - public boolean getPreserveTime() - { - return m_Ptime; - } - - /** - * Executes the task.

- * - * Builds a command line to execute cleartool and then calls Exec's run - * method to execute the command line. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - Commandline commandLine = new Commandline(); - - // Default the viewpath to basedir if it is not specified - if( getViewPath() == null ) - { - setViewPath( getBaseDirectory().getPath() ); - } - - // build the command line from what we got. the format is - // cleartool checkin [options...] [viewpath ...] - // as specified in the CLEARTOOL.EXE help - commandLine.setExecutable( getClearToolCommand() ); - commandLine.addArgument( COMMAND_CHECKIN ); - - checkOptions( commandLine ); - - run( commandLine ); - } - - /** - * Get the 'comment' command - * - * @param cmd Description of Parameter - */ - private void getCommentCommand( ArgumentList cmd ) - { - if( getComment() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_COMMENT ); - cmd.addArgument( getComment() ); - } - } - - /** - * Get the 'commentfile' command - * - * @param cmd Description of Parameter - */ - private void getCommentFileCommand( ArgumentList cmd ) - { - if( getCommentFile() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_COMMENTFILE ); - cmd.addArgument( getCommentFile() ); - } - } - - /** - * Check the command line options. - * - * @param cmd Description of Parameter - */ - private void checkOptions( ArgumentList cmd ) - { - if( getComment() != null ) - { - // -c - getCommentCommand( cmd ); - } - else - { - if( getCommentFile() != null ) - { - // -cfile - getCommentFileCommand( cmd ); - } - else - { - cmd.addArgument( FLAG_NOCOMMENT ); - } - } - - if( getNoWarn() ) - { - // -nwarn - cmd.addArgument( FLAG_NOWARN ); - } - - if( getPreserveTime() ) - { - // -ptime - cmd.addArgument( FLAG_PRESERVETIME ); - } - - if( getKeepCopy() ) - { - // -keep - cmd.addArgument( FLAG_KEEPCOPY ); - } - - if( getIdentical() ) - { - // -identical - cmd.addArgument( FLAG_IDENTICAL ); - } - - // viewpath - cmd.addArgument( getViewPath() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckout.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckout.java deleted file mode 100644 index 0f248be04..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCCheckout.java +++ /dev/null @@ -1,592 +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.todo.taskdefs.clearcase; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task to perform Checkout command to ClearCase.

- * - * The following attributes are interpretted: - * - * - * - * - * - * Attribute - * - * - * - * Values - * - * - * - * Required - * - * - * - * - * - * - * - * viewpath - * - * - * - * Path to the ClearCase view file or directory that the command will - * operate on - * - * - * - * No - * - * - * - * - * - * - * - * reserved - * - * - * - * Specifies whether to check out the file as reserved or not - * - * - * - * Yes - * - * - * - * - * - * - * - * out - * - * - * - * Creates a writable file under a different filename - * - * - * - * No - * - * - * - * - * - * - * - * nodata - * - * - * - * Checks out the file but does not create an editable file - * containing its data - * - * - * - * No - * - * - * - * - * - * - * - * branch - * - * - * - * Specify a branch to check out the file to - * - * - * - * No - * - * - * - * - * - * - * - * version - * - * - * - * Allows checkout of a version other than main latest - * - * - * - * - * No - * - * - * - * - * - * - * - * nowarn - * - * - * - * Suppress warning messages - * - * - * - * No - * - * - * - * - * - * - * - * comment - * - * - * - * Specify a comment. Only one of comment or - * cfile may be used. - * - * - * - * No - * - * - * - * - * - * - * - * commentfile - * - * - * - * Specify a file containing a comment. - * Only one of comment or cfile may be - * used. - * - * - * - * No - * - * - * - * - * - * - * - * @author Curtis White - */ -public class CCCheckout extends ClearCase -{ - - /** - * -reserved flag -- check out the file as reserved - */ - public final static String FLAG_RESERVED = "-reserved"; - /** - * -reserved flag -- check out the file as unreserved - */ - public final static String FLAG_UNRESERVED = "-unreserved"; - /** - * -out flag -- create a writable file under a different filename - */ - public final static String FLAG_OUT = "-out"; - /** - * -ndata flag -- checks out the file but does not create an editable file - * containing its data - */ - public final static String FLAG_NODATA = "-ndata"; - /** - * -branch flag -- checks out the file on a specified branch - */ - public final static String FLAG_BRANCH = "-branch"; - /** - * -version flag -- allows checkout of a version that is not main latest - */ - public final static String FLAG_VERSION = "-version"; - /** - * -nwarn flag -- suppresses warning messages - */ - public final static String FLAG_NOWARN = "-nwarn"; - /** - * -c flag -- comment to attach to the file - */ - public final static String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public final static String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public final static String FLAG_NOCOMMENT = "-nc"; - private boolean m_Reserved = true; - private String m_Out = null; - private boolean m_Ndata = false; - private String m_Branch = null; - private boolean m_Version = false; - private boolean m_Nwarn = false; - private String m_Comment = null; - private String m_Cfile = null; - - /** - * Set branch name - * - * @param branch the name of the branch - */ - public void setBranch( String branch ) - { - m_Branch = branch; - } - - /** - * Set comment string - * - * @param comment the comment string - */ - public void setComment( String comment ) - { - m_Comment = comment; - } - - /** - * Set comment file - * - * @param cfile the path to the comment file - */ - public void setCommentFile( String cfile ) - { - m_Cfile = cfile; - } - - /** - * Set the nodata flag - * - * @param ndata the status to set the flag to - */ - public void setNoData( boolean ndata ) - { - m_Ndata = ndata; - } - - /** - * Set the nowarn flag - * - * @param nwarn the status to set the flag to - */ - public void setNoWarn( boolean nwarn ) - { - m_Nwarn = nwarn; - } - - /** - * Set out file - * - * @param outf the path to the out file - */ - public void setOut( String outf ) - { - m_Out = outf; - } - - /** - * Set reserved flag status - * - * @param reserved the status to set the flag to - */ - public void setReserved( boolean reserved ) - { - m_Reserved = reserved; - } - - /** - * Set the version flag - * - * @param version the status to set the flag to - */ - public void setVersion( boolean version ) - { - m_Version = version; - } - - /** - * Get branch name - * - * @return String containing the name of the branch - */ - public String getBranch() - { - return m_Branch; - } - - /** - * Get comment string - * - * @return String containing the comment - */ - public String getComment() - { - return m_Comment; - } - - /** - * Get comment file - * - * @return String containing the path to the comment file - */ - public String getCommentFile() - { - return m_Cfile; - } - - /** - * Get nodata flag status - * - * @return boolean containing status of ndata flag - */ - public boolean getNoData() - { - return m_Ndata; - } - - /** - * Get nowarn flag status - * - * @return boolean containing status of nwarn flag - */ - public boolean getNoWarn() - { - return m_Nwarn; - } - - /** - * Get out file - * - * @return String containing the path to the out file - */ - public String getOut() - { - return m_Out; - } - - /** - * Get reserved flag status - * - * @return boolean containing status of reserved flag - */ - public boolean getReserved() - { - return m_Reserved; - } - - /** - * Get version flag status - * - * @return boolean containing status of version flag - */ - public boolean getVersion() - { - return m_Version; - } - - /** - * Executes the task.

- * - * Builds a command line to execute cleartool and then calls Exec's run - * method to execute the command line. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - Commandline commandLine = new Commandline(); - - // Default the viewpath to basedir if it is not specified - if( getViewPath() == null ) - { - setViewPath( getBaseDirectory().getPath() ); - } - - // build the command line from what we got the format is - // cleartool checkout [options...] [viewpath ...] - // as specified in the CLEARTOOL.EXE help - commandLine.setExecutable( getClearToolCommand() ); - commandLine.addArgument( COMMAND_CHECKOUT ); - - checkOptions( commandLine ); - - run( commandLine ); - } - - /** - * Get the 'branch' command - * - * @param cmd Description of Parameter - */ - private void getBranchCommand( ArgumentList cmd ) - { - if( getBranch() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_BRANCH ); - cmd.addArgument( getBranch() ); - } - } - - /** - * Get the 'comment' command - * - * @param cmd Description of Parameter - */ - private void getCommentCommand( ArgumentList cmd ) - { - if( getComment() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_COMMENT ); - cmd.addArgument( getComment() ); - } - } - - /** - * Get the 'cfile' command - * - * @param cmd Description of Parameter - */ - private void getCommentFileCommand( ArgumentList cmd ) - { - if( getCommentFile() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_COMMENTFILE ); - cmd.addArgument( getCommentFile() ); - } - } - - /** - * Get the 'out' command - * - * @param cmd Description of Parameter - */ - private void getOutCommand( ArgumentList cmd ) - { - if( getOut() != null ) - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_OUT ); - cmd.addArgument( getOut() ); - } - } - - /** - * Check the command line options. - * - * @param cmd Description of Parameter - */ - private void checkOptions( ArgumentList cmd ) - { - // ClearCase items - if( getReserved() ) - { - // -reserved - cmd.addArgument( FLAG_RESERVED ); - } - else - { - // -unreserved - cmd.addArgument( FLAG_UNRESERVED ); - } - - if( getOut() != null ) - { - // -out - getOutCommand( cmd ); - } - else - { - if( getNoData() ) - { - // -ndata - cmd.addArgument( FLAG_NODATA ); - } - - } - - if( getBranch() != null ) - { - // -branch - getBranchCommand( cmd ); - } - else - { - if( getVersion() ) - { - // -version - cmd.addArgument( FLAG_VERSION ); - } - - } - - if( getNoWarn() ) - { - // -nwarn - cmd.addArgument( FLAG_NOWARN ); - } - - if( getComment() != null ) - { - // -c - getCommentCommand( cmd ); - } - else - { - if( getCommentFile() != null ) - { - // -cfile - getCommentFileCommand( cmd ); - } - else - { - cmd.addArgument( FLAG_NOCOMMENT ); - } - } - - // viewpath - cmd.addArgument( getViewPath() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUnCheckout.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUnCheckout.java deleted file mode 100644 index 113f73647..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUnCheckout.java +++ /dev/null @@ -1,162 +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.todo.taskdefs.clearcase; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task to perform UnCheckout command to ClearCase.

- * - * The following attributes are interpretted: - * - * - * - * - * - * Attribute - * - * - * - * Values - * - * - * - * Required - * - * - * - * - * - * - * - * viewpath - * - * - * - * Path to the ClearCase view file or directory that the command will - * operate on - * - * - * - * No - * - * - * - * - * - * - * - * keepcopy - * - * - * - * Specifies whether to keep a copy of the file with a .keep extension - * or not - * - * - * - * No - * - * - * - * - * - * - * - * @author Curtis White - */ -public class CCUnCheckout extends ClearCase -{ - - /** - * -keep flag -- keep a copy of the file with .keep extension - */ - public final static String FLAG_KEEPCOPY = "-keep"; - /** - * -rm flag -- remove the copy of the file - */ - public final static String FLAG_RM = "-rm"; - private boolean m_Keep = false; - - /** - * Set keepcopy flag status - * - * @param keep the status to set the flag to - */ - public void setKeepCopy( boolean keep ) - { - m_Keep = keep; - } - - /** - * Get keepcopy flag status - * - * @return boolean containing status of keep flag - */ - public boolean getKeepCopy() - { - return m_Keep; - } - - /** - * Executes the task.

- * - * Builds a command line to execute cleartool and then calls Exec's run - * method to execute the command line. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - Commandline commandLine = new Commandline(); - - // Default the viewpath to basedir if it is not specified - if( getViewPath() == null ) - { - setViewPath( getBaseDirectory().getPath() ); - } - - // build the command line from what we got the format is - // cleartool uncheckout [options...] [viewpath ...] - // as specified in the CLEARTOOL.EXE help - commandLine.setExecutable( getClearToolCommand() ); - commandLine.addArgument( COMMAND_UNCHECKOUT ); - - checkOptions( commandLine ); - - run( commandLine ); - } - - /** - * Check the command line options. - * - * @param cmd Description of Parameter - */ - private void checkOptions( ArgumentList cmd ) - { - // ClearCase items - if( getKeepCopy() ) - { - // -keep - cmd.addArgument( FLAG_KEEPCOPY ); - } - else - { - // -rm - cmd.addArgument( FLAG_RM ); - } - - // viewpath - cmd.addArgument( getViewPath() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUpdate.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUpdate.java deleted file mode 100644 index 6a7875e69..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/CCUpdate.java +++ /dev/null @@ -1,429 +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.todo.taskdefs.clearcase; - -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.todo.types.Commandline; -import org.apache.tools.todo.types.ArgumentList; - -/** - * Task to perform an Update command to ClearCase.

- * - * The following attributes are interpretted: - * - * - * - * - * - * Attribute - * - * - * - * Values - * - * - * - * Required - * - * - * - * - * - * - * - * viewpath - * - * - * - * Path to the ClearCase view file or directory that the command will - * operate on - * - * - * - * No - * - * - * - * - * - * - * - * graphical - * - * - * - * Displays a graphical dialog during the update - * - * - * - * No - * - * - * - * - * - * - * - * log - * - * - * - * Specifies a log file for ClearCase to write to - * - * - * - * No - * - * - * - * - * - * - * - * overwrite - * - * - * - * Specifies whether to overwrite hijacked files or not - * - * - * - * No - * - * - * - * - * - * - * - * rename - * - * - * - * Specifies that hijacked files should be renamed with a - * .keep extension - * - * - * - * No - * - * - * - * - * - * - * - * currenttime - * - * - * - * Specifies that modification time should be written - * as the current time. Either currenttime or - * preservetime can be specified. - * - * - * - * No - * - * - * - * - * - * - * - * preservetime - * - * - * - * Specifies that modification time should - * preserved from the VOB time. Either currenttime - * or preservetime can be specified. - * - * - * - * No - * - * - * - * - * - * - * - * @author Curtis White - */ -public class CCUpdate extends ClearCase -{ - - /** - * -graphical flag -- display graphical dialog during update operation - */ - public final static String FLAG_GRAPHICAL = "-graphical"; - /** - * -log flag -- file to log status to - */ - public final static String FLAG_LOG = "-log"; - /** - * -overwrite flag -- overwrite hijacked files - */ - public final static String FLAG_OVERWRITE = "-overwrite"; - /** - * -noverwrite flag -- do not overwrite hijacked files - */ - public final static String FLAG_NOVERWRITE = "-noverwrite"; - /** - * -rename flag -- rename hijacked files with .keep extension - */ - public final static String FLAG_RENAME = "-rename"; - /** - * -ctime flag -- modified time is written as the current time - */ - public final static String FLAG_CURRENTTIME = "-ctime"; - /** - * -ptime flag -- modified time is written as the VOB time - */ - public final static String FLAG_PRESERVETIME = "-ptime"; - private boolean m_Graphical = false; - private boolean m_Overwrite = false; - private boolean m_Rename = false; - private boolean m_Ctime = false; - private boolean m_Ptime = false; - private String m_Log = null; - - /** - * Set modified time based on current time - * - * @param ct the status to set the flag to - */ - public void setCurrentTime( boolean ct ) - { - m_Ctime = ct; - } - - /** - * Set graphical flag status - * - * @param graphical the status to set the flag to - */ - public void setGraphical( boolean graphical ) - { - m_Graphical = graphical; - } - - /** - * Set log file where cleartool can record the status of the command - * - * @param log the path to the log file - */ - public void setLog( String log ) - { - m_Log = log; - } - - /** - * Set overwrite hijacked files status - * - * @param ow the status to set the flag to - */ - public void setOverwrite( boolean ow ) - { - m_Overwrite = ow; - } - - /** - * Preserve modified time from the VOB time - * - * @param pt the status to set the flag to - */ - public void setPreserveTime( boolean pt ) - { - m_Ptime = pt; - } - - /** - * Set rename hijacked files status - * - * @param ren the status to set the flag to - */ - public void setRename( boolean ren ) - { - m_Rename = ren; - } - - /** - * Get current time status - * - * @return boolean containing status of current time flag - */ - public boolean getCurrentTime() - { - return m_Ctime; - } - - /** - * Get graphical flag status - * - * @return boolean containing status of graphical flag - */ - public boolean getGraphical() - { - return m_Graphical; - } - - /** - * Get log file - * - * @return String containing the path to the log file - */ - public String getLog() - { - return m_Log; - } - - /** - * Get overwrite hijacked files status - * - * @return boolean containing status of overwrite flag - */ - public boolean getOverwrite() - { - return m_Overwrite; - } - - /** - * Get preserve time status - * - * @return boolean containing status of preserve time flag - */ - public boolean getPreserveTime() - { - return m_Ptime; - } - - /** - * Get rename hijacked files status - * - * @return boolean containing status of rename flag - */ - public boolean getRename() - { - return m_Rename; - } - - /** - * Executes the task.

- * - * Builds a command line to execute cleartool and then calls Exec's run - * method to execute the command line. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - Commandline commandLine = new Commandline(); - - // Default the viewpath to basedir if it is not specified - if( getViewPath() == null ) - { - setViewPath( getBaseDirectory().getPath() ); - } - - // build the command line from what we got the format is - // cleartool update [options...] [viewpath ...] - // as specified in the CLEARTOOL.EXE help - commandLine.setExecutable( getClearToolCommand() ); - commandLine.addArgument( COMMAND_UPDATE ); - - // Check the command line options - checkOptions( commandLine ); - - run( commandLine ); - } - - /** - * Get the 'log' command - * - * @param cmd Description of Parameter - */ - private void getLogCommand( ArgumentList cmd ) - { - if( getLog() == null ) - { - return; - } - else - { - /* - * Had to make two separate commands here because if a space is - * inserted between the flag and the value, it is treated as a - * Windows filename with a space and it is enclosed in double - * quotes ("). This breaks clearcase. - */ - cmd.addArgument( FLAG_LOG ); - cmd.addArgument( getLog() ); - } - } - - /** - * Check the command line options. - * - * @param cmd Description of Parameter - */ - private void checkOptions( ArgumentList cmd ) - { - // ClearCase items - if( getGraphical() ) - { - // -graphical - cmd.addArgument( FLAG_GRAPHICAL ); - } - else - { - if( getOverwrite() ) - { - // -overwrite - cmd.addArgument( FLAG_OVERWRITE ); - } - else - { - if( getRename() ) - { - // -rename - cmd.addArgument( FLAG_RENAME ); - } - else - { - // -noverwrite - cmd.addArgument( FLAG_NOVERWRITE ); - } - } - - if( getCurrentTime() ) - { - // -ctime - cmd.addArgument( FLAG_CURRENTTIME ); - } - else - { - if( getPreserveTime() ) - { - // -ptime - cmd.addArgument( FLAG_PRESERVETIME ); - } - } - - // -log logname - getLogCommand( cmd ); - } - - // viewpath - cmd.addArgument( getViewPath() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/ClearCase.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/ClearCase.java deleted file mode 100644 index 0967e25d9..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/clearcase/ClearCase.java +++ /dev/null @@ -1,114 +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.todo.taskdefs.clearcase; - -import java.io.File; -import org.apache.aut.nativelib.ExecManager; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.Execute; -import org.apache.tools.todo.types.Commandline; - -/** - * A base class for creating tasks for executing commands on ClearCase.

- * - * The class extends the 'exec' task as it operates by executing the cleartool - * program supplied with ClearCase. By default the task expects the cleartool - * executable to be in the path, * you can override this be specifying the - * cleartooldir attribute.

- * - * This class provides set and get methods for the 'viewpath' attribute. It also - * contains constants for the flags that can be passed to cleartool.

- * - * @author Curtis White - */ -public abstract class ClearCase extends AbstractTask -{ - - /** - * Constant for the thing to execute - */ - private final static String CLEARTOOL_EXE = "cleartool"; - - /** - * The 'Update' command - */ - public final static String COMMAND_UPDATE = "update"; - /** - * The 'Checkout' command - */ - public final static String COMMAND_CHECKOUT = "checkout"; - /** - * The 'Checkin' command - */ - public final static String COMMAND_CHECKIN = "checkin"; - /** - * The 'UndoCheckout' command - */ - public final static String COMMAND_UNCHECKOUT = "uncheckout"; - private String m_ClearToolDir = ""; - private String m_viewPath = null; - - /** - * Set the directory where the cleartool executable is located - * - * @param dir the directory containing the cleartool executable - */ - public final void setClearToolDir( final File dir ) - { - m_ClearToolDir = dir.toString(); - } - - /** - * Set the path to the item in a clearcase view to operate on - * - * @param viewPath Path to the view directory or file - */ - public final void setViewPath( String viewPath ) - { - m_viewPath = viewPath; - } - - /** - * Get the path to the item in a clearcase view - * - * @return m_viewPath - */ - public String getViewPath() - { - return m_viewPath; - } - - /** - * Builds and returns the command string to execute cleartool - * - * @return String containing path to the executable - */ - protected final String getClearToolCommand() - { - String toReturn = m_ClearToolDir; - if( !toReturn.equals( "" ) && !toReturn.endsWith( "/" ) ) - { - toReturn += "/"; - } - - toReturn += CLEARTOOL_EXE; - - return toReturn; - } - - protected void run( Commandline cmd ) - throws TaskException - { - final Execute exe = new Execute(); - exe.setCommandline( cmd ); - exe.execute( getContext() ); - } - -} - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/AbstractMetamataTask.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/AbstractMetamataTask.java deleted file mode 100644 index 865f5b1c2..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/AbstractMetamataTask.java +++ /dev/null @@ -1,343 +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.todo.taskdefs.metamata; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Random; -import org.apache.myrmidon.api.AbstractTask; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.java.ExecuteJava; -import org.apache.tools.todo.types.Argument; -import org.apache.tools.todo.types.DirectoryScanner; -import org.apache.myrmidon.framework.file.Path; -import org.apache.myrmidon.framework.FileSet; -import org.apache.tools.todo.types.ScannerUtil; - -/** - * Somewhat abstract framework to be used for other metama 2.0 tasks. This - * should include, audit, metrics, cover and mparse. For more information, visit - * the website at www.metamata.com - * - * @author Stephane Bailliez - */ -public abstract class AbstractMetamataTask - extends AbstractTask -{ - /** - * the path to the source file - */ - private Path m_sourcePath = new Path(); - - /** - * Metamata home directory. It will be passed as a metamata.home - * property and should normally matches the environment property - * META_HOME set by the Metamata installer. - */ - private File m_metamataHome; - - /** - * the command line used to run MAudit - */ - private ExecuteJava m_exe = new ExecuteJava(); - - /** - * the set of files to be audited - */ - private ArrayList m_fileSets = new ArrayList(); - - /** - * the options file where are stored the command line options - */ - private File m_optionsFile; - - // this is used to keep track of which files were included. It will - // be set when calling scanFileSets(); - private Hashtable m_includedFiles; - - /** - * initialize the task with the classname of the task to run - * - * @param className Description of Parameter - */ - protected AbstractMetamataTask( final String className ) - { - m_exe.setClassName( className ); - } - - /** - * convenient method for JDK 1.1. Will copy all elements from src to dest - * - * @param dest The feature to be added to the AllArrayList attribute - * @param files The feature to be added to the AllArrayList attribute - */ - protected static final void addAllArrayList( ArrayList dest, Iterator files ) - { - while( files.hasNext() ) - { - dest.add( files.next() ); - } - } - - protected static final File createTmpFile() - { - // must be compatible with JDK 1.1 !!!! - final long rand = ( new Random( System.currentTimeMillis() ) ).nextLong(); - File file = new File( "metamata" + rand + ".tmp" ); - return file; - } - - /** - * -mx or -Xmx depending on VM version - * - * @param max The new Maxmemory value - */ - public void setMaxmemory( final String max ) - { - m_exe.setMaxMemory( max ); - } - - /** - * the metamata.home property to run all tasks. - */ - public void setMetamatahome( final File metamataHome ) - { - m_metamataHome = metamataHome; - } - - /** - * The java files or directory to be audited - */ - public void addFileSet( final FileSet fileSet ) - { - m_fileSets.add( fileSet ); - } - - /** - * user classpath - */ - public void addClasspath( final Path path ) - { - m_exe.getClassPath().add( path ); - } - - /** - * Creates a nested jvmarg element. - */ - public void addJvmarg( final Argument argument ) - { - m_exe.getVmArguments().addArgument( argument ); - } - - /** - * create the source path for this task - */ - public void addSourcepath( final Path path ) - { - m_sourcePath.add( path ); - } - - /** - * execute the command line - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - try - { - setUp(); - execute0(); - } - finally - { - cleanUp(); - } - } - - /** - * check the options and build the command line - */ - protected void setUp() - throws TaskException - { - validate(); - - // set the classpath as the jar file - File jar = getMetamataJar( m_metamataHome ); - final Path classPath = m_exe.getClassPath(); - classPath.addLocation( jar ); - - // set the metamata.home property - m_exe.getSysProperties().addVariable( "metamata.home", m_metamataHome.getAbsolutePath() ); - - // retrieve all the files we want to scan - m_includedFiles = scanFileSets(); - getContext().debug( m_includedFiles.size() + " files added for audit" ); - - // write all the options to a temp file and use it ro run the process - ArrayList options = getOptions(); - m_optionsFile = createTmpFile(); - generateOptionsFile( m_optionsFile, options ); - m_exe.getArguments().addArgument( "-arguments" ); - m_exe.getArguments().addArgument( m_optionsFile ); - } - - /** - * return the location of the jar file used to run - */ - protected final File getMetamataJar( File home ) - { - return new File( new File( home.getAbsolutePath() ), "lib/metamata.jar" ); - } - - protected Hashtable getFileMapping() - { - return m_includedFiles; - } - - /** - * return all options of the command line as string elements - */ - protected abstract ArrayList getOptions() - throws TaskException; - - /** - * validate options set - * - * @exception TaskException Description of Exception - */ - protected void validate() - throws TaskException - { - // do some validation first - if( m_metamataHome == null || !m_metamataHome.exists() ) - { - throw new TaskException( "'metamatahome' must point to Metamata home directory." ); - } - m_metamataHome = getContext().resolveFile( m_metamataHome.getPath() ); - File jar = getMetamataJar( m_metamataHome ); - if( !jar.exists() ) - { - throw new TaskException( jar + " does not exist. Check your metamata installation." ); - } - } - - /** - * clean up all the mess that we did with temporary objects - */ - protected void cleanUp() - throws TaskException - { - if( m_optionsFile != null ) - { - m_optionsFile.delete(); - m_optionsFile = null; - } - } - - /** - * execute the process with a specific handler - */ - protected void execute0() - throws TaskException - { - m_exe.executeForked( getContext() ); - } - - protected void generateOptionsFile( File tofile, ArrayList options ) - throws TaskException - { - FileWriter fw = null; - try - { - fw = new FileWriter( tofile ); - PrintWriter pw = new PrintWriter( fw ); - final int size = options.size(); - for( int i = 0; i < size; i++ ) - { - pw.println( options.get( i ) ); - } - pw.flush(); - } - catch( IOException e ) - { - throw new TaskException( "Error while writing options file " + tofile, e ); - } - finally - { - if( fw != null ) - { - try - { - fw.close(); - } - catch( IOException ignored ) - { - } - } - } - } - - /** - * @return the list of .java files (as their absolute path) that should be - * audited. - */ - protected Hashtable scanFileSets() - throws TaskException - { - Hashtable files = new Hashtable(); - for( int i = 0; i < m_fileSets.size(); i++ ) - { - FileSet fs = (FileSet)m_fileSets.get( i ); - DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs ); - ds.scan(); - String[] f = ds.getIncludedFiles(); - getContext().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); - for( int j = 0; j < f.length; j++ ) - { - String pathname = f[ j ]; - if( pathname.endsWith( ".java" ) ) - { - File file = new File( ds.getBasedir(), pathname ); - // file = project.resolveFile(file.getAbsolutePath()); - String classname = pathname.substring( 0, pathname.length() - ".java".length() ); - classname = classname.replace( File.separatorChar, '.' ); - files.put( file.getAbsolutePath(), classname );// it's a java file, add it. - } - } - } - return files; - } - - protected ArrayList getFileSets() - { - return m_fileSets; - } - - protected Hashtable getIncludedFiles() - { - return m_includedFiles; - } - - protected Path getClassPath() - { - return m_exe.getClassPath(); - } - - protected Path getSourcePath() - { - return m_sourcePath; - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java deleted file mode 100644 index 7add67e6c..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java +++ /dev/null @@ -1,201 +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.todo.taskdefs.metamata; - -import java.io.File; -import java.util.ArrayList; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.file.Path; -import org.apache.myrmidon.framework.file.FileListUtil; - -/** - * Metamata Audit evaluates Java code for programming errors, weaknesses, and - * style violation.

- * - * Metamata Audit exists in three versions: - *