KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006 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.Properties JavaDoc;
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
21 /**
22  * Generate a container feature based on a .product file and/or provided feature, plugin lists
23  * @since 3.2
24  */

25 public class FeatureGeneratorTask extends Task {
26     private FeatureGenerator generator = new FeatureGenerator();
27     private Properties JavaDoc antProperties = new Properties JavaDoc();
28     
29     public void execute() throws BuildException {
30         try {
31             BundleHelper.getDefault().setLog(this);
32             String JavaDoc value = getProject().getProperty(IBuildPropertiesConstants.RESOLVER_DEV_MODE);
33             if (Boolean.valueOf(value).booleanValue())
34                 antProperties.put(IBuildPropertiesConstants.RESOLVER_DEV_MODE, "true"); //$NON-NLS-1$
35
generator.setImmutableAntProperties(antProperties);
36             run();
37             BundleHelper.getDefault().setLog(null);
38         } catch (CoreException e) {
39             throw new BuildException(TaskHelper.statusToString(e.getStatus(), null).toString());
40         }
41     }
42     
43     public void run() throws CoreException {
44         generator.generate();
45     }
46
47     /**
48      * Set the folder in which the build will occur.
49      * @param buildDirectory the location where the build will occur.
50      */

51     public void setBuildDirectory(String JavaDoc buildDirectory) {
52         generator.setWorkingDirectory(buildDirectory);
53     }
54
55     /**
56      * Set the product file to base the feature on
57      * @param productFile
58      */

59     public void setProductFile(String JavaDoc productFile) {
60         generator.setProductFile(productFile);
61     }
62
63     /**
64      * Set whether or not to automatically include the launchers in the product
65      * Default is true
66      * @param includeLaunchers
67      */

68     public void setIncludeLaunchers(boolean includeLaunchers) {
69         generator.setIncludeLaunchers(includeLaunchers);
70     }
71     /**
72      * Set a location that contains plugins and features required by plugins and features
73      * for which the feature is being generated
74      * @param baseLocation
75      */

76     public void setBaseLocation(String JavaDoc baseLocation) {
77         BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
78     }
79
80     /**
81      * Set a list of plugin ids to be included in the generated feature
82      * @param pluginList a comma separated list of plugin ids
83      */

84     public void setPluginList(String JavaDoc pluginList) {
85         if (pluginList != null && !pluginList.startsWith("${")) //$NON-NLS-1$
86
generator.setPluginList(Utils.getArrayFromString(pluginList));
87     }
88
89     /**
90      * Set a list of plugin fragment ids to be included in the generated feature
91      * @param fragmentList a comma separated list of plugin ids
92      */

93     public void setFragmentList(String JavaDoc fragmentList) {
94         if(fragmentList != null && !fragmentList.startsWith("${")) //$NON-NLS-1$
95
generator.setFragmentList(Utils.getArrayFromString(fragmentList));
96     }
97     
98     /**
99      * Set a list of feature ids to be include in the generated feature
100      * @param featureList a comma separated list of feature ids
101      */

102     public void setFeatureList(String JavaDoc featureList) {
103         if (featureList != null && !featureList.startsWith("${")) //$NON-NLS-1$
104
generator.setFeatureList(Utils.getArrayFromString(featureList));
105     }
106     
107     /**
108      * The id to give to the generated feature
109      * @param featureId
110      */

111     public void setFeatureId(String JavaDoc featureId) {
112         generator.setFeatureId(featureId);
113     }
114     
115     /**
116      * Set the list of additional paths in which to look for required plugins
117      *
118      * @param pluginPath a {@link File.pathSeparator} separated list of paths
119      */

120     public void setPluginPath(String JavaDoc pluginPath) {
121         generator.setPluginPath(Utils.getArrayFromString(pluginPath, File.pathSeparator));
122     }
123     
124     /**
125      * Set to true if you want to verify that the plugins and features are available.
126      * @param verify
127      */

128     public void setVerify(boolean verify) {
129         generator.setVerify(verify);
130     }
131     
132     /**
133      * Set the configuration for which the script should be generated. The default is set to be configuration independent.
134      * @param configInfo an ampersand separated list of configuration (for example win32, win32, x86 & macoxs, carbon, ppc).
135      * @throws CoreException
136      */

137     public void setConfigInfo(String JavaDoc configInfo) throws CoreException {
138         AbstractScriptGenerator.setConfigInfo(configInfo);
139     }
140 }
141
Popular Tags