http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java index 0eaf09a..afcdcbc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java @@ -94,6 +94,56 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCCheckout extends ClearCase { + /** + * -reserved flag -- check out the file as reserved + */ + public static final String FLAG_RESERVED = "-reserved"; + + /** + * -reserved flag -- check out the file as unreserved + */ + public static final String FLAG_UNRESERVED = "-unreserved"; + + /** + * -out flag -- create a writable file under a different filename + */ + public static final String FLAG_OUT = "-out"; + + /** + * -ndata flag -- checks out the file but does not create an editable file containing its data + */ + public static final String FLAG_NODATA = "-ndata"; + + /** + * -branch flag -- checks out the file on a specified branch + */ + public static final String FLAG_BRANCH = "-branch"; + + /** + * -version flag -- allows checkout of a version that is not main latest + */ + public static final String FLAG_VERSION = "-version"; + + /** + * -nwarn flag -- suppresses warning messages + */ + public static final String FLAG_NOWARN = "-nwarn"; + + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + private boolean mReserved = true; private String mOut = null; private boolean mNdata = false; @@ -111,10 +161,10 @@ public class CCCheckout extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -142,10 +192,10 @@ public class CCCheckout extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -154,7 +204,6 @@ public class CCCheckout extends ClearCase { */ private boolean lsCheckout() { Commandline cmdl = new Commandline(); - String result; // build the command line from what we got the format is // cleartool lsco [options...] [viewpath ...] @@ -167,12 +216,11 @@ public class CCCheckout extends ClearCase { // viewpath cmdl.createArgument().setValue(getViewPath()); - result = runS(cmdl); - - // System.out.println( "lsCheckout: " + result ); + String result = runS(cmdl); - return (result != null && result.length() > 0) ? true : false; + return (result != null && result.length() > 0); } + /** * Check the command line options. */ @@ -189,23 +237,17 @@ public class CCCheckout extends ClearCase { if (getOut() != null) { // -out getOutCommand(cmd); - } else { - if (getNoData()) { - // -ndata - cmd.createArgument().setValue(FLAG_NODATA); - } - + } else if (getNoData()) { + // -ndata + cmd.createArgument().setValue(FLAG_NODATA); } if (getBranch() != null) { // -branch getBranchCommand(cmd); - } else { - if (getVersion()) { - // -version - cmd.createArgument().setValue(FLAG_VERSION); - } - + } else if (getVersion()) { + // -version + cmd.createArgument().setValue(FLAG_VERSION); } if (getNoWarn()) { @@ -216,20 +258,15 @@ public class CCCheckout extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } // viewpath cmd.createArgument().setValue(getViewPath()); - - // Print out info about the notco option - // System.out.println( "Notco: " + (getNotco() ? "yes" : "no") ); } /** @@ -270,7 +307,6 @@ public class CCCheckout extends ClearCase { return mNotco; } - /** * Creates a writable file under a different filename. * @@ -434,7 +470,6 @@ public class CCCheckout extends ClearCase { } } - /** * Get the 'comment' command * @@ -471,46 +506,5 @@ public class CCCheckout extends ClearCase { } } - /** - * -reserved flag -- check out the file as reserved - */ - public static final String FLAG_RESERVED = "-reserved"; - /** - * -reserved flag -- check out the file as unreserved - */ - public static final String FLAG_UNRESERVED = "-unreserved"; - /** - * -out flag -- create a writable file under a different filename - */ - public static final String FLAG_OUT = "-out"; - /** - * -ndata flag -- checks out the file but does not create an editable file containing its data - */ - public static final String FLAG_NODATA = "-ndata"; - /** - * -branch flag -- checks out the file on a specified branch - */ - public static final String FLAG_BRANCH = "-branch"; - /** - * -version flag -- allows checkout of a version that is not main latest - */ - public static final String FLAG_VERSION = "-version"; - /** - * -nwarn flag -- suppresses warning messages - */ - public static final String FLAG_NOWARN = "-nwarn"; - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - }
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java index c273554..c2e36e9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java @@ -18,19 +18,19 @@ package org.apache.tools.ant.taskdefs.optional.clearcase; +import java.util.Optional; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.types.Commandline; -/** +/* * TODO: * comment field doesn't include all options yet */ - - /** * Performs a ClearCase Lock command. * @@ -85,6 +85,31 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCLock extends ClearCase { + /** + * -replace flag -- replace existing lock on object(s) + */ + public static final String FLAG_REPLACE = "-replace"; + + /** + * -nusers flag -- list of users to exclude from lock + */ + public static final String FLAG_NUSERS = "-nusers"; + + /** + * -obsolete flag -- mark locked object as obsolete + */ + public static final String FLAG_OBSOLETE = "-obsolete"; + + /** + * -comment flag -- method to use for commenting events + */ + public static final String FLAG_COMMENT = "-comment"; + + /** + * -pname flag -- pathname to lock + */ + public static final String FLAG_PNAME = "-pname"; + private boolean mReplace = false; private boolean mObsolete = false; private String mComment = null; @@ -99,10 +124,10 @@ public class CCLock extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -125,17 +150,17 @@ public class CCLock extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getOpType(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } /** * Check the command line options. */ -private void checkOptions(Commandline cmd) { + private void checkOptions(Commandline cmd) { // ClearCase items if (getReplace()) { // -replace @@ -150,15 +175,15 @@ private void checkOptions(Commandline cmd) { getCommentCommand(cmd); if (getObjselect() == null && getPname() == null) { - throw new BuildException("Should select either an element " - + "(pname) or an object (objselect)"); + throw new BuildException( + "Should select either an element (pname) or an object (objselect)"); } getPnameCommand(cmd); // object selector if (getObjselect() != null) { cmd.createArgument().setValue(getObjselect()); } -} + } /** * If true, replace an existing lock. @@ -289,15 +314,14 @@ private void checkOptions(Commandline cmd) { private void getNusersCommand(Commandline cmd) { if (getNusers() == 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.createArgument().setValue(FLAG_NUSERS); - cmd.createArgument().setValue(getNusers()); } + /* 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.createArgument().setValue(FLAG_NUSERS); + cmd.createArgument().setValue(getNusers()); } /** @@ -309,15 +333,14 @@ private void checkOptions(Commandline cmd) { private void getCommentCommand(Commandline cmd) { if (getComment() == 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.createArgument().setValue(FLAG_COMMENT); - cmd.createArgument().setValue(getComment()); } + /* 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.createArgument().setValue(FLAG_COMMENT); + cmd.createArgument().setValue(getComment()); } /** @@ -329,15 +352,14 @@ private void checkOptions(Commandline cmd) { private void getPnameCommand(Commandline cmd) { if (getPname() == 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.createArgument().setValue(FLAG_PNAME); - cmd.createArgument().setValue(getPname()); } + /* 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.createArgument().setValue(FLAG_PNAME); + cmd.createArgument().setValue(getPname()); } /** @@ -346,33 +368,7 @@ private void checkOptions(Commandline cmd) { * @return String containing the object/pname being worked on */ private String getOpType() { - - if (getPname() != null) { - return getPname(); - } else { - return getObjselect(); - } + return Optional.ofNullable(getPname()).orElseGet(this::getObjselect); } - /** - * -replace flag -- replace existing lock on object(s) - */ - public static final String FLAG_REPLACE = "-replace"; - /** - * -nusers flag -- list of users to exclude from lock - */ - public static final String FLAG_NUSERS = "-nusers"; - /** - * -obsolete flag -- mark locked object as obsolete - */ - public static final String FLAG_OBSOLETE = "-obsolete"; - /** - * -comment flag -- method to use for commenting events - */ - public static final String FLAG_COMMENT = "-comment"; - /** - * -pname flag -- pathname to lock - */ - public static final String FLAG_PNAME = "-pname"; } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java index 128ea16..c428af0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java @@ -83,6 +83,31 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCMkattr extends ClearCase { + /** + * -replace flag -- replace the existing value of the attribute + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -recurse flag -- process all subdirectories + */ + public static final String FLAG_RECURSE = "-recurse"; + /** + * -version flag -- attach attribute to specified version + */ + public static final String FLAG_VERSION = "-version"; + /** + * -c flag -- comment to attach to the element + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + private boolean mReplace = false; private boolean mRecurse = false; private String mVersion = null; @@ -98,10 +123,10 @@ public class CCMkattr extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Check for required attributes if (getTypeName() == null) { @@ -131,10 +156,10 @@ public class CCMkattr extends ClearCase { // For debugging // System.out.println(commandLine.toString()); - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -161,13 +186,11 @@ public class CCMkattr extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } if (getTypeName() != null) { @@ -182,7 +205,6 @@ public class CCMkattr extends ClearCase { cmd.createArgument().setValue(getViewPath()); } - /** * Set the replace flag * @@ -309,7 +331,6 @@ public class CCMkattr extends ClearCase { return mTypeValue; } - /** * Get the 'version' command * @@ -397,29 +418,4 @@ public class CCMkattr extends ClearCase { } } - /** - * -replace flag -- replace the existing value of the attribute - */ - public static final String FLAG_REPLACE = "-replace"; - /** - * -recurse flag -- process all subdirectories - */ - public static final String FLAG_RECURSE = "-recurse"; - /** - * -version flag -- attach attribute to specified version - */ - public static final String FLAG_VERSION = "-version"; - /** - * -c flag -- comment to attach to the element - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java index 82c9600..94cb5a1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java @@ -80,6 +80,36 @@ previous baseline.</td> * */ public class CCMkbl extends ClearCase { + + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -identical flag -- allows the file to be checked in even if it is identical to the original + */ + public static final String FLAG_IDENTICAL = "-identical"; + /** + * -incremental flag -- baseline to be created is incremental + */ + public static final String FLAG_INCREMENTAL = "-incremental"; + /** + * -full flag -- baseline to be created is full + */ + public static final String FLAG_FULL = "-full"; + /** + * -nlabel -- baseline to be created without a label + */ + public static final String FLAG_NLABEL = "-nlabel"; + private String mComment = null; private String mCfile = null; private String mBaselineRootName = null; @@ -88,7 +118,6 @@ public class CCMkbl extends ClearCase { private boolean mFull = false; private boolean mNlabel = false; - /** * Executes the task. * <p> @@ -96,10 +125,10 @@ public class CCMkbl extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -118,14 +147,13 @@ public class CCMkbl extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getBaselineRootName(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } - /** * Check the command line options. */ @@ -133,13 +161,11 @@ public class CCMkbl extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } if (getIdentical()) { @@ -162,10 +188,8 @@ public class CCMkbl extends ClearCase { // baseline_root_name cmd.createArgument().setValue(getBaselineRootName()); - } - /** * Set comment string * @@ -221,8 +245,6 @@ public class CCMkbl extends ClearCase { } /** - - /** * Set the nowarn flag * * @param nwarn the status to set the flag to @@ -294,7 +316,6 @@ public class CCMkbl extends ClearCase { return mNlabel; } - /** * Get the 'comment' command * @@ -331,35 +352,4 @@ public class CCMkbl extends ClearCase { } } - - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - /** - * -identical flag -- allows the file to be checked in even if it is identical to the original - */ - public static final String FLAG_IDENTICAL = "-identical"; - /** - * -incremental flag -- baseline to be created is incremental - */ - public static final String FLAG_INCREMENTAL = "-incremental"; - /** - * -full flag -- baseline to be created is full - */ - public static final String FLAG_FULL = "-full"; - /** - * -nlabel -- baseline to be created without a label - */ - public static final String FLAG_NLABEL = "-nlabel"; - - } http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java index 4c89539..09af65e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java @@ -63,6 +63,23 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCMkdir extends ClearCase { + /** + * -c flag -- comment to attach to the directory + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the directory + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -nco flag -- do not checkout element after creation + */ + public static final String FLAG_NOCHECKOUT = "-nco"; + private String mComment = null; private String mCfile = null; private boolean mNoco = false; @@ -74,10 +91,10 @@ public class CCMkdir extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -96,10 +113,10 @@ public class CCMkdir extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -110,13 +127,11 @@ public class CCMkdir extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } if (getNoCheckout()) { // -nco @@ -180,7 +195,6 @@ public class CCMkdir extends ClearCase { return mNoco; } - /** * Get the 'comment' command * @@ -217,21 +231,4 @@ public class CCMkdir extends ClearCase { } } - /** - * -c flag -- comment to attach to the directory - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the directory - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - /** - * -nco flag -- do not checkout element after creation - */ - public static final String FLAG_NOCHECKOUT = "-nco"; } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java index 94faa5a..72a736a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java @@ -88,6 +88,43 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCMkelem extends ClearCase { + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -nwarn flag -- suppresses warning messages + */ + public static final String FLAG_NOWARN = "-nwarn"; + /** + * -ptime flag -- preserves the modification time on checkin + */ + public static final String FLAG_PRESERVETIME = "-ptime"; + /** + * -nco flag -- do not checkout element after creation + */ + public static final String FLAG_NOCHECKOUT = "-nco"; + /** + * -ci flag -- checkin element after creation + */ + public static final String FLAG_CHECKIN = "-ci"; + /** + * -master flag -- change mastership of main branch to current site + */ + public static final String FLAG_MASTER = "-master"; + /** + * -eltype flag -- element type to use during creation + */ + public static final String FLAG_ELTYPE = "-eltype"; + private String mComment = null; private String mCfile = null; private boolean mNwarn = false; @@ -104,10 +141,10 @@ public class CCMkelem extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -126,14 +163,13 @@ public class CCMkelem extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } - /** * Check the command line options. */ @@ -141,13 +177,11 @@ public class CCMkelem extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } if (getNoWarn()) { @@ -329,7 +363,6 @@ public class CCMkelem extends ClearCase { return mEltype; } - /** * Get the 'comment' command * @@ -384,41 +417,4 @@ public class CCMkelem extends ClearCase { } } - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - /** - * -nwarn flag -- suppresses warning messages - */ - public static final String FLAG_NOWARN = "-nwarn"; - /** - * -ptime flag -- preserves the modification time on checkin - */ - public static final String FLAG_PRESERVETIME = "-ptime"; - /** - * -nco flag -- do not checkout element after creation - */ - public static final String FLAG_NOCHECKOUT = "-nco"; - /** - * -ci flag -- checkin element after creation - */ - public static final String FLAG_CHECKIN = "-ci"; - /** - * -master flag -- change mastership of main branch to current site - */ - public static final String FLAG_MASTER = "-master"; - /** - * -eltype flag -- element type to use during creation - */ - public static final String FLAG_ELTYPE = "-eltype"; } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java index e3d288d..c75dc6d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java @@ -82,6 +82,31 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCMklabel extends ClearCase { + /** + * -replace flag -- replace another label of the same type + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -recurse flag -- process all subdirectories + */ + public static final String FLAG_RECURSE = "-recurse"; + /** + * -version flag -- attach label to specified version + */ + public static final String FLAG_VERSION = "-version"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + private boolean mReplace = false; private boolean mRecurse = false; private String mVersion = null; @@ -97,10 +122,10 @@ public class CCMklabel extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Check for required attributes if (getTypeName() == null) { @@ -124,10 +149,10 @@ public class CCMklabel extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -154,13 +179,11 @@ public class CCMklabel extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } if (getTypeName() != null) { @@ -172,7 +195,6 @@ public class CCMklabel extends ClearCase { cmd.createArgument().setValue(getViewPath()); } - /** * Set the replace flag * @@ -299,7 +321,6 @@ public class CCMklabel extends ClearCase { return mVOB; } - /** * Get the 'version' command * @@ -361,10 +382,9 @@ public class CCMklabel extends ClearCase { * without the type-name */ private void getTypeCommand(Commandline cmd) { - String typenm = null; if (getTypeName() != null) { - typenm = getTypeName(); + String typenm = getTypeName(); if (getVOB() != null) { typenm += "@" + getVOB(); } @@ -372,31 +392,4 @@ public class CCMklabel extends ClearCase { } } - - /** - * -replace flag -- replace another label of the same type - */ - public static final String FLAG_REPLACE = "-replace"; - /** - * -recurse flag -- process all subdirectories - */ - public static final String FLAG_RECURSE = "-recurse"; - /** - * -version flag -- attach label to specified version - */ - public static final String FLAG_VERSION = "-version"; - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java index 7bb7192..87e2137 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java @@ -94,6 +94,39 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCMklbtype extends ClearCase { + /** + * -replace flag -- replace existing label definition of the same type + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -global flag -- creates a label type that is global to the VOB or to VOBs that use this VOB + */ + public static final String FLAG_GLOBAL = "-global"; + /** + * -ordinary flag -- creates a label type that can be used only in the current VOB + */ + public static final String FLAG_ORDINARY = "-ordinary"; + /** + * -pbranch flag -- allows label type to be used once per branch + */ + public static final String FLAG_PBRANCH = "-pbranch"; + /** + * -shared flag -- sets the way mastership is checked by ClearCase + */ + public static final String FLAG_SHARED = "-shared"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + private String mTypeName = null; private String mVOB = null; private String mComment = null; @@ -111,9 +144,9 @@ public class CCMklbtype extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); - int result = 0; // Check for required attributes if (getTypeName() == null) { @@ -132,14 +165,13 @@ public class CCMklbtype extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getTypeSpecifier(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } - /** * Check the command line options. */ @@ -152,11 +184,9 @@ public class CCMklbtype extends ClearCase { if (getOrdinary()) { // -ordinary cmd.createArgument().setValue(FLAG_ORDINARY); - } else { - if (getGlobal()) { - // -global - cmd.createArgument().setValue(FLAG_GLOBAL); - } + } else if (getGlobal()) { + // -global + cmd.createArgument().setValue(FLAG_GLOBAL); } if (getPbranch()) { @@ -172,20 +202,17 @@ public class CCMklbtype extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } // type-name@vob cmd.createArgument().setValue(getTypeSpecifier()); } - /** * Set type-name string * @@ -348,7 +375,6 @@ public class CCMklbtype extends ClearCase { return mCfile; } - /** * Get the 'comment' command * @@ -392,49 +418,11 @@ public class CCMklbtype extends ClearCase { * specified, otherwise an empty string */ private String getTypeSpecifier() { - String typenm = null; - - typenm = getTypeName(); + String typenm = getTypeName(); if (getVOB() != null) { typenm += "@" + getVOB(); } - return typenm; } - - /** - * -replace flag -- replace existing label definition of the same type - */ - public static final String FLAG_REPLACE = "-replace"; - /** - * -global flag -- creates a label type that is global to the VOB or to VOBs that use this VOB - */ - public static final String FLAG_GLOBAL = "-global"; - /** - * -ordinary flag -- creates a label type that can be used only in the current VOB - */ - public static final String FLAG_ORDINARY = "-ordinary"; - /** - * -pbranch flag -- allows label type to be used once per branch - */ - public static final String FLAG_PBRANCH = "-pbranch"; - /** - * -shared flag -- sets the way mastership is checked by ClearCase - */ - public static final String FLAG_SHARED = "-shared"; - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java index cef0c3a..c699de1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java @@ -86,6 +86,31 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCRmtype extends ClearCase { + /** + * -ignore flag -- ignore pre-trigger operations when removing a trigger type + */ + public static final String FLAG_IGNORE = "-ignore"; + /** + * -rmall flag -- removes all instances of a type and the type object itself + */ + public static final String FLAG_RMALL = "-rmall"; + /** + * -force flag -- suppresses confirmation prompts + */ + public static final String FLAG_FORCE = "-force"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + private String mTypeKind = null; private String mTypeName = null; private String mVOB = null; @@ -101,9 +126,9 @@ public class CCRmtype extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); - int result = 0; // Check for required attributes if (getTypeKind() == null) { @@ -125,14 +150,13 @@ public class CCRmtype extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getTypeSpecifier(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } - /** * Check the command line options. */ @@ -149,13 +173,11 @@ public class CCRmtype extends ClearCase { if (getComment() != null) { // -c getCommentCommand(cmd); + } else if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); } else { - if (getCommentFile() != null) { - // -cfile - getCommentFileCommand(cmd); - } else { - cmd.createArgument().setValue(FLAG_NOCOMMENT); - } + cmd.createArgument().setValue(FLAG_NOCOMMENT); } // type-kind:type-name @@ -297,10 +319,9 @@ public class CCRmtype extends ClearCase { private String getTypeSpecifier() { String tkind = getTypeKind(); String tname = getTypeName(); - String typeSpec = null; // Return the type-selector - typeSpec = tkind + ":" + tname; + String typeSpec = tkind + ":" + tname; if (getVOB() != null) { typeSpec += "@" + getVOB(); } @@ -343,31 +364,4 @@ public class CCRmtype extends ClearCase { } } - - /** - * -ignore flag -- ignore pre-trigger operations when removing a trigger type - */ - public static final String FLAG_IGNORE = "-ignore"; - /** - * -rmall flag -- removes all instances of a type and the type object itself - */ - public static final String FLAG_RMALL = "-rmall"; - /** - * -force flag -- suppresses confirmation prompts - */ - public static final String FLAG_FORCE = "-force"; - /** - * -c flag -- comment to attach to the file - */ - public static final String FLAG_COMMENT = "-c"; - /** - * -cfile flag -- file containing a comment to attach to the file - */ - public static final String FLAG_COMMENTFILE = "-cfile"; - /** - * -nc flag -- no comment is specified - */ - public static final String FLAG_NOCOMMENT = "-nc"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java index 3c00e1a..266c098 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java @@ -53,6 +53,15 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCUnCheckout extends ClearCase { + /** + * -keep flag -- keep a copy of the file with .keep extension + */ + public static final String FLAG_KEEPCOPY = "-keep"; + /** + * -rm flag -- remove the copy of the file + */ + public static final String FLAG_RM = "-rm"; + private boolean mKeep = false; /** @@ -62,10 +71,10 @@ public class CCUnCheckout extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -84,14 +93,13 @@ public class CCUnCheckout extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } - /** * Check the command line options. */ @@ -127,15 +135,4 @@ public class CCUnCheckout extends ClearCase { return mKeep; } - - /** - * -keep flag -- keep a copy of the file with .keep extension - */ - public static final String FLAG_KEEPCOPY = "-keep"; - /** - * -rm flag -- remove the copy of the file - */ - public static final String FLAG_RM = "-rm"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java index 4ca3e89..dbb5f12 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java @@ -18,12 +18,14 @@ package org.apache.tools.ant.taskdefs.optional.clearcase; +import java.util.Optional; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.types.Commandline; -/** +/* * TODO: * comment field doesn't include all options yet */ @@ -68,6 +70,15 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCUnlock extends ClearCase { + /** + * -comment flag -- method to use for commenting events + */ + public static final String FLAG_COMMENT = "-comment"; + /** + * -pname flag -- pathname to lock + */ + public static final String FLAG_PNAME = "-pname"; + private String mComment = null; private String mPname = null; @@ -78,10 +89,10 @@ public class CCUnlock extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -104,10 +115,10 @@ public class CCUnlock extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getOpType(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -119,8 +130,8 @@ public class CCUnlock extends ClearCase { getCommentCommand(cmd); if (getObjSelect() == null && getPname() == null) { - throw new BuildException("Should select either an element " - + "(pname) or an object (objselect)"); + throw new BuildException( + "Should select either an element (pname) or an object (objselect)"); } getPnameCommand(cmd); // object selector @@ -203,15 +214,14 @@ public class CCUnlock extends ClearCase { private void getCommentCommand(Commandline cmd) { if (getComment() == 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.createArgument().setValue(FLAG_COMMENT); - cmd.createArgument().setValue(getComment()); } + /* 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.createArgument().setValue(FLAG_COMMENT); + cmd.createArgument().setValue(getComment()); } /** @@ -223,15 +233,14 @@ public class CCUnlock extends ClearCase { private void getPnameCommand(Commandline cmd) { if (getPname() == 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.createArgument().setValue(FLAG_PNAME); - cmd.createArgument().setValue(getPname()); } + /* 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.createArgument().setValue(FLAG_PNAME); + cmd.createArgument().setValue(getPname()); } /** @@ -240,21 +249,7 @@ public class CCUnlock extends ClearCase { * @return String containing the object/pname being worked on */ private String getOpType() { - - if (getPname() != null) { - return getPname(); - } else { - return getObjSelect(); - } + return Optional.ofNullable(getPname()).orElseGet(this::getObjSelect); } - /** - * -comment flag -- method to use for commenting events - */ - public static final String FLAG_COMMENT = "-comment"; - /** - * -pname flag -- pathname to lock - */ - public static final String FLAG_PNAME = "-pname"; } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java index 712efdc..96afe8d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java @@ -80,6 +80,35 @@ import org.apache.tools.ant.types.Commandline; * */ public class CCUpdate extends ClearCase { + /** + * -graphical flag -- display graphical dialog during update operation + */ + public static final String FLAG_GRAPHICAL = "-graphical"; + /** + * -log flag -- file to log status to + */ + public static final String FLAG_LOG = "-log"; + /** + * -overwrite flag -- overwrite hijacked files + */ + public static final String FLAG_OVERWRITE = "-overwrite"; + /** + * -noverwrite flag -- do not overwrite hijacked files + */ + public static final String FLAG_NOVERWRITE = "-noverwrite"; + /** + * -rename flag -- rename hijacked files with .keep extension + */ + public static final String FLAG_RENAME = "-rename"; + /** + * -ctime flag -- modified time is written as the current time + */ + public static final String FLAG_CURRENTTIME = "-ctime"; + /** + * -ptime flag -- modified time is written as the VOB time + */ + public static final String FLAG_PRESERVETIME = "-ptime"; + private boolean mGraphical = false; private boolean mOverwrite = false; private boolean mRename = false; @@ -94,10 +123,10 @@ public class CCUpdate extends ClearCase { * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ + @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); - int result = 0; // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { @@ -120,10 +149,10 @@ public class CCUpdate extends ClearCase { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } - result = run(commandLine); + int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { - String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException(msg, getLocation()); + throw new BuildException("Failed executing: " + commandLine, + getLocation()); } } @@ -139,24 +168,20 @@ public class CCUpdate extends ClearCase { if (getOverwrite()) { // -overwrite cmd.createArgument().setValue(FLAG_OVERWRITE); + } else if (getRename()) { + // -rename + cmd.createArgument().setValue(FLAG_RENAME); } else { - if (getRename()) { - // -rename - cmd.createArgument().setValue(FLAG_RENAME); - } else { - // -noverwrite - cmd.createArgument().setValue(FLAG_NOVERWRITE); - } + // -noverwrite + cmd.createArgument().setValue(FLAG_NOVERWRITE); } if (getCurrentTime()) { // -ctime cmd.createArgument().setValue(FLAG_CURRENTTIME); - } else { - if (getPreserveTime()) { - // -ptime - cmd.createArgument().setValue(FLAG_PRESERVETIME); - } + } else if (getPreserveTime()) { + // -ptime + cmd.createArgument().setValue(FLAG_PRESERVETIME); } // -log logname @@ -278,7 +303,6 @@ public class CCUpdate extends ClearCase { return mLog; } - /** * Get the 'log' command * @@ -287,45 +311,14 @@ public class CCUpdate extends ClearCase { private void getLogCommand(Commandline 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.createArgument().setValue(FLAG_LOG); - cmd.createArgument().setValue(getLog()); } + /* 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.createArgument().setValue(FLAG_LOG); + cmd.createArgument().setValue(getLog()); } - /** - * -graphical flag -- display graphical dialog during update operation - */ - public static final String FLAG_GRAPHICAL = "-graphical"; - /** - * -log flag -- file to log status to - */ - public static final String FLAG_LOG = "-log"; - /** - * -overwrite flag -- overwrite hijacked files - */ - public static final String FLAG_OVERWRITE = "-overwrite"; - /** - * -noverwrite flag -- do not overwrite hijacked files - */ - public static final String FLAG_NOVERWRITE = "-noverwrite"; - /** - * -rename flag -- rename hijacked files with .keep extension - */ - public static final String FLAG_RENAME = "-rename"; - /** - * -ctime flag -- modified time is written as the current time - */ - public static final String FLAG_CURRENTTIME = "-ctime"; - /** - * -ptime flag -- modified time is written as the VOB time - */ - public static final String FLAG_PRESERVETIME = "-ptime"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java index 5a537eb..eba0e9a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java @@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs.optional.clearcase; import java.io.File; +import java.io.IOException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -29,8 +30,6 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.util.FileUtils; - - /** * A base class for creating tasks for executing commands on ClearCase. * <p> @@ -46,11 +45,73 @@ import org.apache.tools.ant.util.FileUtils; * */ public abstract class ClearCase extends Task { + /** + * Constant for the thing to execute + */ + private static final String CLEARTOOL_EXE = "cleartool"; + /** + * The 'Update' command + */ + public static final String COMMAND_UPDATE = "update"; + /** + * The 'Checkout' command + */ + public static final String COMMAND_CHECKOUT = "checkout"; + /** + * The 'Checkin' command + */ + public static final String COMMAND_CHECKIN = "checkin"; + /** + * The 'UndoCheckout' command + */ + public static final String COMMAND_UNCHECKOUT = "uncheckout"; + /** + * The 'Lock' command + */ + public static final String COMMAND_LOCK = "lock"; + /** + * The 'Unlock' command + */ + public static final String COMMAND_UNLOCK = "unlock"; + /** + * The 'Mkbl' command + */ + public static final String COMMAND_MKBL = "mkbl"; + /** + * The 'Mklabel' command + */ + public static final String COMMAND_MKLABEL = "mklabel"; + /** + * The 'Mklbtype' command + */ + public static final String COMMAND_MKLBTYPE = "mklbtype"; + /** + * The 'Rmtype' command + */ + public static final String COMMAND_RMTYPE = "rmtype"; + /** + * The 'LsCheckout' command + */ + public static final String COMMAND_LSCO = "lsco"; + /** + * The 'Mkelem' command + */ + public static final String COMMAND_MKELEM = "mkelem"; + /** + * The 'Mkattr' command + */ + public static final String COMMAND_MKATTR = "mkattr"; + /** + * The 'Mkdir' command + */ + public static final String COMMAND_MKDIR = "mkdir"; + private String mClearToolDir = ""; private String mviewPath = null; private String mobjSelect = null; private int pcnt = 0; private boolean mFailonerr = true; + /** * Set the directory where the cleartool executable is located. * @@ -67,7 +128,7 @@ public abstract class ClearCase extends Task { */ protected final String getClearToolCommand() { String toReturn = mClearToolDir; - if (!toReturn.equals("") && !toReturn.endsWith("/")) { + if (!("".equals(toReturn) || toReturn.endsWith("/"))) { toReturn += "/"; } @@ -129,13 +190,13 @@ public abstract class ClearCase extends Task { protected int run(Commandline cmd) { try { Project aProj = getProject(); - Execute exe - = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); + Execute exe = new Execute( + new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); - } catch (java.io.IOException e) { + } catch (IOException e) { throw new BuildException(e, getLocation()); } } @@ -157,6 +218,7 @@ public abstract class ClearCase extends Task { return getProject().getProperty(outV); } + /** * If true, command will throw an exception on failure. * @@ -177,66 +239,4 @@ public abstract class ClearCase extends Task { return mFailonerr; } - /** - * Constant for the thing to execute - */ - private static final String CLEARTOOL_EXE = "cleartool"; - /** - * The 'Update' command - */ - public static final String COMMAND_UPDATE = "update"; - /** - * The 'Checkout' command - */ - public static final String COMMAND_CHECKOUT = "checkout"; - /** - * The 'Checkin' command - */ - public static final String COMMAND_CHECKIN = "checkin"; - /** - * The 'UndoCheckout' command - */ - public static final String COMMAND_UNCHECKOUT = "uncheckout"; - /** - * The 'Lock' command - */ - public static final String COMMAND_LOCK = "lock"; - /** - * The 'Unlock' command - */ - public static final String COMMAND_UNLOCK = "unlock"; - /** - * The 'Mkbl' command - */ - public static final String COMMAND_MKBL = "mkbl"; - /** - * The 'Mklabel' command - */ - public static final String COMMAND_MKLABEL = "mklabel"; - /** - * The 'Mklbtype' command - */ - public static final String COMMAND_MKLBTYPE = "mklbtype"; - /** - * The 'Rmtype' command - */ - public static final String COMMAND_RMTYPE = "rmtype"; - /** - * The 'LsCheckout' command - */ - public static final String COMMAND_LSCO = "lsco"; - /** - * The 'Mkelem' command - */ - public static final String COMMAND_MKELEM = "mkelem"; - /** - * The 'Mkattr' command - */ - public static final String COMMAND_MKATTR = "mkattr"; - /** - * The 'Mkdir' command - */ - public static final String COMMAND_MKDIR = "mkdir"; - } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java index 8f0a579..3c8d82b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java @@ -20,10 +20,11 @@ package org.apache.tools.ant.taskdefs.optional.depend; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.Enumeration; -import java.util.Hashtable; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -37,11 +38,6 @@ import org.apache.tools.ant.util.depend.AbstractAnalyzer; * */ public class AntAnalyzer extends AbstractAnalyzer { - /** - * Default constructor - */ - public AntAnalyzer() { - } /** * Determine the dependencies of the configured root classes. @@ -51,31 +47,27 @@ public class AntAnalyzer extends AbstractAnalyzer { * @param classes a vector to be populated with the names of the * dependency classes. */ + @Override protected void determineDependencies(Vector<File> files, Vector<String> classes) { // we get the root classes and build up a set of // classes upon which they depend - Hashtable<String, String> dependencies = new Hashtable<String, String>(); - Hashtable<File, File> containers = new Hashtable<File, File>(); - Hashtable<String, String> toAnalyze = new Hashtable<String, String>(); - for (Enumeration<String> e = getRootClasses(); e.hasMoreElements();) { - String classname = e.nextElement(); - toAnalyze.put(classname, classname); - } + Set<String> toAnalyze = new HashSet<>(Collections.list(getRootClasses())); int count = 0; int maxCount = isClosureRequired() ? MAX_LOOPS : 1; - Hashtable<String, String> analyzedDeps = null; - while (toAnalyze.size() != 0 && count++ < maxCount) { - analyzedDeps = new Hashtable<String, String>(); - for (Enumeration<String> e = toAnalyze.keys(); e.hasMoreElements();) { - String classname = e.nextElement(); - dependencies.put(classname, classname); + Set<String> dependencies = new HashSet<>(); + Set<File> containers = new HashSet<>(); + Set<String> analyzedDeps = null; + while (!toAnalyze.isEmpty() && count++ < maxCount) { + analyzedDeps = new HashSet<>(); + for (String classname : toAnalyze) { + dependencies.add(classname); try { File container = getClassContainer(classname); if (container == null) { continue; } - containers.put(container, container); + containers.add(container); ZipFile zipFile = null; InputStream inStream = null; @@ -93,7 +85,7 @@ public class AntAnalyzer extends AbstractAnalyzer { ClassFile classFile = new ClassFile(); classFile.read(inStream); for (String dependency : classFile.getClassRefs()) { - analyzedDeps.put(dependency, dependency); + analyzedDeps.add(dependency); } } finally { FileUtils.close(inStream); @@ -107,27 +99,20 @@ public class AntAnalyzer extends AbstractAnalyzer { toAnalyze.clear(); // now recover all the dependencies collected and add to the list. - for (String className : analyzedDeps.values()) { - if (!dependencies.containsKey(className)) { - toAnalyze.put(className, className); + for (String className : analyzedDeps) { + if (!dependencies.contains(className)) { + toAnalyze.add(className); } } } // pick up the last round of dependencies that were determined - for (String className : analyzedDeps.values()) { - dependencies.put(className, className); - } + dependencies.addAll(analyzedDeps); files.removeAllElements(); - for (File f : containers.keySet()) { - files.add(f); - } - + files.addAll(containers); classes.removeAllElements(); - for (String dependency :dependencies.keySet()) { - classes.add(dependency); - } + classes.addAll(dependencies); } /** @@ -135,9 +120,9 @@ public class AntAnalyzer extends AbstractAnalyzer { * * @return true if the analyzer provides dependency file information. */ + @Override protected boolean supportsFileDependencies() { return true; } } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java index 858ce03..49f8a27 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFile.java @@ -59,8 +59,8 @@ public class ClassFile { DataInputStream classStream = new DataInputStream(stream); if (classStream.readInt() != CLASS_MAGIC) { - throw new ClassFormatError("No Magic Code Found " - + "- probably not a Java class file."); + throw new ClassFormatError( + "No Magic Code Found - probably not a Java class file."); } // right we have a good looking class file. @@ -81,7 +81,6 @@ public class ClassFile { className = classInfo.getClassName(); } - /** * Get the classes which this class references. * @@ -89,7 +88,7 @@ public class ClassFile { */ public Vector<String> getClassRefs() { - Vector<String> classRefs = new Vector<String>(); + Vector<String> classRefs = new Vector<>(); final int size = constantPool.size(); for (int i = 0; i < size; ++i) { @@ -118,4 +117,3 @@ public class ClassFile { return ClassFileUtils.convertSlashName(className); } } - http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java index 92fc191..0af7579 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileIterator.java @@ -17,11 +17,14 @@ */ package org.apache.tools.ant.taskdefs.optional.depend; +import java.util.Iterator; +import java.util.NoSuchElementException; + /** * Iterator interface for iterating over a set of class files * */ -public interface ClassFileIterator { +public interface ClassFileIterator extends Iterable<ClassFile> { /** * Get the next class file in the iteration @@ -29,5 +32,33 @@ public interface ClassFileIterator { * @return the next class file in the iteration */ ClassFile getNextClassFile(); -} + + @Override + default Iterator<ClassFile> iterator() { + + return new Iterator<ClassFile>() { + ClassFile next; + { + next = getNextClassFile(); + } + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public ClassFile next() { + if (next == null) { + throw new NoSuchElementException(); + } + try { + return next; + } finally { + next = getNextClassFile(); + } + } + + }; + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java index c6eec6c..273b563 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/ClassFileUtils.java @@ -49,4 +49,3 @@ public class ClassFileUtils { return dotName.replace('.', '/'); } } -
