KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.util.Properties JavaDoc;
14 import org.apache.tools.ant.BuildException;
15 import org.apache.tools.ant.Task;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.pde.internal.build.*;
18 import org.eclipse.pde.internal.build.packager.PackagerGenerator;
19 import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
20
21 /**
22  * Internal task.
23  * Generate assemble scripts to repackage binary distributions.
24  * @since 3.0
25  */

26 public class PackagerTask extends Task {
27
28     protected PackagerGenerator generator;
29     private Properties JavaDoc antProperties = new Properties JavaDoc();
30     
31     {
32         generator = new PackagerGenerator();
33         generator.setReportResolutionErrors(true);
34         generator.setIgnoreMissingPropertiesFile(true);
35         BuildTimeSiteFactory.setInstalledBaseSite(null);
36     }
37
38     /**
39      * Set the directory where the packaging will occur
40      * @param workingLocation the location
41      */

42     public void setWorkingDirectory(String JavaDoc workingLocation) {
43         generator.setWorkingDirectory(workingLocation);
44     }
45
46     /**
47      * Set the features to assemble
48      * @param featureList a comma separated list of features to package
49      */

50     public void setFeatureList(String JavaDoc featureList) throws BuildException {
51         generator.setFeatureList(featureList);
52     }
53
54     /**
55      * Set the configuration for which the assembling is being done
56      * @param configInfo a configuration
57      * @throws CoreException
58      */

59     public void setConfigInfo(String JavaDoc configInfo) throws CoreException {
60         AbstractScriptGenerator.setConfigInfo(configInfo);
61     }
62
63      /**
64       * Set on a configuration basis, the format of the archive being produced. The default is set to be configuration independent.
65       * @param archivesFormat an ampersand separated list of configuration (for example win32, win32 - zip, x86 & macoxs, carbon, ppc - tar).
66       * @throws CoreException
67       * @since 3.0
68       */

69      public void setArchivesFormat(String JavaDoc archivesFormat) throws CoreException {
70              generator.setArchivesFormat(archivesFormat);
71      }
72          
73     /**
74      * Set the location where to find features, plugins and fragments
75      * @param baseLocation a comma separated list of paths
76      */

77     public void setBaseLocation(String JavaDoc baseLocation) throws BuildException {
78         String JavaDoc[] locations = Utils.getArrayFromString(baseLocation);
79         generator.setPluginPath(locations);
80     }
81
82     public void execute() throws BuildException {
83         try {
84             generator.setImmutableAntProperties(antProperties);
85             antProperties.setProperty(IBuildPropertiesConstants.PROPERTY_PACKAGER_MODE, "true"); //$NON-NLS-1$
86
String JavaDoc value = getProject().getProperty(IBuildPropertiesConstants.RESOLVER_DEV_MODE);
87             if (Boolean.valueOf(value).booleanValue())
88                 antProperties.put(IBuildPropertiesConstants.RESOLVER_DEV_MODE, "true"); //$NON-NLS-1$
89
BundleHelper.getDefault().setLog(this);
90             generator.generate();
91             BundleHelper.getDefault().setLog(null);
92         } catch (CoreException e) {
93             throw new BuildException(TaskHelper.statusToString(e.getStatus(), null).toString());
94         }
95     }
96
97     /**
98      * Set the property file containing information about packaging
99      * @param propertyFile the path to a property file
100      */

101     public void setPackagePropertyFile(String JavaDoc propertyFile) {
102         generator.setPropertyFile(propertyFile);
103     }
104     
105     public void setDeltaPack(boolean value) {
106         generator.includePlatformIndependent(! value);
107         generator.groupConfigs(value);
108     }
109     
110     public void setFilteredDependencyCheck(boolean value) {
111         generator.setFilterState(value);
112     }
113     
114     public void setNormalize(boolean value) {
115         if (value)
116             antProperties.setProperty(IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER, "true"); //$NON-NLS-1$
117
else
118             antProperties.setProperty(IBuildPropertiesConstants.PROPERTY_PACKAGER_AS_NORMALIZER, "false"); //$NON-NLS-1$
119
}
120 }
121
Popular Tags