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: *******************************************************************************/package org.eclipse.pde.internal.build.tasks;
011:
012: import java.io.File;
013: import java.util.*;
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: import org.eclipse.pde.internal.build.site.QualifierReplacer;
020:
021: /**
022: * Generate build scripts for the listed elements. This is the implementation of the "eclipse.buildScript" Ant task.
023: */
024: public class BuildScriptGeneratorTask extends Task {
025: private Properties antProperties = new Properties();
026: /**
027: * The application associated with this Ant task.
028: */
029: protected BuildScriptGenerator generator = new BuildScriptGenerator();
030:
031: /**
032: * Set the boolean value indicating whether or not children scripts should
033: * be generated.
034: *
035: * @param children <code>true</code> if child scripts should be generated
036: * and <code>false</code> otherwise
037: * @since 3.0
038: */
039: public void setChildren(boolean children) {
040: generator.setChildren(children);
041: }
042:
043: /**
044: * Set the development entries for the compile classpath to be the given value.
045: *
046: * @param devEntries the classpath dev entries
047: */
048: public void setDevEntries(String devEntries) {
049: generator.setDevEntries(devEntries);
050: }
051:
052: /**
053: * Set the plug-in path to be the given value.
054: *
055: * @param pluginPath a File.pathSeparator separated list of paths
056: */
057: public void setPluginPath(String pluginPath) {
058: generator.setPluginPath(Utils.getArrayFromString(pluginPath,
059: File.pathSeparator));
060: }
061:
062: /**
063: * Set the source elements for the script to be the given value.
064: *
065: * @param elements the source elements for the script
066: */
067: public void setElements(String elements) {
068: generator.setElements(Utils.getArrayFromString(elements));
069: }
070:
071: public void setSignificantVersionDigits(String significantDigits) {
072: antProperties
073: .put(
074: IBuildPropertiesConstants.PROPERTY_SIGNIFICANT_VERSION_DIGITS,
075: significantDigits);
076: }
077:
078: public void setGeneratedVersionLength(String generatedLength) {
079: antProperties
080: .put(
081: IBuildPropertiesConstants.PROPERTY_GENERATED_VERSION_LENGTH,
082: generatedLength);
083: }
084:
085: public void execute() throws BuildException {
086: try {
087: run();
088: } catch (CoreException e) {
089: throw new BuildException(TaskHelper.statusToString(
090: e.getStatus(), null).toString());
091: }
092: }
093:
094: public void run() throws CoreException {
095: generator.setReportResolutionErrors(true);
096: String value = getProject().getProperty(
097: IBuildPropertiesConstants.RESOLVER_DEV_MODE);
098: if (Boolean.valueOf(value).booleanValue())
099: antProperties
100: .put(IBuildPropertiesConstants.RESOLVER_DEV_MODE,
101: "true"); //$NON-NLS-1$
102: generator.setImmutableAntProperties(antProperties);
103: BundleHelper.getDefault().setLog(this );
104: generator.generate();
105: BundleHelper.getDefault().setLog(null);
106: }
107:
108: /**
109: * Set the folder in which the build will occur.
110: * @param buildDirectory the location where the build will occur.
111: * @since 3.0
112: */
113: public void setBuildDirectory(String buildDirectory) {
114: generator.setWorkingDirectory(buildDirectory);
115: }
116:
117: /**
118: * Set the folder in which the build will occur.
119: * @param installLocation the location where the build will occur.
120: * @deprecated see {@link #setBuildDirectory(String)}
121: */
122: public void setInstall(String installLocation) {
123: generator.setWorkingDirectory(installLocation);
124: }
125:
126: /**
127: * Set the boolean value indicating whether or not the build scripts should be
128: * generated for nested features. The default is set to true.
129: * @param recursiveGeneration <code>true</code> if the scripts for the nested features should be generated
130: * and <code>false</code> otherwise
131: * @since 3.0
132: */
133: public void setRecursiveGeneration(boolean recursiveGeneration) {
134: generator.setRecursiveGeneration(recursiveGeneration);
135: }
136:
137: /**
138: * Set the configuration for which the script should be generated. The default is set to be configuration independent.
139: * @param configInfo an ampersand separated list of configuration (for example win32, win32, x86 & macoxs, carbon, ppc).
140: * @throws CoreException
141: * @since 3.0
142: */
143: public void setConfigInfo(String configInfo) throws CoreException {
144: AbstractScriptGenerator.setConfigInfo(configInfo);
145: }
146:
147: /**
148: * Set on a configuration basis, the format of the archive being produced. The default is set to be configuration independent.
149: * @param archivesFormat an ampersand separated list of configuration (for example win32, win32 - zip, x86 & macoxs, carbon, ppc - tar).
150: * @throws CoreException
151: * @since 3.0
152: */
153: public void setArchivesFormat(String archivesFormat)
154: throws CoreException {
155: generator.setArchivesFormat(archivesFormat);
156: }
157:
158: /**
159: * Set a location that contains plugins and features required by plugins and features for which build scripts are being generated.
160: * @param baseLocation a path to a folder
161: * @since 3.0
162: */
163: public void setBaseLocation(String baseLocation) {
164: BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
165: }
166:
167: /**
168: * Set the boolean value indicating whether or not the plug-ins and features for which scripts are being generated target eclipse 3.0 or greater.
169: * The default is set to true.
170: * This property is experimental and is likely to be renamed in the future.
171: * @param osgi <code>true</code> if the scripts are generated for eclipse 3.0 or greated and <code>false</code> otherwise
172: * @since 3.0.
173: */
174: public void setBuildingOSGi(boolean osgi) {
175: generator.setBuildingOSGi(osgi);
176: }
177:
178: /**
179: * Set the folder in which the build will occur.
180: * <p>
181: * Note: This API is experimental.
182: * </p>
183: *
184: * @param installLocation the location where the build will occur
185: */
186: public void setWorkingDirectory(String installLocation) {
187: generator.setWorkingDirectory(installLocation);
188: }
189:
190: /**
191: * Set the location of the product being built. This should be a / separated path
192: * where the first segment is the id of the plugin containing the .product file.
193: * @param value the location of the .product file being built.
194: */
195: public void setProduct(String value) {
196: generator.setProduct(value);
197: }
198:
199: /**
200: * Set the boolean value indicating whether or not to sign any constructed JAs.
201: * @param value <code>true</code> if built jars should be signed.
202: */
203: public void setSignJars(boolean value) {
204: generator.setSignJars(value);
205: }
206:
207: /**
208: * Set the boolean value indicating whether or not to generate JNLP files for
209: * built features.
210: * @param value <code>true</code> if JNLP manifests should be generated.
211: */
212: public void setGenerateJnlp(boolean value) {
213: generator.setGenerateJnlp(value);
214: }
215:
216: public void setOutputUpdateJars(boolean value) {
217: AbstractScriptGenerator.setForceUpdateJar(value);
218: }
219:
220: public void setForceContextQualifier(String value) {
221: QualifierReplacer.setGlobalQualifier(value);
222: }
223:
224: /**
225: * Set the boolean value indicating whether or not to generate a version suffix
226: * for features based on their content.
227: * @param value <code>true</code> if version suffixes should be generated.
228: */
229: public void setGenerateFeatureVersionSuffix(boolean value) {
230: generator.setGenerateFeatureVersionSuffix(value);
231: }
232:
233: /**
234: * Set whether or not to generate plugin & feature versions lists
235: * @param value
236: */
237: public void setGenerateVersionsLists(boolean value) {
238: generator.setGenerateVersionsList(value);
239: }
240:
241: /**
242: * Set the boolean indicating if resulting archive should contain a group of all the configurations being built.
243: * @param value <code>false</code> if the configurations being built should be grouped in one archive.
244: */
245: public void setGroupConfiguration(boolean value) {
246: generator.setGroupConfigs(value);
247: }
248:
249: public void setFilteredDependencyCheck(boolean value) {
250: generator.setFilterState(value);
251: }
252:
253: /**
254: * Set the filename to use for the platform properties that will be passed to the state.
255: */
256: public void setPlatformProperties(String filename) {
257: generator.setPlatformProperties(filename);
258: }
259: }
|