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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM - Initial API and implementation
010:         *     G&H Softwareentwicklung GmbH - internationalization implementation (bug 150933)
011:         *     Prosyst - create proper OSGi bundles (bug 174157)
012:         *******************************************************************************/package org.eclipse.pde.internal.build;
013:
014:        import java.io.File;
015:        import java.util.*;
016:        import org.eclipse.core.runtime.*;
017:        import org.eclipse.osgi.service.resolver.BundleDescription;
018:        import org.eclipse.pde.build.Constants;
019:        import org.eclipse.pde.internal.build.ant.*;
020:        import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator;
021:        import org.eclipse.update.core.IFeature;
022:        import org.eclipse.update.core.PluginEntry;
023:
024:        /**
025:         * Generate an assemble script for a given feature and a given config. It
026:         * generates all the instruction to zip the listed plugins and features.
027:         */
028:        public class AssembleConfigScriptGenerator extends
029:                AbstractScriptGenerator {
030:            protected String directory; // representing the directory where to generate the file
031:            protected String featureId;
032:            protected Config configInfo;
033:            protected IFeature[] features; // the features that will be assembled
034:            protected IFeature[] allFeatures; //the set of all the features that have been considered
035:            protected BundleDescription[] plugins;
036:            protected String filename;
037:            protected Collection rootFileProviders;
038:            protected Properties pluginsPostProcessingSteps;
039:            protected Properties featuresPostProcessingSteps;
040:            protected ArrayList addedByPermissions = new ArrayList(); //contains the list of files and folders that have been added to an archive by permission management
041:
042:            private static final String PROPERTY_SOURCE = "source"; //$NON-NLS-1$
043:            private static final String PROPERTY_ELEMENT_NAME = "elementName"; //$NON-NLS-1$
044:
045:            private static final String UPDATEJAR = "updateJar"; //$NON-NLS-1$
046:            private static final String FLAT = "flat"; //$NON-NLS-1$
047:
048:            private static final byte BUNDLE = 0;
049:            private static final byte FEATURE = 1;
050:
051:            protected static final String FOLDER = "folder"; //$NON-NLS-1$
052:            protected static final String FILE = "file"; //$NON-NLS-1$
053:            protected String PROPERTY_ECLIPSE_PLUGINS = "eclipse.plugins"; //$NON-NLS-1$
054:            protected String PROPERTY_ECLIPSE_FEATURES = "eclipse.features"; //$NON-NLS-1$
055:            private boolean signJars;
056:            private boolean generateJnlp;
057:
058:            private String archiveFormat;
059:            private boolean groupConfigs = false;
060:            private String product;
061:            private ProductFile productFile = null;
062:
063:            public AssembleConfigScriptGenerator() {
064:                super ();
065:            }
066:
067:            public void initialize(String directoryName, String feature,
068:                    Config configurationInformation, Collection elementList,
069:                    Collection featureList, Collection allFeaturesList,
070:                    Collection rootProviders) throws CoreException {
071:                this .directory = directoryName;
072:                this .featureId = feature;
073:                this .configInfo = configurationInformation;
074:                this .rootFileProviders = rootProviders != null ? rootProviders
075:                        : new ArrayList(0);
076:
077:                this .features = new IFeature[featureList.size()];
078:                featureList.toArray(this .features);
079:
080:                this .allFeatures = new IFeature[allFeaturesList.size()];
081:                allFeaturesList.toArray(this .allFeatures);
082:
083:                this .plugins = new BundleDescription[elementList.size()];
084:                this .plugins = (BundleDescription[]) elementList
085:                        .toArray(this .plugins);
086:
087:                openScript(directoryName, getTargetName() + ".xml"); //$NON-NLS-1$
088:                loadPostProcessingSteps();
089:            }
090:
091:            private void loadProduct() {
092:                if (product == null || product.startsWith("${")) { //$NON-NLS-1$
093:                    productFile = null;
094:                    return;
095:                }
096:                String productPath = findFile(product, false);
097:
098:                File f = null;
099:                if (productPath != null) {
100:                    f = new File(productPath);
101:                } else {
102:                    // couldn't find product, try it as a path directly
103:                    f = new File(product);
104:                    if (!f.exists() || !f.isFile()) {
105:                        // doesn't exist, try it as a path relative to the working directory
106:                        f = new File(getWorkingDirectory(), product);
107:                        if (!f.exists() || !f.isFile()) {
108:                            f = new File(getWorkingDirectory()
109:                                    + "/" + DEFAULT_PLUGIN_LOCATION, product); //$NON-NLS-1$
110:                        }
111:                    }
112:                }
113:                if (f.exists() && f.isFile()) {
114:                    try {
115:                        productFile = new ProductFile(f.getAbsolutePath(),
116:                                configInfo.getOs());
117:                    } catch (CoreException e) {
118:                        // TODO log
119:                    }
120:                } else {
121:                    //TODO log
122:                }
123:            }
124:
125:            private String computeIconsList() {
126:                String result = Utils
127:                        .getPropertyFormat(PROPERTY_LAUNCHER_ICONS);
128:                if (productFile == null)
129:                    return result;
130:                String[] icons = productFile.getIcons();
131:                for (int i = 0; i < icons.length; i++) {
132:                    String location = findFile(icons[i], true);
133:                    if (location != null)
134:                        result += ", " + Utils.getPropertyFormat(PROPERTY_BASEDIR) + '/' + location; //$NON-NLS-1$
135:                    else {
136:                        result += ", " + Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + DEFAULT_PLUGIN_LOCATION + '/' + icons[i]; //$NON-NLS-1$
137:                        result += ", " + Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + DEFAULT_FEATURE_LOCATION + '/' + icons[i]; //$NON-NLS-1$
138:                    }
139:                }
140:                return result;
141:            }
142:
143:            private void loadPostProcessingSteps() {
144:                try {
145:                    pluginsPostProcessingSteps = readProperties(
146:                            AbstractScriptGenerator.getWorkingDirectory(),
147:                            DEFAULT_PLUGINS_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR,
148:                            IStatus.INFO);
149:                    featuresPostProcessingSteps = readProperties(
150:                            AbstractScriptGenerator.getWorkingDirectory(),
151:                            DEFAULT_FEATURES_POSTPROCESSINGSTEPS_FILENAME_DESCRIPTOR,
152:                            IStatus.INFO);
153:                } catch (CoreException e) {
154:                    //Ignore
155:                }
156:            }
157:
158:            public void generate() {
159:                loadProduct();
160:                generatePrologue();
161:                generateInitializationSteps();
162:                generateGatherBinPartsCalls();
163:                if (embeddedSource)
164:                    generateGatherSourceCalls();
165:                generatePostProcessingSteps();
166:                generateBrandingCalls();
167:                generateArchivingSteps();
168:                generateEpilogue();
169:            }
170:
171:            /**
172:             * 
173:             */
174:            private void generateBrandingCalls() {
175:                String install = Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
176:                        + '/'
177:                        + configInfo.toStringReplacingAny(".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER); //$NON-NLS-1$
178:                script.printBrandTask(install, computeIconsList(), Utils
179:                        .getPropertyFormat(PROPERTY_LAUNCHER_NAME), Utils
180:                        .getPropertyFormat(PROPERTY_OS));
181:            }
182:
183:            private void generateArchivingSteps() {
184:                if (FORMAT_FOLDER.equalsIgnoreCase(archiveFormat)) {
185:                    generateMoveRootFiles();
186:                    return;
187:                }
188:
189:                if (FORMAT_ZIP.equalsIgnoreCase(archiveFormat)) {
190:                    generateZipTarget();
191:                    return;
192:                }
193:
194:                if (FORMAT_ANTZIP.equalsIgnoreCase(archiveFormat)) {
195:                    generateAntZipTarget();
196:                    return;
197:                }
198:
199:                if (FORMAT_ANTTAR.equalsIgnoreCase(archiveFormat)) {
200:                    generateAntTarTarget();
201:                    return;
202:                }
203:
204:                if (FORMAT_TAR.equalsIgnoreCase(archiveFormat)) {
205:                    generateTarGZTasks(true);
206:                    return;
207:                }
208:            }
209:
210:            private void generateMoveRootFiles() {
211:                if (rootFileProviders.size() == 0)
212:                    return;
213:
214:                for (Iterator iter = rootFileProviders.iterator(); iter
215:                        .hasNext();) {
216:                    Properties featureProperties = null;
217:                    try {
218:                        featureProperties = AbstractScriptGenerator
219:                                .readProperties(new Path(((IFeature) iter
220:                                        .next()).getURL().getFile())
221:                                        .removeLastSegments(1).toOSString(),
222:                                        PROPERTIES_FILE, IStatus.OK);
223:                        Utils.generatePermissions(featureProperties,
224:                                configInfo, PROPERTY_ECLIPSE_BASE, script);
225:                    } catch (CoreException e) {
226:                        //do nothing
227:                    }
228:                }
229:
230:                if (Platform.getOS().equals("win32")) { //$NON-NLS-1$
231:                    FileSet[] rootFiles = new FileSet[1];
232:                    rootFiles[0] = new FileSet(
233:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
234:                                    + '/'
235:                                    + configInfo.toStringReplacingAny(
236:                                            ".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER), null, "**/**", null, null, null, null); //$NON-NLS-1$//$NON-NLS-2$	
237:                    script.printMoveTask(Utils
238:                            .getPropertyFormat(PROPERTY_ECLIPSE_BASE),
239:                            rootFiles, false);
240:                    script.printDeleteTask(
241:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
242:                                    + '/'
243:                                    + configInfo.toStringReplacingAny(
244:                                            ".", ANY_STRING), null, null); //$NON-NLS-1$
245:                } else {
246:                    List params = new ArrayList(3);
247:                    params.add("-R"); //$NON-NLS-1$
248:                    params.add("."); //$NON-NLS-1$
249:                    params.add('\'' + Utils
250:                            .getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '\'');
251:                    String rootFileFolder = Utils
252:                            .getPropertyFormat(PROPERTY_ECLIPSE_BASE)
253:                            + '/'
254:                            + configInfo.toStringReplacingAny(".", ANY_STRING); //$NON-NLS-1$
255:                    script
256:                            .printExecTask(
257:                                    "cp", rootFileFolder + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER), params, null); //$NON-NLS-1$
258:                    script.printDeleteTask(rootFileFolder, null, null);
259:                }
260:            }
261:
262:            protected void generateGatherSourceCalls() {
263:                Map properties = new HashMap(1);
264:                properties.put(PROPERTY_DESTINATION_TEMP_FOLDER, Utils
265:                        .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS));
266:
267:                for (int i = 0; i < plugins.length; i++) {
268:                    BundleDescription plugin = plugins[i];
269:                    String placeToGather = getLocation(plugin);
270:
271:                    script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils
272:                            .makeRelative(new Path(placeToGather),
273:                                    new Path(workingDirectory)).toOSString(),
274:                            TARGET_GATHER_SOURCES, null, null, properties);
275:
276:                    Properties bundleProperties = (Properties) plugin
277:                            .getUserObject();
278:                    //Source code for plugins with . on the classpath must be put in a folder in the final jar.
279:                    if (bundleProperties.get(WITH_DOT) == Boolean.TRUE) {
280:                        String targetLocation = Utils
281:                                .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS)
282:                                + '/'
283:                                + ModelBuildScriptGenerator
284:                                        .getNormalizedName(plugin);
285:                        String targetLocationSrc = targetLocation + "/src"; //$NON-NLS-1$
286:
287:                        //Find the source zip where it has been gathered and extract it in a folder  
288:                        script
289:                                .println("<unzip dest=\"" + AntScript.getEscaped(targetLocationSrc) + "\">"); //$NON-NLS-1$//$NON-NLS-2$
290:                        script
291:                                .println("\t<fileset dir=\"" + AntScript.getEscaped(targetLocation) + "\" includes=\"**/*src.zip\" casesensitive=\"false\"/>"); //$NON-NLS-1$//$NON-NLS-2$
292:                        script.println("</unzip>"); //$NON-NLS-1$
293:
294:                        //	Delete the source zip where it has been gathered since we extracted it
295:                        script
296:                                .printDeleteTask(
297:                                        null,
298:                                        null,
299:                                        new FileSet[] { new FileSet(
300:                                                targetLocation,
301:                                                null,
302:                                                "**/*src.zip", null, null, null, "false") }); //$NON-NLS-1$ //$NON-NLS-2$//$NON-bNLS-3$
303:                    }
304:                }
305:
306:                properties = new HashMap(1);
307:                properties.put(PROPERTY_FEATURE_BASE, Utils
308:                        .getPropertyFormat(PROPERTY_ECLIPSE_BASE));
309:                for (int i = 0; i < features.length; i++) {
310:                    IFeature feature = features[i];
311:                    String placeToGather = feature.getURL().getPath();
312:                    int j = placeToGather
313:                            .lastIndexOf(Constants.FEATURE_FILENAME_DESCRIPTOR);
314:                    if (j != -1)
315:                        placeToGather = placeToGather.substring(0, j);
316:                    script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils
317:                            .makeRelative(new Path(placeToGather),
318:                                    new Path(workingDirectory)).toOSString(),
319:                            TARGET_GATHER_SOURCES, null, null, properties);
320:                }
321:            }
322:
323:            protected void generatePackagingTargets() {
324:                String fileName = Utils.getPropertyFormat(PROPERTY_SOURCE)
325:                        + '/' + Utils.getPropertyFormat(PROPERTY_ELEMENT_NAME);
326:                String fileExists = Utils.getPropertyFormat(PROPERTY_SOURCE)
327:                        + '/' + Utils.getPropertyFormat(PROPERTY_ELEMENT_NAME)
328:                        + "_exists"; //$NON-NLS-1$
329:
330:                script.printComment("Beginning of the jarUp task"); //$NON-NLS-1$
331:                script.printTargetDeclaration(TARGET_JARUP, null, null, null,
332:                        Messages.assemble_jarUp);
333:                script.printAvailableTask(fileExists, fileName);
334:                Map params = new HashMap(2);
335:                params.put(PROPERTY_SOURCE, Utils
336:                        .getPropertyFormat(PROPERTY_SOURCE));
337:                params.put(PROPERTY_ELEMENT_NAME, Utils
338:                        .getPropertyFormat(PROPERTY_ELEMENT_NAME));
339:                script.printAntCallTask(TARGET_JARING, true, params);
340:                script.printTargetEnd();
341:
342:                script.printTargetDeclaration(TARGET_JARING, null, fileExists,
343:                        null, null);
344:                script.printJarTask(fileName + ".jar", fileName, null, "merge"); //$NON-NLS-1$ //$NON-NLS-2$
345:                script.printDeleteTask(fileName, null, null);
346:
347:                script.printTargetEnd();
348:                script.printComment("End of the jarUp task"); //$NON-NLS-1$
349:
350:                script.printComment("Beginning of the jar signing  target"); //$NON-NLS-1$
351:                script.printTargetDeclaration(TARGET_JARSIGNING, null, null,
352:                        null, Messages.sign_Jar);
353:                if (generateJnlp)
354:                    script.printProperty(PROPERTY_UNSIGN, "true"); //$NON-NLS-1$
355:                script
356:                        .println("<eclipse.jarProcessor sign=\"" + Utils.getPropertyFormat(PROPERTY_SIGN) + "\" pack=\"" + Utils.getPropertyFormat(PROPERTY_PACK) + "\" unsign=\"" + Utils.getPropertyFormat(PROPERTY_UNSIGN) + "\" jar=\"" + fileName + ".jar" + "\" alias=\"" + Utils.getPropertyFormat(PROPERTY_SIGN_ALIAS) + "\" keystore=\"" + Utils.getPropertyFormat(PROPERTY_SIGN_KEYSTORE) + "\" storepass=\"" + Utils.getPropertyFormat(PROPERTY_SIGN_STOREPASS) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ 
357:                script.printTargetEnd();
358:                script.printComment("End of the jarUp task"); //$NON-NLS-1$
359:            }
360:
361:            protected void generateGZipTarget(boolean assembling) {
362:                //during the assemble stage, only zip if we aren't running the packager
363:                script.printTargetDeclaration(TARGET_GZIP_RESULTS, null, null,
364:                        assembling ? PROPERTY_RUN_PACKAGER : null, null);
365:                script.println("<move file=\"" //$NON-NLS-1$
366:                        + Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH)
367:                        + "\" tofile=\"" //$NON-NLS-1$
368:                        + Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
369:                        + '/'
370:                        + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER)
371:                        + "/tmp.tar\"/>"); //$NON-NLS-1$
372:                script.printGZip(Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
373:                        + '/'
374:                        + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER)
375:                        + "/tmp.tar", //$NON-NLS-1$ 
376:                        Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH));
377:                script.printTargetEnd();
378:            }
379:
380:            protected void generatePrologue() {
381:                script.printProjectDeclaration(
382:                        "Assemble " + featureId, TARGET_MAIN, null); //$NON-NLS-1$  
383:                script.printProperty(PROPERTY_ARCHIVE_NAME,
384:                        computeArchiveName());
385:                script.printProperty(PROPERTY_OS, configInfo.getOs());
386:                script.printProperty(PROPERTY_WS, configInfo.getWs());
387:                script.printProperty(PROPERTY_ARCH, configInfo.getArch());
388:                script.printProperty(PROPERTY_SIGN, (signJars ? Boolean.TRUE
389:                        : Boolean.FALSE).toString());
390:                script.printProperty(PROPERTY_ASSEMBLY_TMP, Utils
391:                        .getPropertyFormat(PROPERTY_BUILD_DIRECTORY)
392:                        + "/tmp"); //$NON-NLS-1$
393:                script.printProperty(PROPERTY_ECLIPSE_BASE, Utils
394:                        .getPropertyFormat(PROPERTY_ASSEMBLY_TMP)
395:                        + '/'
396:                        + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER));
397:                script.printProperty(PROPERTY_ECLIPSE_PLUGINS, Utils
398:                        .getPropertyFormat(PROPERTY_ECLIPSE_BASE)
399:                        + '/' + DEFAULT_PLUGIN_LOCATION);
400:                script.printProperty(PROPERTY_ECLIPSE_FEATURES, Utils
401:                        .getPropertyFormat(PROPERTY_ECLIPSE_BASE)
402:                        + '/' + DEFAULT_FEATURE_LOCATION);
403:                script.printProperty(PROPERTY_ARCHIVE_FULLPATH, Utils
404:                        .getPropertyFormat(PROPERTY_BASEDIR)
405:                        + '/'
406:                        + Utils.getPropertyFormat(PROPERTY_BUILD_LABEL)
407:                        + '/' + Utils.getPropertyFormat(PROPERTY_ARCHIVE_NAME));
408:                if (productFile != null
409:                        && productFile.getLauncherName() != null)
410:                    script.printProperty(PROPERTY_LAUNCHER_NAME, productFile
411:                            .getLauncherName());
412:                script.printProperty(PROPERTY_TAR_ARGS, ""); //$NON-NLS-1$
413:                generatePackagingTargets();
414:                script.printTargetDeclaration(TARGET_MAIN, null, null, null,
415:                        null);
416:            }
417:
418:            private void generateInitializationSteps() {
419:                if (BundleHelper.getDefault().isDebugging()) {
420:                    script
421:                            .printEchoTask("basedir : " + Utils.getPropertyFormat(PROPERTY_BASEDIR)); //$NON-NLS-1$
422:                    script
423:                            .printEchoTask("assemblyTempDir : " + Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP)); //$NON-NLS-1$
424:                    script
425:                            .printEchoTask("eclipse.base : " + Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)); //$NON-NLS-1$
426:                    script
427:                            .printEchoTask("collectingFolder : " + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER)); //$NON-NLS-1$
428:                    script
429:                            .printEchoTask("archivePrefix : " + Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX)); //$NON-NLS-1$
430:                }
431:
432:                script
433:                        .println("<condition property=\"" + PROPERTY_PLUGIN_ARCHIVE_PREFIX + "\" value=\"" + DEFAULT_PLUGIN_LOCATION + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
434:                script
435:                        .println("\t<equals arg1=\"" + Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + "\"  arg2=\"\" trim=\"true\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ 
436:                script.println("</condition>"); //$NON-NLS-1$
437:                script.printProperty(PROPERTY_PLUGIN_ARCHIVE_PREFIX, Utils
438:                        .getPropertyFormat(PROPERTY_ARCHIVE_PREFIX)
439:                        + '/' + DEFAULT_PLUGIN_LOCATION);
440:
441:                script.println();
442:                script
443:                        .println("<condition property=\"" + PROPERTY_FEATURE_ARCHIVE_PREFIX + "\" value=\"" + DEFAULT_FEATURE_LOCATION + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
444:                script
445:                        .println("\t<equals arg1=\"" + Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + "\"  arg2=\"\" trim=\"true\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ 
446:                script.println("</condition>"); //$NON-NLS-1$
447:                script.printProperty(PROPERTY_FEATURE_ARCHIVE_PREFIX, Utils
448:                        .getPropertyFormat(PROPERTY_ARCHIVE_PREFIX)
449:                        + '/' + DEFAULT_FEATURE_LOCATION);
450:
451:                script.println();
452:
453:                script.printDirName(PROPERTY_ARCHIVE_PARENT, Utils
454:                        .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH));
455:                script.printMkdirTask(Utils
456:                        .getPropertyFormat(PROPERTY_ARCHIVE_PARENT));
457:                script.printMkdirTask(Utils
458:                        .getPropertyFormat(PROPERTY_ASSEMBLY_TMP));
459:                script.printMkdirTask(Utils
460:                        .getPropertyFormat(PROPERTY_BUILD_LABEL));
461:            }
462:
463:            protected void generatePostProcessingSteps() {
464:                for (int i = 0; i < plugins.length; i++) {
465:                    BundleDescription plugin = plugins[i];
466:                    generatePostProcessingSteps(plugin.getSymbolicName(),
467:                            plugin.getVersion().toString(),
468:                            (String) getFinalShape(plugin)[1], BUNDLE);
469:                }
470:
471:                for (int i = 0; i < features.length; i++) {
472:                    IFeature feature = features[i];
473:                    generatePostProcessingSteps(feature
474:                            .getVersionedIdentifier().getIdentifier(), feature
475:                            .getVersionedIdentifier().getVersion().toString(),
476:                            (String) getFinalShape(feature)[1], FEATURE);
477:                }
478:            }
479:
480:            protected void generateGatherBinPartsCalls() {
481:                Map properties = new HashMap(1);
482:                properties.put(PROPERTY_DESTINATION_TEMP_FOLDER, Utils
483:                        .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS));
484:                for (int i = 0; i < plugins.length; i++) {
485:                    BundleDescription plugin = plugins[i];
486:                    String placeToGather = getLocation(plugin);
487:                    script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils
488:                            .makeRelative(new Path(placeToGather),
489:                                    new Path(workingDirectory)).toOSString(),
490:                            TARGET_GATHER_BIN_PARTS, null, null, properties);
491:                }
492:
493:                properties = new HashMap(1);
494:                properties.put(PROPERTY_FEATURE_BASE, Utils
495:                        .getPropertyFormat(PROPERTY_ECLIPSE_BASE));
496:                for (int i = 0; i < features.length; i++) {
497:                    IFeature feature = features[i];
498:                    String placeToGather = feature.getURL().getPath();
499:                    int j = placeToGather
500:                            .lastIndexOf(Constants.FEATURE_FILENAME_DESCRIPTOR);
501:                    if (j != -1)
502:                        placeToGather = placeToGather.substring(0, j);
503:                    script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils
504:                            .makeRelative(new Path(placeToGather),
505:                                    new Path(workingDirectory)).toOSString(),
506:                            TARGET_GATHER_BIN_PARTS, null, null, properties);
507:                }
508:
509:                //This will generate gather.bin.parts call to features that provides files for the root
510:                properties = new HashMap(1);
511:                properties.put(PROPERTY_FEATURE_BASE, Utils
512:                        .getPropertyFormat(PROPERTY_ECLIPSE_BASE));
513:                for (Iterator iter = rootFileProviders.iterator(); iter
514:                        .hasNext();) {
515:                    IFeature feature = (IFeature) iter.next();
516:                    String placeToGather = feature.getURL().getPath();
517:                    int j = placeToGather
518:                            .lastIndexOf(Constants.FEATURE_FILENAME_DESCRIPTOR);
519:                    if (j != -1)
520:                        placeToGather = placeToGather.substring(0, j);
521:                    script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils
522:                            .makeRelative(new Path(placeToGather),
523:                                    new Path(workingDirectory)).toOSString(),
524:                            TARGET_GATHER_BIN_PARTS, null, null, properties);
525:                }
526:            }
527:
528:            private void generateSignJarCall(String name, String version,
529:                    byte type) {
530:                if (!signJars)
531:                    return;
532:                Map properties = new HashMap(2);
533:                properties.put(PROPERTY_SOURCE, type == BUNDLE ? Utils
534:                        .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) : Utils
535:                        .getPropertyFormat(PROPERTY_ECLIPSE_FEATURES));
536:                properties.put(PROPERTY_ELEMENT_NAME, name + '_' + version);
537:                script.printAntCallTask(TARGET_JARSIGNING, true, properties);
538:            }
539:
540:            //generate the appropriate postProcessingCall
541:            private void generatePostProcessingSteps(String name,
542:                    String version, String style, byte type) {
543:                if (FOLDER.equalsIgnoreCase(style))
544:                    return;
545:                if (FILE.equalsIgnoreCase(style)) {
546:                    generateJarUpCall(name, version, type);
547:                    generateSignJarCall(name, version, type);
548:                    generateJNLPCall(name, version, type);
549:                    return;
550:                }
551:            }
552:
553:            private void generateJNLPCall(String name, String version, byte type) {
554:                if (generateJnlp == false)
555:                    return;
556:                if (type != FEATURE)
557:                    return;
558:
559:                String dir = type == BUNDLE ? Utils
560:                        .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) : Utils
561:                        .getPropertyFormat(PROPERTY_ECLIPSE_FEATURES);
562:                String location = dir + '/' + name + '_' + version + ".jar"; //$NON-NLS-1$
563:                script
564:                        .println("<eclipse.jnlpGenerator feature=\"" + AntScript.getEscaped(location) + "\"  codebase=\"" + Utils.getPropertyFormat(PROPERTY_JNLP_CODEBASE) + "\" j2se=\"" + Utils.getPropertyFormat(PROPERTY_JNLP_J2SE) + "\" locale=\"" + Utils.getPropertyFormat(PROPERTY_JNLP_LOCALE) + "\" generateOfflineAllowed=\"" + Utils.getPropertyFormat(PROPERTY_JNLP_GENOFFLINE) + "\" configInfo=\"" + Utils.getPropertyFormat(PROPERTY_JNLP_CONFIGS) + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
565:            }
566:
567:            private boolean getUnpackClause(BundleDescription bundle) {
568:                Set entries = (Set) ((Properties) bundle.getUserObject())
569:                        .get(PLUGIN_ENTRY);
570:                return ((PluginEntry) entries.iterator().next()).isUnpack();
571:            }
572:
573:            protected Object[] getFinalShape(BundleDescription bundle) {
574:                String style = getUnpackClause(bundle) ? FLAT : UPDATEJAR;
575:                return getFinalShape(bundle.getSymbolicName(), bundle
576:                        .getVersion().toString(), style, BUNDLE);
577:            }
578:
579:            protected Object[] getFinalShape(IFeature feature) {
580:                return getFinalShape(feature.getVersionedIdentifier()
581:                        .getIdentifier(), feature.getVersionedIdentifier()
582:                        .getVersion().toString(), FLAT, FEATURE);
583:            }
584:
585:            protected Object[] getFinalShape(String name, String version,
586:                    String initialShape, byte type) {
587:                String style = initialShape;
588:                style = getShapeOverride(name, type, style);
589:
590:                if (FLAT.equalsIgnoreCase(style)) {
591:                    //do nothing
592:                    return new Object[] { name + '_' + version, FOLDER };
593:                }
594:                if (UPDATEJAR.equalsIgnoreCase(style)) {
595:                    return new Object[] { name + '_' + version + ".jar", FILE }; //$NON-NLS-1$
596:                }
597:                return new Object[] { name + '_' + version, FOLDER };
598:            }
599:
600:            private String getShapeOverride(String name, byte type,
601:                    String initialStyle) {
602:                String result = initialStyle;
603:                Properties currentProperties = type == BUNDLE ? pluginsPostProcessingSteps
604:                        : featuresPostProcessingSteps;
605:                if (currentProperties.size() > 0) {
606:                    String styleFromFile = currentProperties.getProperty(name);
607:                    if (styleFromFile == null)
608:                        styleFromFile = currentProperties
609:                                .getProperty(DEFAULT_FINAL_SHAPE);
610:                    result = styleFromFile;
611:                }
612:                if (forceUpdateJarFormat)
613:                    result = UPDATEJAR;
614:                return result;
615:            }
616:
617:            private void generateJarUpCall(String name, String version,
618:                    byte type) {
619:                Map properties = new HashMap(2);
620:                properties.put(PROPERTY_SOURCE, type == BUNDLE ? Utils
621:                        .getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) : Utils
622:                        .getPropertyFormat(PROPERTY_ECLIPSE_FEATURES));
623:                properties.put(PROPERTY_ELEMENT_NAME, name + '_' + version);
624:                script.printAntCallTask(TARGET_JARUP, true, properties);
625:            }
626:
627:            private void generateEpilogue() {
628:                if (!FORMAT_FOLDER.equalsIgnoreCase(archiveFormat))
629:                    script.printDeleteTask(Utils
630:                            .getPropertyFormat(PROPERTY_ASSEMBLY_TMP), null,
631:                            null);
632:                script.printTargetEnd();
633:                if (FORMAT_TAR.equalsIgnoreCase(archiveFormat))
634:                    generateGZipTarget(true);
635:                script.printProjectEnd();
636:                script.close();
637:                script = null;
638:            }
639:
640:            public String getTargetName() {
641:                return DEFAULT_ASSEMBLE_NAME
642:                        + (featureId.equals("") ? "" : ('.' + featureId)) + (configInfo.equals(Config.genericConfig()) ? "" : ('.' + configInfo.toStringReplacingAny(".", ANY_STRING))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
643:            }
644:
645:            private void generateZipTarget() {
646:                final int parameterSize = 15;
647:                List parameters = new ArrayList(parameterSize + 1);
648:                for (int i = 0; i < plugins.length; i++) {
649:                    parameters.add(Utils
650:                            .getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX)
651:                            + '/' + (String) getFinalShape(plugins[i])[0]);
652:                    if (i % parameterSize == 0) {
653:                        createZipExecCommand(parameters);
654:                        parameters.clear();
655:                    }
656:                }
657:                if (!parameters.isEmpty()) {
658:                    createZipExecCommand(parameters);
659:                    parameters.clear();
660:                }
661:
662:                if (!parameters.isEmpty()) {
663:                    createZipExecCommand(parameters);
664:                    parameters.clear();
665:                }
666:
667:                for (int i = 0; i < features.length; i++) {
668:                    parameters.add(Utils
669:                            .getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX)
670:                            + '/' + (String) getFinalShape(features[i])[0]);
671:                    if (i % parameterSize == 0) {
672:                        createZipExecCommand(parameters);
673:                        parameters.clear();
674:                    }
675:                }
676:                if (!parameters.isEmpty()) {
677:                    createZipExecCommand(parameters);
678:                    parameters.clear();
679:                }
680:
681:                createZipRootFileCommand();
682:            }
683:
684:            /**
685:             *  Zip the root files
686:             */
687:            private void createZipRootFileCommand() {
688:                if (rootFileProviders.size() == 0)
689:                    return;
690:
691:                List parameters = new ArrayList(1);
692:                parameters
693:                        .add("-r -q ${zipargs} '" + Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH) + "' . "); //$NON-NLS-1$ //$NON-NLS-2$
694:                script
695:                        .printExecTask(
696:                                "zip", Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + configInfo.toStringReplacingAny(".", ANY_STRING), parameters, null); //$NON-NLS-1$ //$NON-NLS-2$ 
697:            }
698:
699:            private void createZipExecCommand(List parameters) {
700:                parameters
701:                        .add(
702:                                0,
703:                                "-r -q " + Utils.getPropertyFormat(PROPERTY_ZIP_ARGS) + " '" + Utils.getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH) + '\''); //$NON-NLS-1$ //$NON-NLS-2$
704:                script
705:                        .printExecTask(
706:                                "zip", Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP), parameters, null); //$NON-NLS-1$ 
707:            }
708:
709:            protected String computeArchiveName() {
710:                String extension = (FORMAT_TAR.equalsIgnoreCase(archiveFormat) || FORMAT_ANTTAR
711:                        .equalsIgnoreCase(archiveFormat)) ? ".tar.gz" : ".zip"; //$NON-NLS-1$ //$NON-NLS-2$
712:                return featureId
713:                        + "-" + Utils.getPropertyFormat(PROPERTY_BUILD_ID_PARAM) + (configInfo.equals(Config.genericConfig()) ? "" : ("-" + configInfo.toStringReplacingAny(".", ANY_STRING))) + extension; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
714:            }
715:
716:            public void generateTarGZTasks(boolean assembling) {
717:                //This task only supports creation of archive with eclipse at the root 
718:                //Need to do the copy using cp because of the link
719:                List parameters = new ArrayList(2);
720:                if (rootFileProviders.size() > 0) {
721:                    parameters
722:                            .add("-r '" + Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + configInfo.toStringReplacingAny(".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + "' '" + Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP) + '\''); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$  
723:                    script
724:                            .printExecTask(
725:                                    "cp", Utils.getPropertyFormat(PROPERTY_BASEDIR), parameters, null); //$NON-NLS-1$
726:
727:                    parameters.clear();
728:                    parameters
729:                            .add("-rf '" + Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER) + '/' + configInfo.toStringReplacingAny(".", ANY_STRING) + '\''); //$NON-NLS-1$ //$NON-NLS-2$
730:                    script
731:                            .printExecTask(
732:                                    "rm", Utils.getPropertyFormat(PROPERTY_BASEDIR), parameters, null); //$NON-NLS-1$
733:                }
734:                parameters.clear();
735:                String tarArgs = assembling ? "-cvf '" : "-rvf '"; //$NON-NLS-1$//$NON-NLS-2$
736:                parameters
737:                        .add(Utils.getPropertyFormat(PROPERTY_TAR_ARGS)
738:                                + tarArgs
739:                                + Utils
740:                                        .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH)
741:                                + "' " + Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + ' '); //$NON-NLS-1$
742:                script
743:                        .printExecTask(
744:                                "tar", Utils.getPropertyFormat(PROPERTY_ASSEMBLY_TMP), parameters, null); //$NON-NLS-1$ 
745:
746:                script.printAntCallTask(TARGET_GZIP_RESULTS, true, null);
747:
748:                List args = new ArrayList(2);
749:                args.add("-rf"); //$NON-NLS-1$
750:                args
751:                        .add('\'' + Utils
752:                                .getPropertyFormat(PROPERTY_ASSEMBLY_TMP) + '\'');
753:                script.printExecTask("rm", null, args, null); //$NON-NLS-1$
754:            }
755:
756:            //TODO this code and the generateAntTarTarget() should be refactored using a factory or something like that.
757:            protected void generateAntZipTarget() {
758:                FileSet[] filesPlugins = new FileSet[plugins.length];
759:                for (int i = 0; i < plugins.length; i++) {
760:                    Object[] shape = getFinalShape(plugins[i]);
761:                    filesPlugins[i] = new ZipFileSet(
762:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
763:                                    + '/' + DEFAULT_PLUGIN_LOCATION + '/'
764:                                    + (String) shape[0],
765:                            shape[1] == FILE,
766:                            null,
767:                            null,
768:                            null,
769:                            null,
770:                            null,
771:                            Utils
772:                                    .getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX)
773:                                    + '/' + (String) shape[0], null, null);
774:                }
775:                if (plugins.length != 0)
776:                    script.printZipTask(Utils
777:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
778:                            null, false, true, filesPlugins);
779:
780:                FileSet[] filesFeatures = new FileSet[features.length];
781:                for (int i = 0; i < features.length; i++) {
782:                    Object[] shape = getFinalShape(features[i]);
783:                    filesFeatures[i] = new ZipFileSet(
784:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
785:                                    + '/' + DEFAULT_FEATURE_LOCATION + '/'
786:                                    + (String) shape[0],
787:                            shape[1] == FILE,
788:                            null,
789:                            null,
790:                            null,
791:                            null,
792:                            null,
793:                            Utils
794:                                    .getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX)
795:                                    + '/' + (String) shape[0], null, null);
796:                }
797:                if (features.length != 0)
798:                    script.printZipTask(Utils
799:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
800:                            null, false, true, filesFeatures);
801:
802:                if (rootFileProviders.size() == 0)
803:                    return;
804:
805:                if (groupConfigs) {
806:                    List allConfigs = getConfigInfos();
807:                    FileSet[] rootFiles = new FileSet[allConfigs.size()];
808:                    int i = 0;
809:                    for (Iterator iter = allConfigs.iterator(); iter.hasNext();) {
810:                        Config elt = (Config) iter.next();
811:                        rootFiles[i++] = new ZipFileSet(
812:                                Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
813:                                        + '/'
814:                                        + elt.toStringReplacingAny(
815:                                                ".", ANY_STRING), false, null, "**/**", null, null, null, elt.toStringReplacingAny(".", ANY_STRING), null, null); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
816:                    }
817:                    script.printZipTask(Utils
818:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
819:                            null, false, true, rootFiles);
820:                } else {
821:                    FileSet[] permissionSets = generatePermissions(true);
822:                    FileSet[] rootFiles = new FileSet[permissionSets.length + 1];
823:                    String toExcludeFromArchive = Utils
824:                            .getStringFromCollection(this .addedByPermissions,
825:                                    ","); //$NON-NLS-1$
826:                    System.arraycopy(permissionSets, 0, rootFiles, 1,
827:                            permissionSets.length);
828:                    rootFiles[0] = new ZipFileSet(
829:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
830:                                    + '/'
831:                                    + configInfo.toStringReplacingAny(
832:                                            ".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER), false, null, "**/**", null, toExcludeFromArchive, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX), null, null); //$NON-NLS-1$//$NON-NLS-2$
833:                    script.printZipTask(Utils
834:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
835:                            null, false, true, rootFiles);
836:                }
837:            }
838:
839:            protected FileSet[] generatePermissions(boolean zip) {
840:                String configInfix = configInfo.toString("."); //$NON-NLS-1$
841:                String prefixPermissions = ROOT_PREFIX + configInfix + '.'
842:                        + PERMISSIONS + '.';
843:                String commonPermissions = ROOT_PREFIX + PERMISSIONS + '.';
844:                ArrayList fileSets = new ArrayList();
845:
846:                for (Iterator iter = rootFileProviders.iterator(); iter
847:                        .hasNext();) {
848:                    Properties featureProperties = null;
849:                    try {
850:                        featureProperties = AbstractScriptGenerator
851:                                .readProperties(new Path(((IFeature) iter
852:                                        .next()).getURL().getFile())
853:                                        .removeLastSegments(1).toOSString(),
854:                                        PROPERTIES_FILE, IStatus.OK);
855:                    } catch (CoreException e) {
856:                        return new FileSet[0];
857:                    }
858:
859:                    for (Iterator iter2 = featureProperties.entrySet()
860:                            .iterator(); iter2.hasNext();) {
861:                        Map.Entry permission = (Map.Entry) iter2.next();
862:                        String instruction = (String) permission.getKey();
863:                        String parameters = (String) permission.getValue();
864:                        String[] values = Utils.getArrayFromString(parameters);
865:                        for (int i = 0; i < values.length; i++) {
866:                            boolean isFile = !values[i].endsWith("/"); //$NON-NLS-1$
867:                            String prefix = Utils
868:                                    .getPropertyFormat(PROPERTY_ECLIPSE_BASE)
869:                                    + '/'
870:                                    + configInfo.toStringReplacingAny(
871:                                            ".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER); //$NON-NLS-1$
872:                            if (instruction.startsWith(prefixPermissions)) {
873:                                addedByPermissions.add(values[i]);
874:                                if (zip)
875:                                    fileSets
876:                                            .add(new ZipFileSet(
877:                                                    prefix
878:                                                            + (isFile ? '/' + values[i]
879:                                                                    : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
880:                                else
881:                                    fileSets
882:                                            .add(new TarFileSet(
883:                                                    prefix
884:                                                            + (isFile ? '/' + values[i]
885:                                                                    : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
886:                                continue;
887:                            }
888:                            if (instruction.startsWith(commonPermissions)) {
889:                                addedByPermissions.add(values[i]);
890:                                if (zip)
891:                                    fileSets
892:                                            .add(new ZipFileSet(
893:                                                    prefix
894:                                                            + (isFile ? '/' + values[i]
895:                                                                    : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
896:                                else
897:                                    fileSets
898:                                            .add(new TarFileSet(
899:                                                    prefix
900:                                                            + (isFile ? '/' + values[i]
901:                                                                    : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
902:                                continue;
903:                            }
904:                        }
905:                    }
906:                }
907:                return (FileSet[]) fileSets
908:                        .toArray(new FileSet[fileSets.size()]);
909:            }
910:
911:            //TODO this code andn the generateAntZipTarget() should be refactored using a factory or something like that.
912:            private void generateAntTarTarget() {
913:                FileSet[] filesPlugins = new FileSet[plugins.length];
914:                for (int i = 0; i < plugins.length; i++) {
915:                    Object[] shape = getFinalShape(plugins[i]);
916:                    filesPlugins[i] = new TarFileSet(
917:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
918:                                    + '/' + DEFAULT_PLUGIN_LOCATION + '/'
919:                                    + (String) shape[0],
920:                            shape[1] == FILE,
921:                            null,
922:                            null,
923:                            null,
924:                            null,
925:                            null,
926:                            Utils
927:                                    .getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX)
928:                                    + '/' + (String) shape[0], null, null);
929:                }
930:                if (plugins.length != 0)
931:                    script.printTarTask(Utils
932:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
933:                            null, false, true, filesPlugins);
934:
935:                FileSet[] filesFeatures = new FileSet[features.length];
936:                for (int i = 0; i < features.length; i++) {
937:                    Object[] shape = getFinalShape(features[i]);
938:                    filesFeatures[i] = new TarFileSet(
939:                            Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
940:                                    + '/' + DEFAULT_FEATURE_LOCATION + '/'
941:                                    + (String) shape[0],
942:                            shape[1] == FILE,
943:                            null,
944:                            null,
945:                            null,
946:                            null,
947:                            null,
948:                            Utils
949:                                    .getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX)
950:                                    + '/' + (String) shape[0], null, null);
951:                }
952:                if (features.length != 0)
953:                    script.printTarTask(Utils
954:                            .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH),
955:                            null, false, true, filesFeatures);
956:
957:                if (rootFileProviders.size() == 0)
958:                    return;
959:
960:                FileSet[] permissionSets = generatePermissions(false);
961:                FileSet[] rootFiles = new FileSet[permissionSets.length + 1];
962:                System.arraycopy(permissionSets, 0, rootFiles, 1,
963:                        permissionSets.length);
964:                rootFiles[0] = new TarFileSet(
965:                        Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE)
966:                                + '/'
967:                                + configInfo.toStringReplacingAny(
968:                                        ".", ANY_STRING) + '/' + Utils.getPropertyFormat(PROPERTY_COLLECTING_FOLDER), false, null, "**/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX), null, null); //$NON-NLS-1$//$NON-NLS-2$
969:                script.printTarTask(Utils
970:                        .getPropertyFormat(PROPERTY_ARCHIVE_FULLPATH), null,
971:                        false, true, rootFiles);
972:            }
973:
974:            public void setGenerateJnlp(boolean value) {
975:                generateJnlp = value;
976:            }
977:
978:            public void setSignJars(boolean value) {
979:                signJars = value;
980:            }
981:
982:            public void setProduct(String value) {
983:                product = value;
984:            }
985:
986:            public void setArchiveFormat(String archiveFormat) {
987:                this .archiveFormat = archiveFormat;
988:            }
989:
990:            public void setGroupConfigs(boolean group) {
991:                groupConfigs = group;
992:            }
993:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.