KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > packager > PackageScriptGenerator


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.packager;
12
13 import java.util.*;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.pde.internal.build.*;
16
17 public class PackageScriptGenerator extends AssembleScriptGenerator {
18     private String JavaDoc packagingPropertiesLocation;
19     private boolean backwardCompatibleName = false;
20     
21     public PackageScriptGenerator(String JavaDoc directory, AssemblyInformation assemblageInformation, String JavaDoc featureId) {
22         super(directory, assemblageInformation, featureId);
23     }
24     
25     protected void printProjectDeclaration() {
26         script.printProjectDeclaration("Package all config of " + featureId, TARGET_MAIN, null); //$NON-NLS-1$
27
}
28     
29     protected AssembleConfigScriptGenerator getConfigScriptGenerator() {
30         return new PackageConfigScriptGenerator();
31     }
32     
33     protected String JavaDoc getScriptName() {
34         if (backwardCompatibleName)
35             return "package" + '.' + DEFAULT_ASSEMBLE_ALL;
36         return "package" + '.' + (featureId.equals("") ? "" : featureId + '.') + DEFAULT_ASSEMBLE_ALL;
37     }
38     
39     public void setPropertyFile(String JavaDoc propertyFile) {
40         packagingPropertiesLocation = propertyFile;
41     }
42
43     protected Collection[] getConfigInfos(Config aConfig) {
44         return new Collection[] {assemblageInformation.getBinaryPlugins(aConfig), assemblageInformation.getBinaryFeatures(aConfig), assemblageInformation.getFeatures(aConfig), new HashSet(0) };
45     }
46     
47     protected void basicGenerateAssembleConfigFileTargetCall(Config aConfig, Collection binaryPlugins, Collection binaryFeatures, Collection allFeatures, Collection rootFiles) throws CoreException {
48         configScriptGenerator.initialize(directory, featureId, aConfig, binaryPlugins, binaryFeatures, allFeatures, rootFiles);
49         ((PackageConfigScriptGenerator) configScriptGenerator).setPackagingPropertiesLocation(packagingPropertiesLocation);
50         configScriptGenerator.setArchiveFormat((String JavaDoc) archivesFormat.get(aConfig));
51         configScriptGenerator.setGroupConfigs(groupConfigs);
52         setForceUpdateJar(forceUpdateJarFormat);
53         configScriptGenerator.setBuildSiteFactory(siteFactory);
54         configScriptGenerator.generate();
55
56         Map params = new HashMap(1);
57         params.put("assembleScriptName", configScriptGenerator.getTargetName() + ".xml");
58         script.printAntTask(Utils.getPropertyFormat(DEFAULT_CUSTOM_TARGETS), null, computeBackwardCompatibleName(aConfig), null, null, params);
59     }
60     
61     public void setBackwardCompatibleName(boolean value) {
62         backwardCompatibleName = value;
63     }
64     
65     private String JavaDoc computeBackwardCompatibleName(Config configInfo) {
66         if (backwardCompatibleName)
67             return DEFAULT_ASSEMBLE_NAME + (configInfo.equals(Config.genericConfig()) ? "" : ('.' + configInfo.toStringReplacingAny(".", ANY_STRING)) + (backwardCompatibleName ? ".xml" : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
68
return DEFAULT_ASSEMBLE_NAME + (featureId.equals("") ? "" : ('.' + featureId)) + (configInfo.equals(Config.genericConfig()) ? "" : ('.' + configInfo.toStringReplacingAny(".", ANY_STRING)) + (backwardCompatibleName ? ".xml" : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
69
}
70 }
71
Popular Tags