Source Code Cross Referenced for PackageConfigScriptGenerator.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » build » packager » 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 » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.build.packager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 IBM Corporation and others. All rights reserved.
003:         * This program and the accompanying materials are made available under the
004:         * terms of the Eclipse Public License v1.0 which accompanies this distribution,
005:         * and is available at http://www.eclipse.org/legal/epl-v10.html
006:         * 
007:         * Contributors: IBM - Initial API and implementation
008:         ******************************************************************************/package org.eclipse.pde.internal.build.packager;
009:
010:        import java.io.*;
011:        import java.util.ArrayList;
012:        import java.util.Properties;
013:        import org.eclipse.core.runtime.*;
014:        import org.eclipse.osgi.service.resolver.BundleDescription;
015:        import org.eclipse.osgi.util.NLS;
016:        import org.eclipse.pde.internal.build.*;
017:        import org.eclipse.pde.internal.build.ant.FileSet;
018:        import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
019:        import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator;
020:        import org.eclipse.pde.internal.build.site.BuildTimeSiteContentProvider;
021:        import org.eclipse.update.core.IFeature;
022:
023:        public class PackageConfigScriptGenerator extends
024:                AssembleConfigScriptGenerator {
025:
026:            private Properties packagingProperties;
027:
028:            private String getFinalName(BundleDescription bundle, String shape) {
029:                final String JAR = "jar"; //$NON-NLS-1$
030:                final String DOT_JAR = '.' + JAR;
031:                if (!AbstractScriptGenerator
032:                        .getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER)) {
033:                    Path path = new Path(bundle.getLocation());
034:                    if (shape.equals(FILE)
035:                            && !JAR.equalsIgnoreCase(path.getFileExtension()))
036:                        return path.lastSegment().concat(DOT_JAR);
037:                    return path.lastSegment();
038:                }
039:                if (shape.equals(FILE))
040:                    return ModelBuildScriptGenerator.getNormalizedName(bundle)
041:                            + DOT_JAR;
042:                return ModelBuildScriptGenerator.getNormalizedName(bundle);
043:            }
044:
045:            private String getFinalName(IFeature feature) {
046:                if (!AbstractScriptGenerator
047:                        .getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER)) {
048:                    Path featurePath = new Path(feature.getURL().getPath());
049:                    return featurePath.segment(featurePath.segmentCount() - 2);
050:                }
051:                return FeatureBuildScriptGenerator.getNormalizedName(feature);
052:            }
053:
054:            protected void generateGatherBinPartsCalls() { //TODO Here we should try to use cp because otherwise we will loose the permissions
055:                String excludedFiles = null;
056:                if (AbstractScriptGenerator
057:                        .getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER))
058:                    excludedFiles = "build.properties, .project, .classpath"; //$NON-NLS-1$
059:                IPath baseLocation = null;
060:                try {
061:                    String url = ((BuildTimeSiteContentProvider) getSite(false)
062:                            .getSiteContentProvider()).getInstalledBaseURL();
063:                    if (url != null)
064:                        baseLocation = new Path(url);
065:                } catch (CoreException e) {
066:                    //nothing
067:                }
068:                for (int i = 0; i < plugins.length; i++) {
069:                    Path pluginLocation = new Path(plugins[i].getLocation());
070:                    String location = pluginLocation.toOSString();
071:                    boolean isFolder = isFolder(pluginLocation);
072:
073:                    //try to relate the plugin location to the ${baseLocation} property
074:                    if (baseLocation != null
075:                            && baseLocation.isPrefixOf(pluginLocation)) {
076:                        IPath relative = pluginLocation
077:                                .removeFirstSegments(baseLocation
078:                                        .segmentCount());
079:                        location = new Path(Utils
080:                                .getPropertyFormat(PROPERTY_BASE_LOCATION))
081:                                .append(relative).toOSString();
082:                    }
083:                    if (isFolder) {
084:                        script
085:                                .printCopyTask(
086:                                        null,
087:                                        Utils
088:                                                .getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
089:                                                + '/'
090:                                                + Utils
091:                                                        .getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX)
092:                                                + '/'
093:                                                + getFinalName(plugins[i],
094:                                                        FOLDER),
095:                                        new FileSet[] { new FileSet(location,
096:                                                null, null, null,
097:                                                excludedFiles, null, null) },
098:                                        false, false);
099:                    } else {
100:                        script
101:                                .printCopyFileTask(
102:                                        location,
103:                                        Utils
104:                                                .getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
105:                                                + '/'
106:                                                + Utils
107:                                                        .getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX)
108:                                                + '/'
109:                                                + getFinalName(plugins[i], FILE),
110:                                        false);
111:                    }
112:                }
113:
114:                for (int i = 0; i < features.length; i++) {
115:                    IPath featureLocation = new Path(features[i].getURL()
116:                            .getPath()); // Here we assume that all the features are local
117:                    featureLocation = featureLocation.removeLastSegments(1);
118:                    String location = featureLocation.toOSString();
119:                    if (baseLocation != null
120:                            && baseLocation.isPrefixOf(featureLocation)) {
121:                        IPath relative = featureLocation
122:                                .removeFirstSegments(baseLocation
123:                                        .segmentCount());
124:                        location = new Path(Utils
125:                                .getPropertyFormat(PROPERTY_BASE_LOCATION))
126:                                .append(relative).toOSString();
127:                    }
128:                    script
129:                            .printCopyTask(
130:                                    null,
131:                                    Utils
132:                                            .getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
133:                                            + '/'
134:                                            + Utils
135:                                                    .getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX)
136:                                            + '/' + getFinalName(features[i]),
137:                                    new FileSet[] { new FileSet(location, null,
138:                                            null, null, null, null, null) },
139:                                    false, false);
140:                }
141:
142:                if (packagingProperties.size() != 0) {
143:                    String filesToPackage = null;
144:                    filesToPackage = packagingProperties
145:                            .getProperty(ROOT, null);
146:                    if (filesToPackage != null)
147:                        filesToPackage += ',';
148:
149:                    String tmp = packagingProperties.getProperty(ROOT_PREFIX
150:                            + configInfo.toString("."), null); //$NON-NLS-1$
151:                    if (tmp != null)
152:                        filesToPackage += tmp;
153:
154:                    if (filesToPackage == null)
155:                        filesToPackage = "**/**"; //$NON-NLS-1$
156:
157:                    FileSet rootFiles = new FileSet(
158:                            Utils.getPropertyFormat("tempDirectory") + '/' + configInfo.toStringReplacingAny(".", ANY_STRING) + "/eclipse", null, filesToPackage, null, null, null, null); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
159:                    String target = Utils
160:                            .getPropertyFormat(PROPERTY_ECLIPSE_BASE)
161:                            + '/'
162:                            + configInfo.toStringReplacingAny(".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER); //$NON-NLS-1$
163:                    script.printCopyTask(null, target,
164:                            new FileSet[] { rootFiles }, false, false);
165:
166:                    Utils.generatePermissions(packagingProperties, configInfo,
167:                            PROPERTY_ECLIPSE_BASE, script);
168:
169:                    //This is need so that the call in assemble config script generator gather the root files 
170:                    rootFileProviders = new ArrayList(1);
171:                    rootFileProviders.add("elt"); //$NON-NLS-1$
172:                }
173:            }
174:
175:            public String getTargetName() {
176:                return "package" + (featureId.equals("") ? "" : ('.' + featureId)) + (configInfo.equals(Config.genericConfig()) ? "" : ('.' + configInfo.toStringReplacingAny(".", ANY_STRING))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ 
177:            }
178:
179:            private boolean isFolder(Path pluginLocation) {
180:                return pluginLocation.toFile().isDirectory();
181:            }
182:
183:            public void setPackagingPropertiesLocation(
184:                    String packagingPropertiesLocation) throws CoreException {
185:                packagingProperties = new Properties();
186:                if (packagingPropertiesLocation == null
187:                        || packagingPropertiesLocation.equals("")) //$NON-NLS-1$
188:                    return;
189:
190:                InputStream propertyStream = null;
191:                try {
192:                    propertyStream = new BufferedInputStream(
193:                            new FileInputStream(packagingPropertiesLocation));
194:                    try {
195:                        packagingProperties.load(new BufferedInputStream(
196:                                propertyStream));
197:                    } finally {
198:                        propertyStream.close();
199:                    }
200:                } catch (FileNotFoundException e) {
201:                    String message = NLS.bind(Messages.exception_readingFile,
202:                            packagingPropertiesLocation);
203:                    throw new CoreException(new Status(IStatus.ERROR,
204:                            PI_PDEBUILD, EXCEPTION_READING_FILE, message, e));
205:                } catch (IOException e) {
206:                    String message = NLS.bind(Messages.exception_readingFile,
207:                            packagingPropertiesLocation);
208:                    throw new CoreException(new Status(IStatus.ERROR,
209:                            PI_PDEBUILD, EXCEPTION_READING_FILE, message, e));
210:                }
211:            }
212:
213:            protected void generateGatherSourceCalls() {
214:                //In the packager, we do not gather source
215:            }
216:
217:            protected FileSet[] generatePermissions(boolean zip) {
218:                //In the packager there is nothing to do since, the features we are packaging are pre-built and do not have a build.properties
219:                return new FileSet[0];
220:            }
221:
222:            protected void generateGZipTarget(boolean assembling) {
223:                super .generateGZipTarget(false);
224:            }
225:
226:            public void generateTarGZTasks(boolean assembling) {
227:                super .generateTarGZTasks(false);
228:            }
229:
230:            protected Object[] getFinalShape(BundleDescription bundle) {
231:                if (AbstractScriptGenerator
232:                        .getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_PACKAGER_MODE) == true) {
233:                    String shape = isFolder(new Path(bundle.getLocation())) ? FOLDER
234:                            : FILE;
235:                    return new Object[] { getFinalName(bundle, shape), shape };
236:                }
237:                return super .getFinalShape(bundle);
238:            }
239:
240:            protected Object[] getFinalShape(IFeature feature) {
241:                if (AbstractScriptGenerator
242:                        .getPropertyAsBoolean(IBuildPropertiesConstants.PROPERTY_PACKAGER_MODE) == true)
243:                    return new Object[] { getFinalName(feature), FOLDER };
244:                return super.getFinalShape(feature);
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.