Source Code Cross Referenced for CCMkbl.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » clearcase » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs.optional.clearcase 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs.optional.clearcase;
020:
021:        import org.apache.tools.ant.BuildException;
022:        import org.apache.tools.ant.Project;
023:        import org.apache.tools.ant.taskdefs.Execute;
024:        import org.apache.tools.ant.types.Commandline;
025:
026:        /**
027:         * Task to CreateBaseline command to ClearCase.
028:         * <p>
029:         * The following attributes are interpreted:
030:         * <table border="1">
031:         *   <tr>
032:         *     <th>Attribute</th>
033:         *     <th>Values</th>
034:         *     <th>Required</th>
035:         *   </tr>
036:         *   <tr>
037:         *      <td>comment</td>
038:         *      <td>Specify a comment. Only one of comment or cfile may be
039:         used.</td>
040:         *      <td>No</td>
041:         *   </tr>
042:         *   <tr>
043:         *      <td>commentfile</td>
044:         *      <td>Specify a file containing a comment. Only one of comment or
045:         cfile may be used.</td>
046:         *      <td>No</td>
047:         *   </tr>
048:         *   <tr>
049:         *      <td>baselinerootname</td>
050:         *      <td>Specify the name to be associated with the baseline.</td>
051:         *      <td>Yes</td>
052:         *   </tr>
053:         *   <tr>
054:         *      <td>nowarn</td>
055:         *      <td>Suppress warning messages</td>
056:         *      <td>No</td>
057:         *   <tr>
058:         *   <tr>
059:         *      <td>identical</td>
060:         *      <td>Allows the baseline to be created even if it is identical to the
061:         previous baseline.</td>
062:         *      <td>No</td>
063:         *   </tr>
064:         *   <tr>
065:         *      <td>full</td>
066:         *      <td>Creates a full baseline.</td>
067:         *      <td>No</td>
068:         *   </tr>
069:         *   <tr>
070:         *      <td>nlabel</td>
071:         *      <td>Allows the baseline to be created without a label.</td>
072:         *      <td>No</td>
073:         *   </tr>
074:         *   <tr>
075:         *      <td>failonerr</td>
076:         *      <td>Throw an exception if the command fails. Default is true</td>
077:         *      <td>No</td>
078:         *   <tr>
079:         * </table>
080:         *
081:         */
082:        public class CCMkbl extends ClearCase {
083:            private String mComment = null;
084:            private String mCfile = null;
085:            private String mBaselineRootName = null;
086:            private boolean mNwarn = false;
087:            private boolean mIdentical = true;
088:            private boolean mFull = false;
089:            private boolean mNlabel = false;
090:
091:            /**
092:             * Executes the task.
093:             * <p>
094:             * Builds a command line to execute cleartool and then calls Exec's run method
095:             * to execute the command line.
096:             * @throws BuildException if the command fails and failonerr is set to true
097:             */
098:            public void execute() throws BuildException {
099:                Commandline commandLine = new Commandline();
100:                Project aProj = getProject();
101:                int result = 0;
102:
103:                // Default the viewpath to basedir if it is not specified
104:                if (getViewPath() == null) {
105:                    setViewPath(aProj.getBaseDir().getPath());
106:                }
107:
108:                // build the command line from what we got. the format is
109:                // cleartool checkin [options...] [viewpath ...]
110:                // as specified in the CLEARTOOL.EXE help
111:                commandLine.setExecutable(getClearToolCommand());
112:                commandLine.createArgument().setValue(COMMAND_MKBL);
113:
114:                checkOptions(commandLine);
115:
116:                if (!getFailOnErr()) {
117:                    getProject().log(
118:                            "Ignoring any errors that occur for: "
119:                                    + getBaselineRootName(),
120:                            Project.MSG_VERBOSE);
121:                }
122:                result = run(commandLine);
123:                if (Execute.isFailure(result) && getFailOnErr()) {
124:                    String msg = "Failed executing: " + commandLine.toString();
125:                    throw new BuildException(msg, getLocation());
126:                }
127:            }
128:
129:            /**
130:             * Check the command line options.
131:             */
132:            private void checkOptions(Commandline cmd) {
133:                if (getComment() != null) {
134:                    // -c
135:                    getCommentCommand(cmd);
136:                } else {
137:                    if (getCommentFile() != null) {
138:                        // -cfile
139:                        getCommentFileCommand(cmd);
140:                    } else {
141:                        cmd.createArgument().setValue(FLAG_NOCOMMENT);
142:                    }
143:                }
144:
145:                if (getIdentical()) {
146:                    // -identical
147:                    cmd.createArgument().setValue(FLAG_IDENTICAL);
148:                }
149:
150:                if (getFull()) {
151:                    // -full
152:                    cmd.createArgument().setValue(FLAG_FULL);
153:                } else {
154:                    // -incremental
155:                    cmd.createArgument().setValue(FLAG_INCREMENTAL);
156:                }
157:
158:                if (getNlabel()) {
159:                    // -nlabel
160:                    cmd.createArgument().setValue(FLAG_NLABEL);
161:                }
162:
163:                // baseline_root_name
164:                cmd.createArgument().setValue(getBaselineRootName());
165:
166:            }
167:
168:            /**
169:             * Set comment string
170:             *
171:             * @param comment the comment string
172:             */
173:            public void setComment(String comment) {
174:                mComment = comment;
175:            }
176:
177:            /**
178:             * Get comment string
179:             *
180:             * @return String containing the comment
181:             */
182:            public String getComment() {
183:                return mComment;
184:            }
185:
186:            /**
187:             * Set comment file
188:             *
189:             * @param cfile the path to the comment file
190:             */
191:            public void setCommentFile(String cfile) {
192:                mCfile = cfile;
193:            }
194:
195:            /**
196:             * Get comment file
197:             *
198:             * @return String containing the path to the comment file
199:             */
200:            public String getCommentFile() {
201:                return mCfile;
202:            }
203:
204:            /**
205:             * Set baseline_root_name
206:             *
207:             * @param baselineRootName the name of the baseline
208:             */
209:            public void setBaselineRootName(String baselineRootName) {
210:                mBaselineRootName = baselineRootName;
211:            }
212:
213:            /**
214:             * Get baseline_root_name
215:             *
216:             * @return String containing the name of the baseline
217:             */
218:            public String getBaselineRootName() {
219:                return mBaselineRootName;
220:            }
221:
222:            /**
223:
224:            /**
225:             * Set the nowarn flag
226:             *
227:             * @param nwarn the status to set the flag to
228:             */
229:            public void setNoWarn(boolean nwarn) {
230:                mNwarn = nwarn;
231:            }
232:
233:            /**
234:             * Get nowarn flag status
235:             *
236:             * @return boolean containing status of nwarn flag
237:             */
238:            public boolean getNoWarn() {
239:                return mNwarn;
240:            }
241:
242:            /**
243:             * Set the identical flag
244:             *
245:             * @param identical the status to set the flag to
246:             */
247:            public void setIdentical(boolean identical) {
248:                mIdentical = identical;
249:            }
250:
251:            /**
252:             * Get identical flag status
253:             *
254:             * @return boolean containing status of identical flag
255:             */
256:            public boolean getIdentical() {
257:                return mIdentical;
258:            }
259:
260:            /**
261:             * Set the full flag
262:             *
263:             * @param full the status to set the flag to
264:             */
265:            public void setFull(boolean full) {
266:                mFull = full;
267:            }
268:
269:            /**
270:             * Get full flag status
271:             *
272:             * @return boolean containing status of full flag
273:             */
274:            public boolean getFull() {
275:                return mFull;
276:            }
277:
278:            /**
279:             * Set the nlabel flag
280:             *
281:             * @param nlabel the status to set the flag to
282:             */
283:            public void setNlabel(boolean nlabel) {
284:                mNlabel = nlabel;
285:            }
286:
287:            /**
288:             * Get nlabel status
289:             *
290:             * @return boolean containing status of nlabel flag
291:             */
292:            public boolean getNlabel() {
293:                return mNlabel;
294:            }
295:
296:            /**
297:             * Get the 'comment' command
298:             *
299:             * @param cmd containing the command line string with or
300:             *                    without the comment flag and string appended
301:             */
302:            private void getCommentCommand(Commandline cmd) {
303:                if (getComment() != null) {
304:                    /* Had to make two separate commands here because if a space is
305:                       inserted between the flag and the value, it is treated as a
306:                       Windows filename with a space and it is enclosed in double
307:                       quotes ("). This breaks clearcase.
308:                     */
309:                    cmd.createArgument().setValue(FLAG_COMMENT);
310:                    cmd.createArgument().setValue(getComment());
311:                }
312:            }
313:
314:            /**
315:             * Get the 'commentfile' command
316:             *
317:             * @param cmd CommandLine containing the command line string with or
318:             *                    without the commentfile flag and file appended
319:             */
320:            private void getCommentFileCommand(Commandline cmd) {
321:                if (getCommentFile() != null) {
322:                    /* Had to make two separate commands here because if a space is
323:                       inserted between the flag and the value, it is treated as a
324:                       Windows filename with a space and it is enclosed in double
325:                       quotes ("). This breaks clearcase.
326:                     */
327:                    cmd.createArgument().setValue(FLAG_COMMENTFILE);
328:                    cmd.createArgument().setValue(getCommentFile());
329:                }
330:            }
331:
332:            /**
333:             * -c flag -- comment to attach to the file
334:             */
335:            public static final String FLAG_COMMENT = "-c";
336:            /**
337:             * -cfile flag -- file containing a comment to attach to the file
338:             */
339:            public static final String FLAG_COMMENTFILE = "-cfile";
340:            /**
341:             * -nc flag -- no comment is specified
342:             */
343:            public static final String FLAG_NOCOMMENT = "-nc";
344:            /**
345:             * -identical flag -- allows the file to be checked in even if it is identical to the original
346:             */
347:            public static final String FLAG_IDENTICAL = "-identical";
348:            /**
349:             * -incremental flag -- baseline to be created is incremental
350:             */
351:            public static final String FLAG_INCREMENTAL = "-incremental";
352:            /**
353:             * -full flag -- baseline to be created is full
354:             */
355:            public static final String FLAG_FULL = "-full";
356:            /**
357:             * -nlabel -- baseline to be created without a label
358:             */
359:            public static final String FLAG_NLABEL = "-nlabel";
360:
361:        }
w___w__w_.__j__av__a___2_s___.___c___o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.