Source Code Cross Referenced for DotnetBaseMatchingTask.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » dotnet » 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.dotnet 
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.dotnet;
020:
021:        import org.apache.tools.ant.taskdefs.MatchingTask;
022:        import org.apache.tools.ant.taskdefs.condition.Os;
023:        import org.apache.tools.ant.types.FileSet;
024:        import org.apache.tools.ant.Project;
025:        import org.apache.tools.ant.DirectoryScanner;
026:
027:        import java.io.File;
028:        import java.util.Vector;
029:        import java.util.Hashtable;
030:        import java.util.Enumeration;
031:
032:        /**
033:         * refactoring of some stuff so that different things (like ILASM)
034:         * can use shared code.
035:         */
036:        public class DotnetBaseMatchingTask extends MatchingTask {
037:            // CheckStyle:VisibilityModifier OFF - bc
038:            /**
039:             *  output file. If not supplied this is derived from the source file
040:             */
041:            protected File outputFile;
042:            /**
043:             * filesets of file to compile
044:             */
045:            protected Vector filesets = new Vector();
046:
047:            /**
048:             *  source directory upon which the search pattern is applied
049:             */
050:            protected File srcDir;
051:
052:            /**
053:             * Are we running on Windows?
054:             *
055:             * @since Ant 1.6.3
056:             */
057:            // CheckStyle:ConstantNameCheck OFF - bc
058:            protected static final boolean isWindows = Os.isFamily("windows");
059:
060:            // CheckStyle:ConstantNameCheck ON
061:            // CheckStyle:VisibilityModifier ON
062:
063:            /**
064:             * Overridden because we need to be able to set the srcDir.
065:             * @return the source directory.
066:             */
067:            public File getSrcDir() {
068:                return this .srcDir;
069:            }
070:
071:            /**
072:             *  Set the source directory of the files to be compiled.
073:             *
074:             *@param  srcDirName  The new SrcDir value
075:             */
076:            public void setSrcDir(File srcDirName) {
077:                this .srcDir = srcDirName;
078:            }
079:
080:            /**
081:             *  Set the name of exe/library to create.
082:             *
083:             *@param  file  The new outputFile value
084:             */
085:            public void setDestFile(File file) {
086:                outputFile = file;
087:            }
088:
089:            /**
090:             * add a new source directory to the compile
091:             * @param src a fileset.
092:             */
093:            public void addSrc(FileSet src) {
094:                filesets.add(src);
095:            }
096:
097:            /**
098:             * get the destination file
099:             * @return the dest file or null for not assigned
100:             */
101:            public File getDestFile() {
102:                return outputFile;
103:            }
104:
105:            /**
106:             * create the list of files
107:             * @param command the command to create the files for.
108:             * @param filesToBuild vector to add files to
109:             * @param outputTimestamp timestamp to compare against
110:             * @return number of files out of date
111:             */
112:            protected int buildFileList(NetCommand command,
113:                    Hashtable filesToBuild, long outputTimestamp) {
114:                int filesOutOfDate = 0;
115:                boolean scanImplicitFileset = getSrcDir() != null
116:                        || filesets.size() == 0;
117:                if (scanImplicitFileset) {
118:                    //scan for an implicit fileset if there was a srcdir set
119:                    //or there was no srcDir set but there was no contained classes
120:                    if (getSrcDir() == null) {
121:                        //if there is no src dir here, set it
122:                        setSrcDir(getProject().resolveFile("."));
123:                    }
124:                    log("working from source directory " + getSrcDir(),
125:                            Project.MSG_VERBOSE);
126:                    //get dependencies list.
127:                    DirectoryScanner scanner = getDirectoryScanner(getSrcDir());
128:                    filesOutOfDate = command.scanOneFileset(scanner,
129:                            filesToBuild, outputTimestamp);
130:                }
131:                //get any included source directories
132:                for (int i = 0; i < filesets.size(); i++) {
133:                    FileSet fs = (FileSet) filesets.elementAt(i);
134:                    filesOutOfDate += command.scanOneFileset(fs
135:                            .getDirectoryScanner(getProject()), filesToBuild,
136:                            outputTimestamp);
137:                }
138:
139:                return filesOutOfDate;
140:            }
141:
142:            /**
143:             * add the list of files to a command
144:             * @param filesToBuild vector of files
145:             * @param command the command to append to
146:             */
147:            protected void addFilesToCommand(Hashtable filesToBuild,
148:                    NetCommand command) {
149:                int count = filesToBuild.size();
150:                log("compiling " + count + " file" + ((count == 1) ? "" : "s"),
151:                        Project.MSG_VERBOSE);
152:                Enumeration files = filesToBuild.elements();
153:                while (files.hasMoreElements()) {
154:                    File file = (File) files.nextElement();
155:                    command.addArgument(file.toString());
156:                }
157:            }
158:
159:            /**
160:             * determine the timestamp of the output file
161:             * @return a timestamp or 0 for no output file known/exists
162:             */
163:            protected long getOutputFileTimestamp() {
164:                long outputTimestamp;
165:                if (getDestFile() != null && getDestFile().exists()) {
166:                    outputTimestamp = getDestFile().lastModified();
167:                } else {
168:                    outputTimestamp = 0;
169:                }
170:                return outputTimestamp;
171:            }
172:
173:            /**
174:             * finish off the command by adding all dependent files, execute
175:             * @param command the command to update.
176:             * @param ignoreTimestamps not used.
177:             */
178:            protected void addFilesAndExecute(NetCommand command,
179:                    boolean ignoreTimestamps) {
180:                long outputTimestamp = getOutputFileTimestamp();
181:                Hashtable filesToBuild = new Hashtable();
182:                int filesOutOfDate = buildFileList(command, filesToBuild,
183:                        outputTimestamp);
184:
185:                //now run the command of exe + settings + files
186:                if (filesOutOfDate > 0) {
187:                    //add the files to the command
188:                    addFilesToCommand(filesToBuild, command);
189:                    command.runCommand();
190:                } else {
191:                    log("output file is up to date", Project.MSG_VERBOSE);
192:                }
193:            }
194:
195:        }
ww___w.j_a__v_a2s__.___c___o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.