Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 107272 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/build/IPDEBuildConstants.java (+1 lines)
Lines 101-106 Link Here
101
	public final static int WARNING_MISSING_SOURCE = 20;
101
	public final static int WARNING_MISSING_SOURCE = 20;
102
	public final static int WARNING_ELEMENT_NOT_FETCHED = 21;
102
	public final static int WARNING_ELEMENT_NOT_FETCHED = 21;
103
	public final static int EXCEPTION_CONFIG_FORMAT = 22;
103
	public final static int EXCEPTION_CONFIG_FORMAT = 22;
104
	public final static int EXCEPTION_PRODUCT_FORMAT = 23;
104
105
105
	//User object keys. BundleDescription.getUserObject()
106
	//User object keys. BundleDescription.getUserObject()
106
	public final static String IS_COMPILED = "isCompiler"; //$NON-NLS-1$
107
	public final static String IS_COMPILED = "isCompiler"; //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/build/ProductGenerator.java (-1 / +5 lines)
Lines 77-83 Link Here
77
		refactoredRuntime = state.getResolvedBundle(BUNDLE_EQUINOX_COMMON) != null;
77
		refactoredRuntime = state.getResolvedBundle(BUNDLE_EQUINOX_COMMON) != null;
78
	}
78
	}
79
	
79
	
