Source Code Cross Referenced for TemplateAntTask.java in  » Testing » Marathon » org » python » util » 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 » Testing » Marathon » org.python.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         * 
004:         * Copyright (c) 2002 The Apache Software Foundation. All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are met:
008:         * 
009:         * 1. Redistributions of source code must retain the above copyright notice,
010:         * this list of conditions and the following disclaimer.
011:         * 
012:         * 2. Redistributions in binary form must reproduce the above copyright notice,
013:         * this list of conditions and the following disclaimer in the documentation
014:         * and/or other materials provided with the distribution.
015:         * 
016:         * 3. The end-user documentation included with the redistribution, if any, must
017:         * include the following acknowlegement: "This product includes software
018:         * developed by the Apache Software Foundation (http://www.apache.org/)."
019:         * Alternately, this acknowlegement may appear in the software itself, if and
020:         * wherever such third-party acknowlegements normally appear.
021:         * 
022:         * 4. The names "The Jakarta Project", "Ant", and "Apache Software Foundation"
023:         * must not be used to endorse or promote products derived from this software
024:         * without prior written permission. For written permission, please contact
025:         * apache@apache.org.
026:         * 
027:         * 5. Products derived from this software may not be called "Apache" nor may
028:         * "Apache" appear in their names without prior written permission of the Apache
029:         * Group.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
032:         * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
033:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE
034:         * SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
035:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
036:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
037:         * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
038:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
039:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
040:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
041:         * ====================================================================
042:         * 
043:         * This software consists of voluntary contributions made by many individuals on
044:         * behalf of the Apache Software Foundation. For more information on the Apache
045:         * Software Foundation, please see <http://www.apache.org/>.
046:         */
047:        package org.python.util;
048:
049:        import org.apache.tools.ant.taskdefs.MatchingTask;
050:        import org.apache.tools.ant.taskdefs.Execute;
051:        import org.apache.tools.ant.BuildException;
052:        import org.apache.tools.ant.taskdefs.Java;
053:        import org.apache.tools.ant.types.Path;
054:        import org.apache.tools.ant.DirectoryScanner;
055:        import java.io.File;
056:        import java.io.BufferedReader;
057:        import java.io.InputStreamReader;
058:        import java.io.FileInputStream;
059:        import java.io.Reader;
060:        import java.io.IOException;
061:        import java.util.Map;
062:        import java.util.HashMap;
063:
064:        /**
065:         * Template is an Ant task for generating new-style object definitions based on
066:         * template files. These template files come in two flavors; *.expose and
067:         * *.derived, both are supported by this task.
068:         * 
069:         * @author Matt Small - msmall@activegrid.com
070:         * @version 1.0
071:         */
072:        public class TemplateAntTask extends MatchingTask {
073:
074:            /**
075:             * Specifies the Python interpreter.
076:             */
077:            protected String python;
078:
079:            /**
080:             * Specifies the Python interpreter.
081:             */
082:            public void setPython(String aPE) {
083:                python = aPE;
084:            }
085:
086:            /**
087:             * Source paths.
088:             */
089:            private File srcDir;
090:
091:            /**
092:             * Source paths.
093:             */
094:            public void setSrcdir(String in) {
095:                srcDir = new File(getProject().replaceProperties(in));
096:            }
097:
098:            /**
099:             * Verbose flag.
100:             */
101:            protected boolean verbose = false;
102:
103:            /**
104:             * Verbose flag.
105:             */
106:            public void setVerbose(String in) {
107:                verbose = (new Boolean(getProject().replaceProperties(in)))
108:                        .booleanValue();
109:            }
110:
111:            /**
112:             * Lazy flag.
113:             */
114:            protected boolean lazy = false;
115:
116:            /**
117:             * Lazy flag.
118:             */
119:            public void setLazy(String in) {
120:                lazy = (new Boolean(getProject().replaceProperties(in)))
121:                        .booleanValue();
122:            }
123:
124:            public void execute() {
125:                if (null == srcDir) {
126:                    throw new BuildException("no srcdir specified");
127:                } else if (!srcDir.exists()) {
128:                    throw new BuildException("srcdir '" + srcDir
129:                            + "' doesn't exist");
130:                }
131:                File gexposeScript = new File(srcDir.getAbsolutePath()
132:                        + File.separator + "gexpose.py");
133:                File gderiveScript = new File(srcDir.getAbsolutePath()
134:                        + File.separator + "gderived.py");
135:                if (!gexposeScript.exists()) {
136:                    throw new BuildException("no gexpose.py script found at: "
137:                            + gexposeScript);
138:                }
139:                if (!gderiveScript.exists()) {
140:                    throw new BuildException("no gderive.py script found at: "
141:                            + gderiveScript);
142:                }
143:                runPythonScript(gexposeScript.getAbsolutePath());
144:                runPythonScript(gderiveScript.getAbsolutePath());
145:            }
146:
147:            private void runPythonScript(String script) throws BuildException {
148:                if (null == python) {
149:                    python = "python";
150:                }
151:                Execute e = new Execute();
152:                e.setWorkingDirectory(srcDir);
153:                String[] command;
154:                if (lazy) {
155:                    command = new String[] { python, script, "--lazy" };
156:                } else {
157:                    command = new String[] { python, script };
158:                }
159:                e.setCommandline(command);
160:                if (verbose) {
161:                    String out = "";
162:                    for (int k = 0; k < e.getCommandline().length; k++) {
163:                        out += (e.getCommandline()[k] + " ");
164:                    }
165:                    log("executing: " + out);
166:                }
167:                try {
168:                    e.execute();
169:                } catch (IOException e2) {
170:                    throw new BuildException(e2.toString(), e2);
171:                }
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.