001: /*******************************************************************************
002: * Copyright (c) 2005, 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: *******************************************************************************/package org.eclipse.pde.internal.build.tasks;
011:
012: import java.util.Properties;
013: import org.apache.tools.ant.BuildException;
014: import org.apache.tools.ant.Task;
015: import org.eclipse.core.runtime.CoreException;
016: import org.eclipse.pde.internal.build.*;
017: import org.eclipse.pde.internal.build.packager.PackagerGenerator;
018: import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
019:
020: /**
021: * Internal task.
022: * Generate assemble scripts to repackage binary distributions.
023: * @since 3.0
024: */
025: public class PackagerTask extends Task {
026:
027: protected PackagerGenerator generator;
028: private Properties antProperties = new Properties();
029:
030: {
031: generator = new PackagerGenerator();
032: generator.setReportResolutionErrors(true);
033: generator.setIgnoreMissingPropertiesFile(true);
034: BuildTimeSiteFactory.setInstalledBaseSite(null);
035: }
036:
037: /**
038: * Set the directory where the packaging will occur
039: * @param workingLocation the location
040: */
041: public void setWorkingDirectory(String workingLocation) {
042: generator.setWorkingDirectory(workingLocation);
043: }
044:
045: /**
046: * Set the features to assemble
047: * @param featureList a comma separated list of features to package
048: */
049: public void setFeatureList(String featureList)
050: throws BuildException {
051: generator.setFeatureList(featureList);
052: }
053:
054: /**
055: * Set the configuration for which the assembling is being done
056: * @param configInfo a configuration
057: * @throws CoreException
058: */
059: public void setConfigInfo(String configInfo) throws CoreException {
060: AbstractScriptGenerator.setConfigInfo(configInfo);
061: }
062:
063: /**
064: * Set on a configuration basis, the format of the archive being produced. The default is set to be configuration independent.
065: * @param archivesFormat an ampersand separated list of configuration (for example win32, win32 - zip, x86 & macoxs, carbon, ppc - tar).
066: * @throws CoreException
067: * @since 3.0
068: */
069: public void setArchivesFormat(String archivesFormat)
070: throws CoreException {
071: generator.setArchivesFormat(archivesFormat);
072: }
073:
074: /**
075: * Set the location where to find features, plugins and fragments
076: * @param baseLocation a comma separated list of paths
077: */
078: public void setBaseLocation(String baseLocation)
079: throws BuildException {
080: String[] locations = Utils.getArrayFromString(baseLocation);
081: generator.setPluginPath(locations);
082: }
083:
084: public void execute() throws BuildException {
085: try {
086: generator.setImmutableAntProperties(antProperties);
087: antProperties.setProperty(
088: IBuildPropertiesConstants.PROPERTY_PACKAGER_MODE,
089: "true"); //$NON-NLS-1$
090: String value = getProject().getProperty(
091: IBuildPropertiesConstants.RESOLVER_DEV_MODE);
092: if (Boolean.valueOf(value).booleanValue())
093: antProperties.put(
094: IBuildPropertiesConstants.RESOLVER_DEV_MODE,
095: "true"); //$NON-NLS-1$
096: BundleHelper.getDefault().setLog(this );
097: generator.generate();
098: BundleHelper.getDefault().setLog(null);
099: } catch (CoreException e) {
100: throw new BuildException(TaskHelper.statusToString(
101: e.getStatus(), null).toString());
102: }
103: }
104:
105: /**
106: * Set the property file containing information about packaging
107: * @param propertyFile the path to a property file
108: */
109: public void setPackagePropertyFile(String propertyFile) {
110: generator.setPropertyFile(propertyFile);
111: }
112:
113: public void setDeltaPack(boolean value) {
114: generator.includePlatformIndependent(!value);
115: generator.groupConfigs(value);
116: }
117:
118: public void setFilteredDependencyCheck(boolean value) {
119: generator.setFilterState(value);
120: }
121:
122: public void setNormalize(boolean value) {
123: if (value)
124: antProperties
125: .setProperty(
126: IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER,
127: "true"); //$NON-NLS-1$
128: else
129: antProperties
130: .setProperty(
131: IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER,
132: "false"); //$NON-NLS-1$
133: }
134: }
|