01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM - Initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.build.packager;
11:
12: import java.util.*;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.pde.internal.build.*;
15:
16: public class PackageScriptGenerator extends AssembleScriptGenerator {
17: private String packagingPropertiesLocation;
18: private boolean backwardCompatibleName = false;
19:
20: public PackageScriptGenerator(String directory,
21: AssemblyInformation assemblageInformation, String featureId) {
22: super (directory, assemblageInformation, featureId);
23: }
24:
25: protected void printProjectDeclaration() {
26: script
27: .printProjectDeclaration(
28: "Package all config of " + featureId, TARGET_MAIN, null); //$NON-NLS-1$
29: }
30:
31: protected AssembleConfigScriptGenerator getConfigScriptGenerator() {
32: return new PackageConfigScriptGenerator();
33: }
34:
35: protected String getScriptName() {
36: if (backwardCompatibleName)
37: return "package" + '.' + DEFAULT_ASSEMBLE_ALL;
38: return "package" + '.'
39: + (featureId.equals("") ? "" : featureId + '.')
40: + DEFAULT_ASSEMBLE_ALL;
41: }
42:
43: public void setPropertyFile(String propertyFile) {
44: packagingPropertiesLocation = propertyFile;
45: }
46:
47: protected Collection[] getConfigInfos(Config aConfig) {
48: return new Collection[] {
49: assemblageInformation.getBinaryPlugins(aConfig),
50: assemblageInformation.getBinaryFeatures(aConfig),
51: assemblageInformation.getFeatures(aConfig),
52: new HashSet(0) };
53: }
54:
55: protected void basicGenerateAssembleConfigFileTargetCall(
56: Config aConfig, Collection binaryPlugins,
57: Collection binaryFeatures, Collection allFeatures,
58: Collection rootFiles) throws CoreException {
59: configScriptGenerator.initialize(directory, featureId, aConfig,
60: binaryPlugins, binaryFeatures, allFeatures, rootFiles);
61: ((PackageConfigScriptGenerator) configScriptGenerator)
62: .setPackagingPropertiesLocation(packagingPropertiesLocation);
63: configScriptGenerator.setArchiveFormat((String) archivesFormat
64: .get(aConfig));
65: configScriptGenerator.setGroupConfigs(groupConfigs);
66: setForceUpdateJar(forceUpdateJarFormat);
67: configScriptGenerator.setBuildSiteFactory(siteFactory);
68: configScriptGenerator.generate();
69:
70: Map params = new HashMap(1);
71: params.put("assembleScriptName", configScriptGenerator
72: .getTargetName()
73: + ".xml");
74: script.printAntTask(Utils
75: .getPropertyFormat(DEFAULT_CUSTOM_TARGETS), null,
76: computeBackwardCompatibleName(aConfig), null, null,
77: params);
78: }
79:
80: public void setBackwardCompatibleName(boolean value) {
81: backwardCompatibleName = value;
82: }
83:
84: private String computeBackwardCompatibleName(Config configInfo) {
85: if (backwardCompatibleName)
86: return DEFAULT_ASSEMBLE_NAME
87: + (configInfo.equals(Config.genericConfig()) ? "" : ('.' + configInfo.toStringReplacingAny(".", ANY_STRING)) + (backwardCompatibleName ? ".xml" : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
88: return DEFAULT_ASSEMBLE_NAME
89: + (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$
90: }
91: }
|