80
	private void loadProduct() {
80
	private void loadProduct() throws CoreException {
81
		if (product == null || product.startsWith("${")) { //$NON-NLS-1$
81
		if (product == null || product.startsWith("${")) { //$NON-NLS-1$
82
			productFile = null;
82
			productFile = null;
83
			return;
83
			return;
Lines 171-176 Link Here
171
			for (Iterator iter = pluginList.iterator(); iter.hasNext();) {
171
			for (Iterator iter = pluginList.iterator(); iter.hasNext();) {
172
				String id = (String) iter.next();
172
				String id = (String) iter.next();
173
				BundleDescription bundle = state.getResolvedBundle(id);
173
				BundleDescription bundle = state.getResolvedBundle(id);
174
				if (bundle == null) {
175
					//TODO error?
176
					continue;
177
				}
174
				String filter = bundle.getPlatformFilter();
178
				String filter = bundle.getPlatformFilter();
175
				if (filter == null || helper.createFilter(filter).match(environment)) {
179
				if (filter == null || helper.createFilter(filter).match(environment)) {
176
					if (BUNDLE_OSGI.equals(id))
180
					if (BUNDLE_OSGI.equals(id))
(-)src/org/eclipse/pde/internal/build/AbstractScriptGenerator.java (-5 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 35-40 Link Here
35
	private static PDEUIStateWrapper pdeUIState;
35
	private static PDEUIStateWrapper pdeUIState;
36
36
37
	/** Location of the plug-ins and fragments. */
37
	/** Location of the plug-ins and fragments. */
38
	protected String[] sitePaths;
38
	protected String[] pluginPath;
39
	protected String[] pluginPath;
39
	protected BuildTimeSiteFactory siteFactory;
40
	protected BuildTimeSiteFactory siteFactory;
40
41
Lines 235-248 Link Here
235
	}
236
	}
236
237
237
	/**
238
	/**
238
	 * Method getPaths. 
239
	 * Method getPaths.  These are the paths used for the BuildTimeSite
239
	 * @return URL[]
240
	 * @return URL[]
240
	 */
241
	 */
241
	private String[] getPaths() {
242
	private String[] getPaths() {
242
		if (pluginPath != null)
243
		if (sitePaths == null) {
243
			return pluginPath;
244
			if (pluginPath != null) {
245
				sitePaths = new String[pluginPath.length + 1];
246
				System.arraycopy(pluginPath, 0, sitePaths, 0, pluginPath.length);
247
				sitePaths[sitePaths.length - 1] = workingDirectory;
248
			} else {
249
				sitePaths = new String[] {workingDirectory};
250
			}
251
		}
244
252
245
		return new String[] {workingDirectory};
253
		return sitePaths;
246
	}
254
	}
247
255
248
	public void setBuildSiteFactory(BuildTimeSiteFactory siteFactory) {
256
	public void setBuildSiteFactory(BuildTimeSiteFactory siteFactory) {
Lines 290-295 Link Here
290
			pdeUIState = new PDEUIStateWrapper();
298
			pdeUIState = new PDEUIStateWrapper();
291
	}
299
	}
292
	
300
	
301
	protected boolean havePDEUIState() {
302
		return pdeUIState != null;
303
	}
304
	
305
	//Find a file in a bundle or a feature.
306
	//location is assumed to be structured like : /<featureId | pluginId>/path.to.the.file
293
	protected String findFile(String location, boolean makeRelative) {
307
	protected String findFile(String location, boolean makeRelative) {
294
		if (location == null)
308
		if (location == null)
295
			return null;
309
			return null;
(-)src/org/eclipse/pde/internal/build/ProductFile.java (-9 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import java.io.*;
14
import java.io.*;
15
import java.util.*;
15
import java.util.*;
16
import javax.xml.parsers.*;
16
import javax.xml.parsers.*;
17
import org.eclipse.core.runtime.*;
17
import org.xml.sax.*;
18
import org.xml.sax.*;
18
import org.xml.sax.helpers.DefaultHandler;
19
import org.xml.sax.helpers.DefaultHandler;
19
20
Lines 21-27 Link Here
21
 * 
22
 * 
22
 * @since 3.1
23
 * @since 3.1
23
 */
24
 */
24
public class ProductFile extends DefaultHandler {
25
public class ProductFile extends DefaultHandler implements IPDEBuildConstants {
25
	private final static SAXParserFactory parserFactory = SAXParserFactory.newInstance();
26
	private final static SAXParserFactory parserFactory = SAXParserFactory.newInstance();
26
27
27
	private static final String SOLARIS_LARGE = "solarisLarge"; //$NON-NLS-1$
28
	private static final String SOLARIS_LARGE = "solarisLarge"; //$NON-NLS-1$
Lines 50-62 Link Here
50
	private String id = null;
51
	private String id = null;
51
	private boolean useFeatures = false;
52
	private boolean useFeatures = false;
52
	private List plugins = null;
53
	private List plugins = null;
54
	private List features = null;
53
	private String splashLocation = null;
55
	private String splashLocation = null;
54
	private String productName;
56
	private String productName;
55
57
56
	/**
58
	/**
57
	 * Constructs a feature parser.
59
	 * Constructs a feature parser.
58
	 */
60
	 */
59
	public ProductFile(String location, String os) {
61
	public ProductFile(String location, String os) throws CoreException {
60
		super();
62
		super();
61
		this.location = new File(location);
63
		this.location = new File(location);
62
		this.currentOS = os;
64
		this.currentOS = os;
Lines 64-74 Link Here
64
			parserFactory.setNamespaceAware(true);
66
			parserFactory.setNamespaceAware(true);
65
			parser = parserFactory.newSAXParser();
67
			parser = parserFactory.newSAXParser();
66
		} catch (ParserConfigurationException e) {
68
		} catch (ParserConfigurationException e) {
67
			if (BundleHelper.getDefault().isDebugging())
69
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PRODUCT_FORMAT, e.getLocalizedMessage(), e));
68
				System.out.println(e);	
69
		} catch (SAXException e) {
70
		} catch (SAXException e) {
70
			if (BundleHelper.getDefault().isDebugging())
71
			throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PRODUCT_FORMAT, e.getLocalizedMessage(), e));
71
				System.out.println(e);
72
		}
72
		}
73
	}
73
	}
74
74
Lines 85-90 Link Here
85
		return plugins;
85
		return plugins;
86
	}
86
	}
87
	
87
	
88
	public List getFeatures() {
89
		if(!parsed)
90
			parse();
91
		return features;
92
	}
93
	
88
	public boolean containsPlugin(String plugin) {
94
	public boolean containsPlugin(String plugin) {
89
		if(!parsed)
95
		if(!parsed)
90
			parse();
96
			parse();
Lines 183-188 Link Here
183
			processPlugin(attributes);
189
			processPlugin(attributes);
184
		} else if ("splash".equals(localName)) { //$NON-NLS-1$
190
		} else if ("splash".equals(localName)) { //$NON-NLS-1$
185
			splashLocation = attributes.getValue("location"); //$NON-NLS-1$
191
			splashLocation = attributes.getValue("location"); //$NON-NLS-1$
192
		} else if ("feature".equals(localName)) { //$NON-NLS-1$
193
			processFeature(attributes);
186
		}
194
		}
187
	}
195
	}
188
196
Lines 191-204 Link Here
191
			plugins = new ArrayList();
199
			plugins = new ArrayList();
192
		plugins.add(attributes.getValue("id")); //$NON-NLS-1$
200
		plugins.add(attributes.getValue("id")); //$NON-NLS-1$
193
	}
201
	}
202
	
203
	private void processFeature(Attributes attributes) {
204
		if (features == null)
205
			features = new ArrayList();
206
		features.add(attributes.getValue("id")); //$NON-NLS-1$
207
	}
