Source Code Cross Referenced for PluginInfoTask.java in  » Development » Java-Plugin-Framework » org » java » plugin » 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 » Development » Java Plugin Framework » org.java.plugin.tools.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*****************************************************************************
002:         * Java Plug-in Framework (JPF)
003:         * Copyright (C) 2004-2007 Dmitry Olshansky
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *****************************************************************************/package org.java.plugin.tools.ant;
019:
020:        import java.io.File;
021:        import java.net.MalformedURLException;
022:        import java.net.URL;
023:
024:        import org.apache.tools.ant.BuildException;
025:        import org.apache.tools.ant.Task;
026:        import org.java.plugin.ObjectFactory;
027:        import org.java.plugin.registry.ManifestInfo;
028:        import org.java.plugin.registry.ManifestProcessingException;
029:        import org.java.plugin.registry.MatchingRule;
030:        import org.java.plugin.registry.Version;
031:        import org.java.plugin.util.IoUtil;
032:
033:        /**
034:         * Simple task to read some data from plug-in manifest into project properties.
035:         * <p>
036:         * Inspired by Sebastian Kopsan.
037:         * 
038:         * @version $Id$
039:         */
040:        public class PluginInfoTask extends Task {
041:            private File manifest;
042:            private String propertyId;
043:            private String propertyVersion;
044:            private String propertyVendor;
045:            private String propertyPluginId;
046:            private String propertyPluginVersion;
047:            private String propertyMatchingRule;
048:
049:            /**
050:             * @param aManifest plug-in manifest to read data from
051:             */
052:            public void setManifest(final File aManifest) {
053:                manifest = aManifest;
054:            }
055:
056:            /**
057:             * @param propertyName name of the property to read plug-in or plug-in
058:             *                     fragment ID in
059:             * 
060:             * @see org.java.plugin.registry.ManifestInfo#getId()
061:             */
062:            public void setPropertyId(String propertyName) {
063:                propertyId = propertyName;
064:            }
065:
066:            /**
067:             * @param propertyName name of the property to read plug-in or plug-in
068:             *                     fragment version in
069:             * 
070:             * @see org.java.plugin.registry.ManifestInfo#getVersion()
071:             */
072:            public void setPropertyVersion(String propertyName) {
073:                propertyVersion = propertyName;
074:            }
075:
076:            /**
077:             * @param propertyName name of the property to read plug-in or plug-in
078:             *                     fragment vendor in
079:             * 
080:             * @see org.java.plugin.registry.ManifestInfo#getVendor()
081:             */
082:            public void setPropertyVendor(String propertyName) {
083:                propertyVendor = propertyName;
084:            }
085:
086:            /**
087:             * @param propertyName name of the property to read plug-in ID in
088:             * 
089:             * @see org.java.plugin.registry.ManifestInfo#getPluginId()
090:             */
091:            public void setPropertyPluginId(String propertyName) {
092:                propertyPluginId = propertyName;
093:            }
094:
095:            /**
096:             * @param propertyName name of the property to read plug-in version in
097:             * 
098:             * @see org.java.plugin.registry.ManifestInfo#getPluginVersion()
099:             */
100:            public void setPropertyPluginVersion(String propertyName) {
101:                propertyPluginVersion = propertyName;
102:            }
103:
104:            /**
105:             * @param propertyName name of the property to read plug-in fragment
106:             *                     matching rule in
107:             * 
108:             * @see org.java.plugin.registry.ManifestInfo#getMatchingRule()
109:             */
110:            public void setPropertyMatchingRule(String propertyName) {
111:                this .propertyMatchingRule = propertyName;
112:            }
113:
114:            /**
115:             * @see org.apache.tools.ant.Task#execute()
116:             */
117:            @Override
118:            public void execute() throws BuildException {
119:                if (manifest == null) {
120:                    throw new BuildException("manifest attribute must be set!", //$NON-NLS-1$
121:                            getLocation());
122:                }
123:                URL url;
124:                try {
125:                    url = IoUtil.file2url(manifest);
126:                } catch (MalformedURLException mue) {
127:                    throw new BuildException(
128:                            "failed converting file " + manifest //$NON-NLS-1$
129:                                    + " to URL", mue, getLocation()); //$NON-NLS-1$
130:                }
131:                ManifestInfo manifestInfo;
132:                try {
133:                    manifestInfo = ObjectFactory.newInstance().createRegistry()
134:                            .readManifestInfo(url);
135:                    //log("Data read from manifest " + manifest); //$NON-NLS-1$
136:                } catch (ManifestProcessingException mpe) {
137:                    throw new BuildException(
138:                            "failed reading data from manifest " //$NON-NLS-1$
139:                                    + url, mpe, getLocation());
140:                }
141:                if (propertyId != null) {
142:                    getProject().setProperty(propertyId, manifestInfo.getId());
143:                }
144:                if (propertyVersion != null) {
145:                    Version version = manifestInfo.getVersion();
146:                    getProject().setProperty(propertyVersion,
147:                            (version != null) ? version.toString() : ""); //$NON-NLS-1$
148:                }
149:                if (propertyVendor != null) {
150:                    String value = manifestInfo.getVendor();
151:                    getProject().setProperty(propertyVendor,
152:                            (value != null) ? value : ""); //$NON-NLS-1$
153:                }
154:                if (propertyPluginId != null) {
155:                    String value = manifestInfo.getPluginId();
156:                    getProject().setProperty(propertyPluginId,
157:                            (value != null) ? value : ""); //$NON-NLS-1$
158:                }
159:                if (propertyPluginVersion != null) {
160:                    Version version = manifestInfo.getPluginVersion();
161:                    getProject().setProperty(propertyPluginVersion,
162:                            (version != null) ? version.toString() : ""); //$NON-NLS-1$
163:                }
164:                if (propertyMatchingRule != null) {
165:                    MatchingRule value = manifestInfo.getMatchingRule();
166:                    getProject().setProperty(propertyMatchingRule,
167:                            (value != null) ? value.toCode() : ""); //$NON-NLS-1$
168:                }
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.