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

(-)scripts/build.xml (-1 / +2 lines)
Lines 8-14 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="customTargets" location="${basedir}/../templates/headless-build/customTargets.xml"/>
12
<property name="genericTargets" location="genericTargets.xml"/>
13
<property name="genericTargets" location="genericTargets.xml"/>
13
14
14
<!-- ===================================================================== -->
15
<!-- ===================================================================== -->
(-)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">
(-)src/org/eclipse/pde/internal/build/FetchScriptGenerator.java (-1 / +2 lines)
Lines 253-259 Link Here
253
			if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId)) {
253
			if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId)) {
254
				String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_FEATURE_PREFIX + featureId), ","); //$NON-NLS-1$
254
				String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_FEATURE_PREFIX + featureId), ","); //$NON-NLS-1$
255
				for (int j = 1; j < extraElementsToFetch.length; j++) {
255
				for (int j = 1; j < extraElementsToFetch.length; j++) {
256
					generateFetchEntry(extraElementsToFetch[j], false);
256
					String [] elements = Utils.getArrayFromString(extraElementsToFetch[j], ";"); //$NON-NLS-1$
257
					generateFetchEntry(elements[0], false);
257
				}
258
				}
258
				continue;
259
				continue;
259
			}
260
			}
(-)src/org/eclipse/pde/internal/build/ProductFile.java (-1 / +16 lines)
Lines 50-55 Link Here
50
	private String id = null;
50
	private String id = null;
51
	private boolean useFeatures = false;
51
	private boolean useFeatures = false;
52
	private List plugins = null;
52
	private List plugins = null;
53
	private List features = null;
53
	private String splashLocation = null;
54
	private String splashLocation = null;
54
	private String productName;
55
	private String productName;
55
56
Lines 85-90 Link Here
85
		return plugins;
86
		return plugins;
86
	}
87
	}
87
	
88
	
89
	public List getFeatures() {
90
		if(!parsed)
91
			parse();
92
		return features;
93
	}
94
	
88
	public boolean containsPlugin(String plugin) {
95
	public boolean containsPlugin(String plugin) {
89
		if(!parsed)
96
		if(!parsed)
90
			parse();
97
			parse();
Lines 183-188 Link Here
183
			processPlugin(attributes);
190
			processPlugin(attributes);
184
		} else if ("splash".equals(localName)) { //$NON-NLS-1$
191
		} else if ("splash".equals(localName)) { //$NON-NLS-1$
185
			splashLocation = attributes.getValue("location"); //$NON-NLS-1$
192
			splashLocation = attributes.getValue("location"); //$NON-NLS-1$
193
		} else if ("feature".equals(localName)) {
194
			processFeature(attributes);
186
		}
195
		}
187
	}
196
	}
188
197
Lines 191-203 Link Here
191
			plugins = new ArrayList();
200
			plugins = new ArrayList();
192
		plugins.add(attributes.getValue("id")); //$NON-NLS-1$
201
		plugins.add(attributes.getValue("id")); //$NON-NLS-1$
193
	}
202
	}
203
	
204
	private void processFeature(Attributes attributes) {
205
		if (features == null)
206
			features = new ArrayList();
207
		features.add(attributes.getValue("id")); //$NON-NLS-1$
208
	}
194
209
195
	private void processProduct(Attributes attributes) {
210
	private void processProduct(Attributes attributes) {
196
		id = attributes.getValue("id"); //$NON-NLS-1$
211
		id = attributes.getValue("id"); //$NON-NLS-1$
197
		productName = attributes.getValue("name"); //$NON-NLS-1$
212
		productName = attributes.getValue("name"); //$NON-NLS-1$
198
		String use = attributes.getValue("useFeatures"); //$NON-NLS-1$
213
		String use = attributes.getValue("useFeatures"); //$NON-NLS-1$
199
		if (use != null)
214
		if (use != null)
200
			useFeatures = IBuildPropertiesConstants.TRUE.equals(use.toUpperCase());
215
			useFeatures = IBuildPropertiesConstants.TRUE.equals(use.toLowerCase());
201
216
202
	}
217
	}
