001: /*******************************************************************************
002: * Copyright (c) 2006 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.io.File;
013: import java.util.Properties;
014: import org.apache.tools.ant.BuildException;
015: import org.apache.tools.ant.Task;
016: import org.eclipse.core.runtime.CoreException;
017: import org.eclipse.pde.internal.build.*;
018: import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
019:
020: /**
021: * Generate a container feature based on a .product file and/or provided feature, plugin lists
022: * @since 3.2
023: */
024: public class FeatureGeneratorTask extends Task {
025: private FeatureGenerator generator = new FeatureGenerator();
026: private Properties antProperties = new Properties();
027:
028: public void execute() throws BuildException {
029: try {
030: BundleHelper.getDefault().setLog(this );
031: String value = getProject().getProperty(
032: IBuildPropertiesConstants.RESOLVER_DEV_MODE);
033: if (Boolean.valueOf(value).booleanValue())
034: antProperties.put(
035: IBuildPropertiesConstants.RESOLVER_DEV_MODE,
036: "true"); //$NON-NLS-1$
037: generator.setImmutableAntProperties(antProperties);
038: run();
039: BundleHelper.getDefault().setLog(null);
040: } catch (CoreException e) {
041: throw new BuildException(TaskHelper.statusToString(
042: e.getStatus(), null).toString());
043: }
044: }
045:
046: public void run() throws CoreException {
047: generator.generate();
048: }
049:
050: /**
051: * Set the folder in which the build will occur.
052: * @param buildDirectory the location where the build will occur.
053: */
054: public void setBuildDirectory(String buildDirectory) {
055: generator.setWorkingDirectory(buildDirectory);
056: }
057:
058: /**
059: * Set the product file to base the feature on
060: * @param productFile
061: */
062: public void setProductFile(String productFile) {
063: generator.setProductFile(productFile);
064: }
065:
066: /**
067: * Set whether or not to automatically include the launchers in the product
068: * Default is true
069: * @param includeLaunchers
070: */
071: public void setIncludeLaunchers(boolean includeLaunchers) {
072: generator.setIncludeLaunchers(includeLaunchers);
073: }
074:
075: /**
076: * Set a location that contains plugins and features required by plugins and features
077: * for which the feature is being generated
078: * @param baseLocation
079: */
080: public void setBaseLocation(String baseLocation) {
081: BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
082: }
083:
084: /**
085: * Set a list of plugin ids to be included in the generated feature
086: * @param pluginList a comma separated list of plugin ids
087: */
088: public void setPluginList(String pluginList) {
089: if (pluginList != null && !pluginList.startsWith("${")) //$NON-NLS-1$
090: generator.setPluginList(Utils
091: .getArrayFromString(pluginList));
092: }
093:
094: /**
095: * Set a list of plugin fragment ids to be included in the generated feature
096: * @param fragmentList a comma separated list of plugin ids
097: */
098: public void setFragmentList(String fragmentList) {
099: if (fragmentList != null && !fragmentList.startsWith("${")) //$NON-NLS-1$
100: generator.setFragmentList(Utils
101: .getArrayFromString(fragmentList));
102: }
103:
104: /**
105: * Set a list of feature ids to be include in the generated feature
106: * @param featureList a comma separated list of feature ids
107: */
108: public void setFeatureList(String featureList) {
109: if (featureList != null && !featureList.startsWith("${")) //$NON-NLS-1$
110: generator.setFeatureList(Utils
111: .getArrayFromString(featureList));
112: }
113:
114: /**
115: * The id to give to the generated feature
116: * @param featureId
117: */
118: public void setFeatureId(String featureId) {
119: generator.setFeatureId(featureId);
120: }
121:
122: /**
123: * Set the list of additional paths in which to look for required plugins
124: *
125: * @param pluginPath a {@link File.pathSeparator} separated list of paths
126: */
127: public void setPluginPath(String pluginPath) {
128: generator.setPluginPath(Utils.getArrayFromString(pluginPath,
129: File.pathSeparator));
130: }
131:
132: /**
133: * Set to true if you want to verify that the plugins and features are available.
134: * @param verify
135: */
136: public void setVerify(boolean verify) {
137: generator.setVerify(verify);
138: }
139:
140: /**
141: * Set the configuration for which the script should be generated. The default is set to be configuration independent.
142: * @param configInfo an ampersand separated list of configuration (for example win32, win32, x86 & macoxs, carbon, ppc).
143: * @throws CoreException
144: */
145: public void setConfigInfo(String configInfo) throws CoreException {
146: AbstractScriptGenerator.setConfigInfo(configInfo);
147: }
148: }
|