194
208
195
	private void processProduct(Attributes attributes) {
209
	private void processProduct(Attributes attributes) {
196
		id = attributes.getValue("id"); //$NON-NLS-1$
210
		id = attributes.getValue("id"); //$NON-NLS-1$
197
		productName = attributes.getValue("name"); //$NON-NLS-1$
211
		productName = attributes.getValue("name"); //$NON-NLS-1$
198
		String use = attributes.getValue("useFeatures"); //$NON-NLS-1$
212
		String use = attributes.getValue("useFeatures"); //$NON-NLS-1$
199
		if (use != null)
213
		if (use != null)
200
			useFeatures = IBuildPropertiesConstants.TRUE.equals(use.toUpperCase());
214
			useFeatures = IBuildPropertiesConstants.TRUE.equalsIgnoreCase(use);
201
202
	}
215
	}
203
216
204
	private void processConfigIni(Attributes attributes) {
217
	private void processConfigIni(Attributes attributes) {
(-)src/org/eclipse/pde/internal/build/BuildScriptGenerator.java (-7 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-25 Link Here
18
import org.eclipse.pde.internal.build.builder.*;
18
import org.eclipse.pde.internal.build.builder.*;
19
import org.eclipse.pde.internal.build.packager.PackageScriptGenerator;
19
import org.eclipse.pde.internal.build.packager.PackageScriptGenerator;
20
import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
20
import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
21
import org.eclipse.update.core.IFeature;
21
import org.eclipse.update.core.*;
22
import org.eclipse.update.core.VersionedIdentifier;
23
import org.osgi.framework.Version;
22
import org.osgi.framework.Version;
24
23
25
public class BuildScriptGenerator extends AbstractScriptGenerator {
24
public class BuildScriptGenerator extends AbstractScriptGenerator {
Lines 326-335 Link Here
326
		this.elements = elements;
325
		this.elements = elements;
327
	}
326
	}
328
327
329
	public void setPluginPath(String[] pluginPath) {
330
		this.pluginPath = pluginPath;
331
	}
332
333
	/**
328
	/**
334
	 * Sets the recursiveGeneration.
329
	 * Sets the recursiveGeneration.
335
	 * 
330
	 * 
(-)src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java (-1 / +11 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build;
11
package org.eclipse.pde.internal.build;
12
12
13
import java.io.File;
13
import java.util.*;
14
import java.util.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
15
import org.eclipse.osgi.service.resolver.BundleDescription;
16
import org.eclipse.osgi.service.resolver.BundleDescription;
Lines 86-92 Link Here
86
		String productPath = findFile(product, false);
87
		String productPath = findFile(product, false);
87
		if (productPath == null)
88
		if (productPath == null)
88
			productPath = product;
89
			productPath = product;
89
		productFile = new ProductFile(productPath, configInfo.getOs());
90
		File f = new File(productPath);
91
		if (f.exists() && f.isFile()) {
92
			try {
93
				productFile = new ProductFile(productPath, configInfo.getOs());
94
			} catch (CoreException e) {
95
				// TODO log
96
			}
97
		} else {
98
			//TODO log
99
		}
90
	}
100
	}
91
101
92
	private String computeIconsList() {
102
	private String computeIconsList() {
(-)templates/headless-build/build.properties (-1 / +4 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2003, 2005 IBM Corporation and others.
2
# Copyright (c) 2003, 2006 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 22-27 Link Here
22
product=/plugin or feature id/path/to/.product
22
product=/plugin or feature id/path/to/.product
23
runPackager=true
23
runPackager=true
24
24
25
#Set the name of the archive that will result from the product build.
26
#archiveNamePrefix=
27
25
# The prefix that will be used in the generated archive.
28
# The prefix that will be used in the generated archive.
26
archivePrefix=<output archive root>
29
archivePrefix=<output archive root>
27
30
(-)templates/headless-build/customTargets.xml (-16 / +4 lines)
Lines 4-27 Link Here
4
	<!-- Run a given ${target} on all elements being built -->
4
	<!-- Run a given ${target} on all elements being built -->
5
	<!-- Add on <ant> task for each top level element being built. -->
5
	<!-- Add on <ant> task for each top level element being built. -->
6
	<!-- ===================================================================== -->
6
	<!-- ===================================================================== -->
7
	<property name="allElementsFile" value="${builder}/allElements.xml"/>
8
	<import file="${allElementsFile}" />
7
	<target name="allElements">
9
	<target name="allElements">
8
		<ant antfile="${genericTargets}" target="${target}">
10
		<antcall target="allElementsDelegator" />
9
		<property name="type" value="<feature | plugin | fragment>" />
10
		<property name="id" value="<element.id>" />
11
		</ant>
12
	</target>
11
	</target>
13
12
	
14
	<!-- ===================================================================== -->
15
	<!-- Targets to assemble the built elements for particular configurations  -->
16
	<!-- These generally call the generated assemble scripts (named in -->
17
	<!-- ${assembleScriptName}) but may also add pre and post processing -->
18
	<!-- Add one target for each root element and each configuration -->
19
	<!-- ===================================================================== -->
20
21
	<target name="assemble.<element.id>[.config.spec]">
22
		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
23
	</target>
24
25
	<!-- ===================================================================== -->
13
	<!-- ===================================================================== -->
26
	<!-- ===================================================================== -->
14
	<!-- ===================================================================== -->
27
	<target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
15
	<target name="getBaseComponents" depends="checkLocalBase" unless="skipBase">
(-)scripts/build.xml (-2 / +3 lines)
Lines 8-15 Link Here
8
<property name="builderDirectory" location="${builder}"/>
8
<property name="builderDirectory" location="${builder}"/>
9
<property name="buildProperties" location="${builder}/build.properties"/>
9
<property name="buildProperties" location="${builder}/build.properties"/>
10
<property file="${buildProperties}"/>
10
<property file="${buildProperties}"/>
11
<property name="customTargets" location="${builderDirectory}/customTargets.xml"/>
11
<available property="customTargets" file="${builder}/customTargets.xml" value="${builder}/customTargets.xml"/>
12
<property name="genericTargets" location="genericTargets.xml"/>
12
<property name="customTargets" location="${eclipse.pdebuild.templates}/headless-build/customTargets.xml"/>
13
<property name="genericTargets" location="${eclipse.pdebuild.scripts}/genericTargets.xml"/>
13
14
14
<!-- ===================================================================== -->
15
<!-- ===================================================================== -->
15
<!-- main entry point to setup, fetch, generate, build etc. Use -->
16
<!-- main entry point to setup, fetch, generate, build etc. Use -->
(-)src_ant/org/eclipse/pde/internal/build/tasks/BuildScriptGeneratorTask.java (-2 / +3 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.build.tasks;
11
package org.eclipse.pde.internal.build.tasks;
12
12
13
import java.io.File;
13
import org.apache.tools.ant.BuildException;
14
import org.apache.tools.ant.BuildException;
14
import org.apache.tools.ant.Task;
15
import org.apache.tools.ant.Task;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
Lines 51-60 Link Here
51
	/**
52
	/**
52
	 * Set the plug-in path to be the given value.
53
	 * Set the plug-in path to be the given value.
53
	 * 
54
	 * 
54
	 * @param pluginPath the plug-in path
55
	 * @param pluginPath a File.pathSeparator separated list of paths
55
	 */
56
	 */
56
	public void setPluginPath(String pluginPath) {
57
	public void setPluginPath(String pluginPath) {
57
		generator.setPluginPath(Utils.getArrayFromString(pluginPath));
58
		generator.setPluginPath(Utils.getArrayFromString(pluginPath, File.pathSeparator));
58
	}
59
	}
59
60
60
	/**
61
	/**
(-)src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java (-2 / +2 lines)
Lines 532-538 Link Here
532
	 *  
532
	 *  
533
	 */
533
	 */
534
	private void generateRootFilesAndPermissions() throws CoreException {
534
	private void generateRootFilesAndPermissions() throws CoreException {
535
		if (product != null) {
535
		if (product != null && !havePDEUIState()) {
536
			ProductGenerator generator = new ProductGenerator();
536
			ProductGenerator generator = new ProductGenerator();
537
			generator.setProduct(product);
537
			generator.setProduct(product);
538
			generator.setBuildSiteFactory(siteFactory);
538
			generator.setBuildSiteFactory(siteFactory);
Lines 1149-1155 Link Here
1149
				while (tokenizer.hasMoreTokens()){
1149
				while (tokenizer.hasMoreTokens()){
1150
					String token = tokenizer.nextToken();
1150
					String token = tokenizer.nextToken();
1151
					if (token.startsWith("unpack")){ //$NON-NLS-1$
1151
					if (token.startsWith("unpack")){ //$NON-NLS-1$
1152
						unpack = (token.toUpperCase().indexOf(TRUE) > -1);
1152
						unpack = (token.toLowerCase().indexOf(TRUE) > -1);
1153
						break;
1153
						break;
1154
					}
1154
					}
1155
				}
1155
				}
(-)plugin.xml (+23 lines)
Lines 21-26 Link Here
21
      </antTask>
21
      </antTask>
22
      <antTask
22
      <antTask
23
            library="lib/pdebuild-ant.jar"
23
            library="lib/pdebuild-ant.jar"
24
            name="eclipse.generateFeature"
25
            class="org.eclipse.pde.internal.build.tasks.FeatureGeneratorTask">
26
      </antTask>
27
      <antTask
28
            library="lib/pdebuild-ant.jar"
24
            name="eclipse.buildManifest"
29
            name="eclipse.buildManifest"
25
            class="org.eclipse.pde.internal.build.tasks.BuildManifestTask">
30
            class="org.eclipse.pde.internal.build.tasks.BuildManifestTask">
26
      </antTask>
31
      </antTask>
Lines 84-88 Link Here
84
         <run class="org.eclipse.pde.internal.build.BuildApplication"/>
89
         <run class="org.eclipse.pde.internal.build.BuildApplication"/>
85
      </application>
90
      </application>
86
   </extension>
91
   </extension>
92
   <extension
93
         point="org.eclipse.ant.core.antProperties">
94
      <antProperty
95
            class="org.eclipse.pde.internal.build.properties.PDEProperties"
96
            eclipseRuntime="false"
97
            headless="true"
98
            name="eclipse.pdebuild.home"/>
99
      <antProperty
100
            class="org.eclipse.pde.internal.build.properties.PDEProperties"
101
            eclipseRuntime="false"
102
            headless="true"
103
            name="eclipse.pdebuild.scripts"/>
104
      <antProperty
105
            class="org.eclipse.pde.internal.build.properties.PDEProperties"
106
            eclipseRuntime="false"
107
            headless="true"
108
            name="eclipse.pdebuild.templates"/>                        
109
   </extension>
87
110
88
</plugin>
111
</plugin>
(-)src/org/eclipse/pde/internal/build/properties/PDEProperties.java (+46 lines)
Added Link Here
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 Corporation - initial API and implementation
10
 *****************************************/
11
 
12
package org.eclipse.pde.internal.build.properties;
13
14
import java.io.IOException;
15
import org.eclipse.ant.core.IAntPropertyValueProvider;
16
import org.eclipse.core.runtime.Platform;
17
18
public class PDEProperties implements IAntPropertyValueProvider {
19
	static private final String PREFIX = "eclipse.pdebuild"; //$NON-NLS-1$
20
	static private final String HOME = PREFIX + ".home"; //$NON-NLS-1$
21
	static private final String SCRIPTS = PREFIX + ".scripts"; //$NON-NLS-1$
22
	static private final String TEMPLATES = PREFIX + ".templates"; //$NON-NLS-1$
23
	
24
	public String getAntPropertyValue(String antPropertyName) {
25
		String searchedEntry = null;
26
		if (HOME.equals(antPropertyName))
27
			searchedEntry = "."; //$NON-NLS-1$
28
		
29
		if (SCRIPTS.equals(antPropertyName))
30
			searchedEntry = "scripts"; //$NON-NLS-1$
31
		
32
		if (TEMPLATES.equals(antPropertyName))
33
			searchedEntry = "templates"; //$NON-NLS-1$
34
		
35
		if (searchedEntry == null)
36
			return null; //TODO Throw an expcetion or log an error
37
		
38
		try {
39
			return Platform.asLocalURL(Platform.getBundle("org.eclipse.pde.build").getEntry(searchedEntry)).getPath(); //$NON-NLS-1$
40
		} catch (IOException e) {
41
			return null;
42
		}
43
		
44
	}
45
46
}
(-)scripts/productBuild/allElements.xml (+87 lines)
Added Link Here
1
<project name="Product Build allElements Delegator">
2
	<property name="archiveNamePrefix" value="${buildId}"/>
3
	
4
 	<!-- ===================================================================== -->
5
 	<!-- Run a given ${target} on all elements being built                     -->
6
 	<!-- Add on <ant> task for each top level element being built.             -->
7
 	<!-- ===================================================================== -->
8
 	<target name="allElementsDelegator">
9
 		<ant antfile="${genericTargets}" target="${target}">
10
	 		<property name="type" value="feature" />
11
	 		<property name="id" value="org.eclipse.pde.build.container.feature" />
12
 		</ant>
13
 	</target>
14
 
15
 	<!-- ===================================================================== -->
16
 	<!-- Targets to assemble the built elements for particular configurations  -->
17
 	<!-- These generally call the generated assemble scripts (named in         -->
18
 	<!-- ${assembleScriptName}) but may also add pre and post processing       -->
19
 	<!-- Add one target for each root element and each configuration           -->
20
 	<!-- ===================================================================== -->
21
 	<target name="assemble.org.eclipse.pde.build.container.feature">
22
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">
23
			<property name="archiveName" value="${archiveNamePrefix}.zip"/>
24
		</ant>
25
 	</target>
26
	
27
 	<target name="assemble.org.eclipse.pde.build.container.feature.win32.win32.x86">
28
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
29
 			<property name="archiveName" value="${archiveNamePrefix}-win32.win32.x86.zip"/>
30
		</ant>
31
32
 	</target>
33
	
34
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.ppc">
35
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
36
 			<property name="archiveName" value="${archiveNamePrefix}-linux.gtk.ppc.zip"/>
37
		</ant>
38
 	</target>
39
	
40
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.x86">
41
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
42
 			<property name="archiveName" value="${archiveNamePrefix}-linux.gtk.x86.zip"/>
43
		</ant>
44
 	</target>
45
	
46
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.x86_64">
47
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
48
 			<property name="archiveName" value="${archiveNamePrefix}-linux.gtk.x86_64.zip"/>
49
		</ant>
50
 	</target>
51
	
52
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.motif.x86">
53
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
54
 			<property name="archiveName" value="${archiveNamePrefix}-linux.motif.x86.zip"/>
55
		</ant>
56
 	</target>
57
	
58
 	<target name="assemble.org.eclipse.pde.build.container.feature.solaris.motif.sparc">
59
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
60
 			<property name="archiveName" value="${archiveNamePrefix}-solaris.motif.sparc.zip"/>
61
		</ant>
62
 	</target>
63
 		
64
 	<target name="assemble.org.eclipse.pde.build.container.feature.solaris.gtk.sparc">
65
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
66
 			<property name="archiveName" value="${archiveNamePrefix}-solaris.gtk.sparc.zip"/>
67
		</ant>
68
 	</target>
69
	
70
 	<target name="assemble.org.eclipse.pde.build.container.feature.aix.motif.ppc">
71
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
72
 			<property name="archiveName" value="${archiveNamePrefix}-aix.motif.ppc.zip"/>
73
		</ant>
74
 	</target>
75
	
76
 	<target name="assemble.org.eclipse.pde.build.container.feature.hpux.motif.PA_RISC">
77
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
78
 			<property name="archiveName" value="${archiveNamePrefix}-hpux.motif.PA_RISC.zip"/>
79
		</ant>
80
 	</target>
81
	
82
 	<target name="assemble.org.eclipse.pde.build.container.feature.macosx.carbon.ppc">
83
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}">			
84
 			<property name="archiveName" value="${archiveNamePrefix}-macosx.carbon.ppc.tar.gz"/>
85
		</ant>
86
 	</target>
87
</project>
(-)templates/headless-build/allElements.xml (+25 lines)
Added Link Here
1
<project name="allElements Delegator">
2
	
3
 	<!-- ===================================================================== -->
4
 	<!-- Run a given ${target} on all elements being built                     -->
5
 	<!-- Replace element.id with the id of the top level element being built   -->
6
 	<!-- Add on <ant> task for each top level element being built.             -->
7
 	<!-- ===================================================================== -->
8
 	<target name="allElementsDelegator">
9
 		<ant antfile="${genericTargets}" target="${target}">
10
	 		<property name="type" value="feature | plugin | fragment" />
11
	 		<property name="id" value="element.id" />
12
 		</ant>
13
 	</target>
14
 
15
 	<!-- ===================================================================== -->
16
 	<!-- Targets to assemble the built elements for particular configurations  -->
17
 	<!-- These generally call the generated assemble scripts (named in         -->
18
 	<!-- ${assembleScriptName}) but may also add pre and post processing       -->
19
 	<!-- Add one target for each root element and each configuration           -->
20
 	<!-- Replace element.id with the id of the top level element being built   -->
21
 	<!-- ===================================================================== -->
22
 	<target name="assemble.element.id[.config.spec]">
23
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
24
 	</target>
25
</project>
(-)scripts/productBuild/productBuild.xml (+45 lines)
Added Link Here
1
<project name="Build a Product" default="main">
2
3
<!-- ===================================================================== -->
4
<!-- Global properties.  See the build.properties for information on -->
5
<!-- the properties which callers can control. -->
6
<!-- ===================================================================== -->
7
<property name="allElementsFile" value="${eclipse.pdebuild.scripts}/productBuild/allElements.xml"/>
8
9
<import file="${eclipse.pdebuild.scripts}/build.xml"/>
10
11
<!-- ===================================================================== -->
12
<!-- main entry point to setup, fetch, generate, build etc. Use -->
13
<!-- the customTargets.xml to modify the build behaviour. -->
14
<!-- ===================================================================== -->
15
<target name="main" description="the main build target">	
16
  	<antcall target="preBuild" /> 
17
	<antcall target="generateFeature"/> <!-- Generate the feature to drive the fetch -->
18
 	<antcall target="fetch" />
19
	<antcall target="generateFeature"> <!-- We are calling generate feature a second time so that we can get the pack / unpack clause fixed -->
20
		<param name="verify" value="true"/>
21
	</antcall> 
22
	<antcall target="generate" /> 
23
	<antcall target="process" /> 
24
	<antcall target="assemble" />
25
	<antcall target="package" />
26
	<antcall target="postBuild" />
27
</target>
28
29
<!-- ===================================================================== -->
30
<!-- Generate a container feature based on the product file                -->
31
<!-- The plugin or feature containing the .product file will need to exist -->
32
<!-- already, use preSetup or postSetup to fetch it if necessary           -->
33
<!-- ===================================================================== -->
34
<target name="generateFeature">
35
	<eclipse.generateFeature
36
		featureId="org.eclipse.pde.build.container.feature"
37
		buildDirectory="${buildDirectory}"
38
		baseLocation="${baseLocation}"
39
		productFile="${product}"
40
		verify="${verify}"
41
	/>
42
</target>
43
44
45
</project>
(-)src_ant/org/eclipse/pde/internal/build/tasks/FeatureGeneratorTask.java (+107 lines)
Added Link Here
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;
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.FeatureGenerator;
18
import org.eclipse.pde.internal.build.Utils;
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
28
	public void execute() throws BuildException {
29
		try {
30
			run();
31
		} catch (CoreException e) {
32
			throw new BuildException(e);
33
		}
34
	}
35
36
	public void run() throws CoreException {
37
		generator.generate();
38
	}
39
40
	/** 
41
	 * Set the folder in which the build will occur.
42
	 * @param buildDirectory the location where the build will occur.
43
	 */
44
	public void setBuildDirectory(String buildDirectory) {
45
		generator.setWorkingDirectory(buildDirectory);
46
	}
47
48
	/**
49
	 * Set the product file to base the feature on
50
	 * @param productFile
51
	 */
52
	public void setProductFile(String productFile) {
53
		generator.setProductFile(productFile);
54
	}
55
56
	/**
57
	 * Set a location that contains plugins and features required by plugins and features 
58
	 * for which the feature is being generated
59
	 * @param baseLocation
60
	 */
61
	public void setBaseLocation(String baseLocation) {
62
		BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
63
	}
64
65
	/**
66
	 * Set a list of plugin ids to be included in the generated feature
67
	 * @param pluginList a comma separated list of plugin ids
68
	 */
69
	public void setPluginList(String pluginList) {
70
		if (pluginList != null && !pluginList.startsWith("${")) //$NON-NLS-1$
71
			generator.setPluginList(Utils.getArrayFromString(pluginList));
72
	}
73
74
	/**
75
	 * Set a list of feature ids to be include in the generated feature
76
	 * @param featureList a comma separated list of feature ids
77
	 */
78
	public void setFeatureList(String featureList) {
79
		if (featureList != null && !featureList.startsWith("${")) //$NON-NLS-1$
80
			generator.setFeatureList(Utils.getArrayFromString(featureList));
81
	}
82
	
83
	/**
84
	 * The id to give to the generated feature
85
	 * @param featureId
86
	 */
87
	public void setFeatureId(String featureId) {
88
		generator.setFeatureId(featureId);
89
	}
90
	
91
	/**
92
	 * Set the list of additional paths in which to look for required plugins
93
	 * 
94
	 * @param pluginPath a {@link File.pathSeparator} separated list of paths
95
	 */
96
	public void setPluginPath(String pluginPath) {
97
		generator.setPluginPath(Utils.getArrayFromString(pluginPath, File.pathSeparator));
98
	}
99
	
100
	/**
101
	 * Set to true if you want to verify that the plugins and features are available.  
102
	 * @param verify
103
	 */
104
	public void setVerify(boolean verify) {
105
		generator.setVerify(verify);
106
	}
107
}
(-)src/org/eclipse/pde/internal/build/FeatureGenerator.java (+171 lines)
Added Link Here
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;
12
13
import java.io.*;
14
import java.util.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.osgi.service.resolver.BundleDescription;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.pde.internal.build.site.PDEState;
19
20
public class FeatureGenerator extends AbstractScriptGenerator {
21
	private String featureId = null;
22
	private String productFile = null;
23
	private String[] pluginList = null;
24
	private String[] featureList = null;
25
26
	private ProductFile product = null;
27
28
	private boolean verify = false;
29
	
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.pde.internal.build.AbstractScriptGenerator#generate()
32
	 */
33
	public void generate() throws CoreException {
34
		initialize();
35
36
		List plugins = pluginList != null ? Arrays.asList(pluginList) : new ArrayList();
37
		List features = featureList != null ? Arrays.asList(featureList) : new ArrayList();
38
		if (product != null) {
39
			List productElements = product.useFeatures() ? product.getFeatures() : product.getPlugins();
40
			if (productElements != null && productElements.size() > 0) {
41
				if (product.useFeatures())
42
					features.addAll(productElements);
43
				else
44
					plugins.addAll(productElements);
45
			}
46
		}
47
		
48
		try {
49
			createFeature(featureId, plugins, features);
50
		} catch (FileNotFoundException e) {
51
			//error
52
		}
53
	}
54
55
	public void setProductFile(String productFile) {
56
		this.productFile  = productFile;
57
	}
58
59
	public void setPluginList(String[] pluginList) {
60
		this.pluginList = pluginList;
61
	}
62
	
63
	public void setFeatureList(String[] featureList) {
64
		this.featureList = featureList;
65
	}
66
67
	public void setFeatureId(String featureId) {
68
		this.featureId = featureId;
69
	}
70
	
71
	private void initialize(){
72
		if (productFile != null && !productFile.startsWith("${")) { //$NON-NLS-1$
73
			String productPath = findFile(productFile, false);
74
			if (productPath == null)
75
				productPath = productFile;
76
			File f = new File(productPath);
77
			if (f.exists() && f.isFile()) {
78
				try {
79
					product = new ProductFile(productPath, null);
80
				} catch (CoreException e) {
81
					// log
82
				}
83
			}
84
		}
85
	}
86
	
87
	protected void createFeature(String feature, List plugins, List features) throws CoreException, FileNotFoundException {
88
		String location = IPDEBuildConstants.DEFAULT_FEATURE_LOCATION + '/' + feature;
89
		File directory = new File(getWorkingDirectory(), location);
90
		if (!directory.exists())
91
			directory.mkdirs();
92
93
		PDEState state = verify ? getSite(false).getRegistry() : null;
94
95
		//Create feature.xml
96
		File file = new File(directory, IPDEBuildConstants.DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
97
		OutputStream output = new FileOutputStream(file);
98
		XMLWriter writer = null;
99
		try {
100
			writer = new XMLWriter(output);
101
		} catch (UnsupportedEncodingException e) {
102
			//should not happen
103
			return;
104
		}
105
		Map parameters = new HashMap();
106
107
		parameters.put("id", feature); //$NON-NLS-1$
108
		parameters.put("version", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$
109
		writer.startTag("feature", parameters, true); //$NON-NLS-1$
110
111
		for (Iterator iter = plugins.iterator(); iter.hasNext();) {
112
			String name = (String) iter.next();
113
			boolean unpack = true;
114
			if (verify) {
115
				BundleDescription bundle = state.getResolvedBundle(name);
116
				if (bundle != null){
117
					String [] bundleClasspath = (String[]) state.getExtraData().get(new Long(bundle.getBundleId()));
118
					unpack = !(bundleClasspath == null || bundleClasspath.length == 0 || bundleClasspath[0].equals(".")); //$NON-NLS-1$
119
				} else {
120
					//throw error
121
					String message = NLS.bind(Messages.exception_missingPlugin, name);
122
					throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PLUGIN_MISSING, message, null));
123
				}
124
			}
125
			parameters.clear();
126
			parameters.put("id", name); //$NON-NLS-1$
127
			parameters.put("version", "0.0.0"); //$NON-NLS-1$//$NON-NLS-2$
128
			parameters.put("unpack", unpack ? "true" : "false");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
129
			writer.printTag("plugin", parameters, true, true, true); //$NON-NLS-1$
130
		}
131
		
132
		for (Iterator iter = features.iterator(); iter.hasNext();) {
133
			String name = (String) iter.next();
134
			if (verify) {
135
				//this will throw an exception if the feature is not found.
136
				getSite(false).findFeature(name, null, true);
137
			}
138
			parameters.clear();
139
			parameters.put("id", name); //$NON-NLS-1$
140
			parameters.put("version", "0.0.0");  //$NON-NLS-1$//$NON-NLS-2$
141
			writer.printTag("includes", parameters, true, true, true); //$NON-NLS-1$
142
			
143
		}
144
		writer.endTag("feature"); //$NON-NLS-1$
145
		writer.close();
146
		
147
		//create build.properties
148
		file = new File(directory, IPDEBuildConstants.PROPERTIES_FILE);
149
		Properties prop = new Properties();
150
		prop.put("pde", "marker"); //$NON-NLS-1$ //$NON-NLS-2$
151
		FileOutputStream stream = null;
152
		try{
153
			stream = new FileOutputStream(file);
154
			prop.store(stream, "Marker File so that the file gets written");  //$NON-NLS-1$
155
			stream.flush();
156
		} catch (IOException e) {
157
			if( stream != null) {					
158
				try {
159
					stream.close();
160
				} catch (IOException e1) {
161
					// nothing
162
				}
163
			}
164
		}
165
		
166
	}
167
168
	public void setVerify(boolean verify) {
169
		this.verify = verify;
170
	}
171
}

Return to bug 107272