203
218
(-)plugin.xml (+5 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>
(-)scripts/productBuild/allElements.xml (+63 lines)
Added Link Here
1
<project name="Product Build allElements Delegator">
2
	 
3
 	<!-- ===================================================================== -->
4
 	<!-- Run a given ${target} on all elements being built                     -->
5
 	<!-- Add on <ant> task for each top level element being built.             -->
6
 	<!-- ===================================================================== -->
7
 	<target name="allElementsDelegator">
8
 		<ant antfile="${genericTargets}" target="${target}">
9
	 		<property name="type" value="feature" />
10
	 		<property name="id" value="org.eclipse.pde.build.container.feature" />
11
 		</ant>
12
 	</target>
13
 
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
 	<target name="assemble.org.eclipse.pde.build.container.feature">
21
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
22
 	</target>
23
	
24
 	<target name="assemble.org.eclipse.pde.build.container.feature.win32.win32.x86">
25
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
26
 	</target>
27
	
28
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.ppc">
29
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
30
 	</target>
31
	
32
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.x86">
33
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
34
 	</target>
35
	
36
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.gtk.x86_64">
37
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
38
 	</target>
39
	
40
 	<target name="assemble.org.eclipse.pde.build.container.feature.linux.motif.x86">
41
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
42
 	</target>
43
	
44
 	<target name="assemble.org.eclipse.pde.build.container.feature.solaris.motif.sparc">
45
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
46
 	</target>
47
 		
48
 	<target name="assemble.org.eclipse.pde.build.container.feature.solaris.gtk.sparc">
49
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
50
 	</target>
51
	
52
 	<target name="assemble.org.eclipse.pde.build.container.feature.aix.motif.ppc">
53
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
54
 	</target>
55
	
56
 	<target name="assemble.org.eclipse.pde.build.container.feature.hpux.motif.PA_RISC">
57
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
58
 	</target>
59
	
60
 	<target name="assemble.org.eclipse.pde.build.container.feature.macosx.carbon.ppc">
61
 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
62
 	</target>
63
</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 (+39 lines)
Added Link Here
1
<project name="Build All Elements" 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="builder" location="${user.dir}"/>
8
<property name="builderDirectory" location="${builder}"/>
9
<property name="buildProperties" location="${builder}/build.properties"/>
10
<property file="${buildProperties}"/>
11
12
<property name="allElementsFile" value="${basedir}/allElements.xml"/>
13
	
14
<!-- ===================================================================== -->
15
<!-- main entry point to setup, fetch, generate, build etc. Use -->
16
<!-- the customTargets.xml to modify the build behaviour. -->
17
<!-- ===================================================================== -->
18
19
<!-- ******* add in the descriptions for each of the top level targets to teh target decl -->
20
<target name="main" description="the main build target">	
21
  	<antcall target="generateFeature" /> 
22
	<ant antfile="${basedir}/../build.xml" target="main" dir=".." />
23
</target>
24
25
<!-- ===================================================================== -->
26
<!-- Steps to do before starting the build.  Typical setup includes -->
27
<!-- fetching the map files and building the directory.  -->
28
<!-- ===================================================================== -->
29
<target name="generateFeature">
30
	<eclipse.generateFeature
31
		featureId="org.eclipse.pde.build.container.feature"
32
		buildDirectory="${buildDirectory}"
33
		baseLocation="${baseLocation}"
34
		productFile="${product}"
35
	/>
36
</target>
37
38
39
</project>
(-)src_ant/org/eclipse/pde/internal/build/tasks/FeatureGeneratorTask.java (+64 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 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 org.apache.tools.ant.BuildException;
14
import org.apache.tools.ant.Task;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.pde.internal.build.FeatureGenerator;
17
import org.eclipse.pde.internal.build.Utils;
18
import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
19
20
/**
21
 * @author aniefer
22
 *
23
 */
24
public class FeatureGeneratorTask extends Task {
25
	private FeatureGenerator generator = new FeatureGenerator();
26
27
	public void execute() throws BuildException {
28
		try {
29
			run();
30
		} catch (CoreException e) {
31
			throw new BuildException(e);
32
		}
33
	}
34
35
	public void run() throws CoreException {
36
		generator.generate();
37
	}
38
39
	public void setBuildDirectory(String buildDirectory) {
40
		generator.setWorkingDirectory(buildDirectory);
41
	}
42
43
	public void setProductFile(String productFile) {
44
		generator.setProductFile(productFile);
45
	}
46
47
	public void setBaseLocation(String baseLocation) {
48
		BuildTimeSiteFactory.setInstalledBaseSite(baseLocation);
49
	}
50
51
	public void setPluginList(String pluginList) {
52
		if (pluginList != null && !pluginList.startsWith("${")) //$NON-NLS-1$
53
			generator.setPluginList(Utils.getArrayFromString(pluginList));
54
	}
55
56
	public void setFeatureList(String featureList) {
57
		if (featureList != null && !featureList.startsWith("${")) //$NON-NLS-1$
58
			generator.setFeatureList(Utils.getArrayFromString(featureList));
59
	}
60
	
61
	public void setFeatureId(String featureId) {
62
		generator.setFeatureId(featureId);
63
	}
64
}
(-)src/org/eclipse/pde/internal/build/FeatureGenerator.java (+151 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 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.CoreException;
16
import org.eclipse.osgi.service.resolver.BundleDescription;
17
import org.eclipse.pde.internal.build.site.PDEState;
18
19
/**
20
 * @author aniefer
21
 *
22
 */
23
public class FeatureGenerator extends AbstractScriptGenerator {
24
	private String featureId = null;
25
	private String productFile = null;
26
	private String[] pluginList = null;
27
	private String[] featureList = null;
28
29
	private ProductFile product = null;
30
	
31
	
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.pde.internal.build.AbstractScriptGenerator#generate()
34
	 */
35
	public void generate() throws CoreException {
36
		initialize();
37
38
		List plugins = pluginList != null ? Arrays.asList(pluginList) : new ArrayList();
39
		List features = featureList != null ? Arrays.asList(featureList) : new ArrayList();
40
		List productElements = product.useFeatures() ? product.getFeatures() : product.getPlugins();
41
		if (productElements.size() > 0) {
42
			if (product.useFeatures())
43
				features.addAll(productElements);
44
			else
45
				plugins.addAll(productElements);
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
			product = new ProductFile(productPath, null);
77
		}
78
	}
79
	
80
	protected void createFeature(String feature, List plugins, List features) throws CoreException, FileNotFoundException {
81
		String location = IPDEBuildConstants.DEFAULT_FEATURE_LOCATION + '/' + feature;
82
		File directory = new File(getWorkingDirectory(), location);
83
		if (!directory.exists())
84
			directory.mkdirs();
85
86
		PDEState state = getSite(false).getRegistry();
87
88
		//Create feature.xml
89
		File file = new File(directory, IPDEBuildConstants.DEFAULT_FEATURE_FILENAME_DESCRIPTOR);
90
		OutputStream output = new FileOutputStream(file);
91
		XMLWriter writer = null;
92
		try {
93
			writer = new XMLWriter(output);
94
		} catch (UnsupportedEncodingException e) {
95
			//should not happen
96
			return;
97
		}
98
		Map parameters = new HashMap();
99
100
		parameters.put("id", feature); //$NON-NLS-1$
101
		parameters.put("version", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$
102
		writer.startTag("feature", parameters, true); //$NON-NLS-1$
103
104
		for (Iterator iter = plugins.iterator(); iter.hasNext();) {
105
			String name = (String) iter.next();
106
			boolean unpack = true;
107
			BundleDescription bundle = state.getResolvedBundle(name);
108
			if (bundle != null){
109
				String [] bundleClasspath = (String[]) state.getExtraData().get(new Long(bundle.getBundleId()));
110
				unpack = !(bundleClasspath == null || bundleClasspath.length == 0 || bundleClasspath[0].equals(".")); //$NON-NLS-1$
111
			}
112
			
113
			parameters.clear();
114
			parameters.put("id", name); //$NON-NLS-1$
115
			parameters.put("version", "0.0.0"); //$NON-NLS-1$//$NON-NLS-2$
116
			parameters.put("unpack", unpack ? "true" : "false");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
117
			writer.printTag("plugin", parameters, true, true, true); //$NON-NLS-1$
118
		}
119
		
120
		for (Iterator iter = features.iterator(); iter.hasNext();) {
121
			String name = (String) iter.next();
122
			parameters.clear();
123
			parameters.put("id", name); //$NON-NLS-1$
124
			parameters.put("version", "0.0.0");  //$NON-NLS-1$//$NON-NLS-2$
125
			writer.printTag("includes", parameters, true, true, true); //$NON-NLS-1$
126
			
127
		}
128
		writer.endTag("feature"); //$NON-NLS-1$
129
		writer.close();
130
		
131
		//create build.properties
132
		file = new File(directory, IPDEBuildConstants.PROPERTIES_FILE);
133
		Properties prop = new Properties();
134
		prop.put("pde", "marker"); //$NON-NLS-1$ //$NON-NLS-2$
135
		FileOutputStream stream = null;
136
		try{
137
			stream = new FileOutputStream(file);
138
			prop.store(stream, "Marker File");  //$NON-NLS-1$
139
			stream.flush();
140
		} catch (IOException e) {
141
			if( stream != null) {					
142
				try {
143
					stream.close();
144
				} catch (IOException e1) {
145
					// nothing
146
				}
147
			}
148
		}
149
		
150
	}
151
}

Return to bug 107272