Source Code Cross Referenced for Nicec.java in  » Scripting » Nice » nice » tools » ant » 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 » Scripting » Nice » nice.tools.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package nice.tools.ant;
002:
003:        import org.apache.tools.ant.*;
004:        import org.apache.tools.ant.types.*;
005:        import java.io.File;
006:        import java.util.Vector;
007:        import bossa.modules.Compilation;
008:
009:        /**
010:         <h2><a name="java">Nicec</a></h2>
011:         <h3>Description</h3>
012:         <p>Runs the Nice compiler.</p>
013:         All arguments to the Nice compiler Task has to be placed as attributes in the nicec xml-element.
014:         <h3>Parameters</h3>
015:         <table border="1" cellpadding="2" cellspacing="0">
016:         <tr>
017:         <td valign="top"><b>Attribute</b></td>
018:         <td valign="top"><b>Description</b></td>
019:         <td align="center" valign="top"><b>Required</b></td>
020:         </tr>
021:         <tr>
022:         <td valign="top">package</td>
023:         <td valign="top">The Nice package to compile.</td>
024:         <td align="center" valign="top">Yes</td>
025:         </tr>
026:         <tr>
027:         <td valign="top">jar</td>
028:         <td valign="top">Compile the Nice sources to archive.</td>
029:         <td align="center" valign="top">No</td>
030:         </tr>
031:         <tr>
032:         <td valign="top">sourcepath</td>
033:         <td valign="top">Search path for source packages. Is a list of directories and .jar archives.</td>
034:         <td align="center" valign="top">No</td>
035:         </tr>
036:         <tr>
037:         <td valign="top">destination</td>
038:         <td valign="top">Destination directory for compiled packages.</td>
039:         <td align="center" valign="top">No</td>
040:         </tr>
041:         <tr>
042:         <td valign="top">classpath</td>
043:         <td valign="top">Search path for compiled packages and libraries.</td>
044:         <td align="center" valign="top">No</td>
045:         </tr>
046:         <tr>
047:         <td valign="top">output</td>
048:         <td valign="top">Generate native executable.</td>
049:         <td align="center" valign="top">No</td>
050:         </tr>
051:         <tr>
052:         <td valign="top">compile</td>
053:         <td valign="top">Compile packages but do not link them.</td>
054:         <td align="center" valign="top">No</td>
055:         </tr>
056:         <tr>
057:         <td valign="top">recompile</td>
058:         <td valign="top">Force recompilation of package.</td>
059:         <td align="center" valign="top">No</td>
060:         </tr>
061:         <tr>
062:         <td valign="top">recompile_all</td>
063:         <td valign="top">Force recompilation of all dependant packages.</td>
064:         <td align="center" valign="top">No</td>
065:         </tr>
066:         <tr>
067:         <td valign="top">exclude_runtime</td>
068:         <td valign="top">Avoid inclusion of the runtime in the archive.</td>
069:         <td align="center" valign="top">No</td>
070:         </tr>
071:         <tr>
072:         <td valign="top">runtime</td>
073:         <td valign="top">Location of nice.jar.</td>
074:         <td align="center" valign="top">Yes</td>
075:         </tr>
076:         <tr>
077:         <td valign="top">native_compiler</td>
078:         <td valign="top">Location of the native compiler binary (gcj).</td>
079:         <td align="center" valign="top">No</td>
080:         </tr>
081:         <tr>
082:         <td valign="top">editor</td>
083:         <td valign="top">Tell nicec that it is called by an editor.</td>
084:         <td align="center" valign="top">No</td>
085:         </tr>
086:         </table>
087:
088:         <h4>classpath</h4>
089:         <p><code>Nicec</code>'s <i>classpath</i> attribute is a PATH like structure and can also be set via a nested
090:         <i>classpath</i> element. This is very reasonable if you want to make your build script's pathes platform
091:         independent. </p>
092:         <h5>Example</h5>
093:         <pre>  
094:         &lt;nicec package=&quot;test&quot; &gt;
095:         &lt;classpath&gt;
096:         &lt;pathelement location=&quot;\test.jar&quot;/&gt;
097:         &lt;pathelement path=&quot;${java.class.path}&quot;/&gt;
098:         &lt;/classpath&gt;
099:         &lt;/java&gt;
100:         </pre>
101:         <p>It is possible to use the <i>classpath</i> attribute together with the
102:         <i>classpath<i> nested tag. In this case the result is a concatenated path.</p>
103:         <p>It is highly recommended to use the nested version!<p>
104:
105:
106:         <h3>Examples</h3>
107:         <pre>
108:         &lt;taskdef name=&quot;nicec&quot; classname=&quot;nice.tools.ant.Nicec&quot;/&gt;
109:         &lt;target name=&quot;nice-compiler&quot;&gt;
110:         &lt;nicec package=&quot;test&quot; runtime=&quot;../share/java/nice.jar&quot;/&gt;
111:         &lt;/target&gt;
112:         </pre>
113:
114:
115:         * @author Alex Greif <a href="mailto:alex.greif@web.de">alex.greif@web.de</a>
116:         */
117:
118:        public class Nicec extends Task {
119:
120:            private static final String ERROR_MSG = "Compilation failed with errors.";
121:            private static final String BUG_MSG = "Compilation failed because of a bug in the compiler.";
122:            private static final String WARNING_MSG = "Compilation successful despite warnings.";
123:            private static final String OK_MSG = "Compilation successful.";
124:
125:            /**	Search path for source packages
126:             PATH is a list of directories and .jar archives
127:             */
128:            private String sourcepath;
129:
130:            public void setSourcepath(String sourcepath) {
131:                this .sourcepath = sourcepath;
132:            }
133:
134:            /**	Destination directory for compiled packages
135:             */
136:            private File destination;
137:
138:            public void setDestination(File destination) {
139:                this .destination = destination;
140:            }
141:
142:            /**	Search path for compiled packages and libraries
143:             */
144:            private String classpath = "";
145:
146:            public void setClasspath(String classpath) {
147:                this .classpath = classpath;
148:            }
149:
150:            /**	Compile to archive
151:             You can then run the program with 'java -jar FILE'
152:             */
153:            private String jar;
154:
155:            public void setJar(String jar) {
156:                this .jar = jar;
157:            }
158:
159:            /**	Generate native executable
160:             */
161:            private String output;
162:
163:            public void setOutput(String output) {
164:                this .output = output;
165:            }
166:
167:            /**	Force recompilation of package
168:             */
169:            private boolean recompile;
170:
171:            public void setRecompile(boolean recompile) {
172:                this .recompile = recompile;
173:            }
174:
175:            /**	Force recompilation of all dependant packages
176:             */
177:            private boolean recompile_all;
178:
179:            public void setRecompile_all(boolean recompile_all) {
180:                this .recompile_all = recompile_all;
181:            }
182:
183:            /**	Compile packages but do not link them
184:             */
185:            private boolean compile;
186:
187:            public void setCompile(boolean compile) {
188:                this .compile = compile;
189:            }
190:
191:            /**	Avoid inclusion of the runtime in the archive
192:             */
193:            private boolean exclude_runtime;
194:
195:            public void setExclude_runtime(boolean exclude_runtime) {
196:                this .exclude_runtime = exclude_runtime;
197:            }
198:
199:            /**	Location of nice.jar
200:             */
201:            private String runtime = null;
202:
203:            public void setRuntime(String runtime) {
204:                this .runtime = runtime;
205:            }
206:
207:            /**	Location of the native compiler binary (gcj)
208:             */
209:            private String native_compiler;
210:
211:            public void setNative_compiler(String native_compiler) {
212:                this .native_compiler = native_compiler;
213:            }
214:
215:            /**	Tell nicec that it is called by an editor.
216:             */
217:            private boolean editor;
218:
219:            public void setEditor(boolean editor) {
220:                this .editor = editor;
221:            }
222:
223:            /**	The package to compile
224:             */
225:            private String pack;
226:
227:            public void setPackage(String pack) {
228:                this .pack = pack;
229:            }
230:
231:            private Path nestedClasspath = null;
232:
233:            /**
234:             * Creates a nested classpath element
235:             */
236:            public Path createClasspath() {
237:                nestedClasspath = new Path(project);
238:                return nestedClasspath.createPath();
239:            }
240:
241:            /**	Executes the ant Nice compiler.
242:             */
243:            public void execute() throws BuildException {
244:                log("runtime: " + runtime, Project.MSG_VERBOSE);
245:                log("Base dir: " + project.getBaseDir(), Project.MSG_VERBOSE);
246:
247:                String oldUserDir = System.getProperty("user.dir");
248:                try {
249:                    System.setProperty("user.dir", project.getBaseDir()
250:                            .getAbsolutePath());
251:
252:                    NicecListener listener = new NicecListener(this );
253:                    Compilation compilation = bossa.modules.fun
254:                            .createCompilation(listener,
255:                                    new bossa.parser.JavaccParser(false));
256:                    if (sourcepath != null)
257:                        compilation.sourcePath = sourcepath;
258:                    if (destination != null)
259:                        compilation.destinationDir = destination
260:                                .getAbsolutePath();
261:                    compilation.packagePath = classpath
262:                            + (nestedClasspath != null ? File.pathSeparator
263:                                    + nestedClasspath : "");
264:                    compilation.output = jar;
265:                    compilation.recompileCommandLine = recompile;
266:                    compilation.recompileAll = recompile_all;
267:                    compilation.skipLink = compile;
268:                    compilation.excludeRuntime = exclude_runtime;
269:                    compilation.runtimeFile = runtime;
270:                    nice.tools.compiler.fun.compile(compilation, pack, output,
271:                            native_compiler, editor);
272:                    int retval = listener.statusCode;
273:
274:                    switch (retval) {
275:                    case nice.tools.compiler.fun.ERROR:
276:                        throw new BuildException(ERROR_MSG, location);
277:                    case nice.tools.compiler.fun.BUG:
278:                        throw new BuildException(BUG_MSG, location);
279:                    case nice.tools.compiler.fun.WARNING:
280:                        log(WARNING_MSG, Project.MSG_WARN);
281:                        break;
282:                    case nice.tools.compiler.fun.OK:
283:                        log(OK_MSG, Project.MSG_INFO);
284:                        break;
285:                    }
286:                } finally {
287:                    System.setProperty("user.dir", oldUserDir);
288:                }
289:            }
290:
291:            /** Only for test usage.
292:             */
293:            public static void main(String[] args) {
294:                Nicec nicec = new Nicec();
295:                nicec.setRuntime("../share/java/nice.jar");
296:                nicec.setPackage("test");
297:                nicec.execute();
298:            }
299:
300:        }
301:
302:        // Setting for Emacs
303:        // Local variables:
304:        // tab-width:2
305:        // indent-tabs-mode:t
306:        // End:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.