KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > tasks > BuildScriptGeneratorTask


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.tasks;
12
13 import java.io.File JavaDoc;
14 import java.util.*;
15 import org.apache.tools.ant.BuildException;
16 import org.apache.tools.ant.Task;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.pde.internal.build.*;
19 import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
20 import org.eclipse.pde.internal.build.site.QualifierReplacer;
21
22 /**
23  * Generate build scripts for the listed elements. This is the implementation of the "eclipse.buildScript" Ant task.
24  */

25 public class BuildScriptGeneratorTask extends Task {
26     private Properties antProperties = new Properties();
27     /**
28      * The application associated with this Ant task.
29      */

30     protected BuildScriptGenerator generator = new BuildScriptGenerator();
31
32     /**
33      * Set the boolean value indicating whether or not children scripts should
34      * be generated.
35      *
36      * @param children <code>true</code> if child scripts should be generated
37      * and <code>false</code> otherwise
38      * @since 3.0
39      */

40     public void setChildren(boolean children) {
41         generator.setChildren(children);
42     }
43
44     /**
45      * Set the development entries for the compile classpath to be the given value.
46      *
47      * @param devEntries the classpath dev entries
48      */

49     public void setDevEntries(String JavaDoc devEntries) {
50         generator.setDevEntries(devEntries);
51     }
52
53     /**
54      * Set the plug-in path to be the given value.
55      *
56      * @param pluginPath a File.pathSeparator separated list of paths
57      */

58     public void setPluginPath(String JavaDoc pluginPath) {
59         generator.setPluginPath(Utils.getArrayFromString(pluginPath, File.pathSeparator));
60     }
61
62     /**
63      * Set the source elements for the script to be the given value.
64      *
65      * @param elements the source elements for the script
66      */

67     public void setElements(String JavaDoc elements) {
68         generator.setElements(Utils.getArrayFromString(elements));
69     }
70
71     public void setSignificantVersionDigits(String JavaDoc significantDigits) {
72         antProperties.put(IBuildPropertiesConstants.PROPERTY_SIGNIFICANT_VERSION_DIGITS, significantDigits);
73     }
74     
75     public void setGeneratedVersionLength(String JavaDoc generatedLength) {
76         antProperties.put(IBuildPropertiesConstants.PROPERTY_GENERATED_VERSION_LENGTH, generatedLength);
77     }
78     
79     public void execute() throws BuildException {
80         try {
81             run();
82         } catch (CoreException e) {
83             throw new BuildException(TaskHelper.statusToString(e.getStatus(), null).toString());
84         }
85     }
86
87     public void run() throws CoreException {
88         generator.setReportResolutionErrors(true);
89         String JavaDoc value = getProject().getProperty(IBuildPropertiesConstants.RESOLVER_DEV_MODE);
90         if (Boolean.valueOf(value).booleanValue())
91             antProperties.put(IBuildPropertiesConstants.RESOLVER_DEV_MODE, "true"); //$NON-NLS-1$
92
generator.setImmutableAntProperties(antProperties);
93         BundleHelper.getDefault().setLog(this);
94         generator.generate();
95         BundleHelper.getDefault().setLog(null);
96     }
97
98     /**
99      * Set the folder in which the build will occur.
100      * @param buildDirectory the location where the build will occur.
101      * @since 3.0
102      */

103     public void setBuildDirectory(String JavaDoc buildDirectory) {
104         generator.setWorkingDirectory(buildDirectory);
105     }
106
107     /**
108      * Set the folder in which the build will occur.
109      * @param installLocation the location where the build will occur.
110      * @deprecated see {@link #setBuildDirectory(String)}
111      */

112     public void setInstall(String JavaDoc installLocation) {
113         generator.setWorkingDirectory(installLocation);
114     }
115     
116     /**
117      * Set the boolean value indicating whether or not the build scripts should be
118      * generated for nested features. The default is set to true.
119      * @param recursiveGeneration <code>true</code> if the scripts for the nested features should be generated
120      * and <code>false</code> otherwise
121      * @since 3.0
122      */

123     public void setRecursiveGeneration(boolean recursiveGeneration) {
124         generator.setRecursiveGeneration(recursiveGeneration);
125     }
126
127     /**
128      * Set the configuration for which the script should be generated. The default is set to be configuration independent.
129      * @param configInfo an ampersand separated list of configuration (for example win32, win32, x86 & macoxs, carbon, ppc).
130      * @throws CoreException
131      * @since 3.0
132      */

133     public void setConfigInfo(String JavaDoc configInfo) throws CoreException {
134         AbstractScriptGenerator.setConfigInfo(configInfo);
135     }
136
137          
138      /**
139       * Set on a configuration basis, the format of the archive being produced. The default is set to be configuration independent.
140       * @param archivesFormat an ampersand separated list of configuration (for example win32, win32 - zip, x86 & macoxs, carbon, ppc - tar).
141       * @throws CoreException
142       * @since 3.0
143       */

144      public void setArchivesFormat(String JavaDoc archivesFormat) throws CoreException {
145              generator.setArchivesFormat(archivesFormat);
146      }
147          
148     /**
149      * Set a location that contains plugins and features required by plugins and features for which build scripts are being generated.
150      * @param baseLocation a path to a folder
151      * @since 3.0
152      */

153     public void setBaseLocation(String JavaDoc baseLocation) {
154         BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
155     }
156
157     /**
158      * 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.
159      * The default is set to true.
160      * This property is experimental and is likely to be renamed in the future.
161      * @param osgi <code>true</code> if the scripts are generated for eclipse 3.0 or greated and <code>false</code> otherwise
162      * @since 3.0.
163      */

164     public void setBuildingOSGi(boolean osgi) {
165         generator.setBuildingOSGi(osgi);
166     }
167     
168     /**
169      * Set the folder in which the build will occur.
170      * <p>
171      * Note: This API is experimental.
172      * </p>
173      *
174      * @param installLocation the location where the build will occur
175      */

176     public void setWorkingDirectory(String JavaDoc installLocation) {
177         generator.setWorkingDirectory(installLocation);
178     }
179
180     /**
181      * Set the location of the product being built. This should be a / separated path
182      * where the first segment is the id of the plugin containing the .product file.
183      * @param value the location of the .product file being built.
184      */

185     public void setProduct(String JavaDoc value) {
186         generator.setProduct(value);
187     }
188
189     /**
190      * Set the boolean value indicating whether or not to sign any constructed JAs.
191      * @param value <code>true</code> if built jars should be signed.
192      */

193     public void setSignJars(boolean value) {
194         generator.setSignJars(value);
195     }
196
197     /**
198      * Set the boolean value indicating whether or not to generate JNLP files for
199      * built features.
200      * @param value <code>true</code> if JNLP manifests should be generated.
201      */

202     public void setGenerateJnlp(boolean value) {
203         generator.setGenerateJnlp(value);
204     }
205     
206     public void setOutputUpdateJars(boolean value) {
207         AbstractScriptGenerator.setForceUpdateJar(value);
208     }
209     
210     public void setForceContextQualifier(String JavaDoc value) {
211         QualifierReplacer.setGlobalQualifier(value);
212     }
213     
214     /**
215      * Set the boolean value indicating whether or not to generate a version suffix
216      * for features based on their content.
217      * @param value <code>true</code> if version suffixes should be generated.
218      */

219     public void setGenerateFeatureVersionSuffix(boolean value){
220         generator.setGenerateFeatureVersionSuffix(value);
221     }
222     
223     /**
224      * Set whether or not to generate plugin & feature versions lists
225      * @param value
226      */

227     public void setGenerateVersionsLists(boolean value){
228         generator.setGenerateVersionsList(value);
229     }
230     
231     /**
232      * Set the boolean indicating if resulting archive should contain a group of all the configurations being built.
233      * @param value <code>false</code> if the configurations being built should be grouped in one archive.
234      */

235     public void setGroupConfiguration(boolean value) {
236         generator.setGroupConfigs(value);
237     }
238     
239     public void setFilteredDependencyCheck(boolean value) {
240         generator.setFilterState(value);
241     }
242     
243     /**
244      * Set the filename to use for the platform properties that will be passed to the state.
245      */

246     public void setPlatformProperties(String JavaDoc filename) {
247         generator.setPlatformProperties(filename);
248     }
249 }
250
Popular Tags