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 92714
Collapse All | Expand All

(-)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.sourceBuildScript"
25
            class="org.eclipse.pde.internal.build.tasks.SourceBuildScriptGeneratorTask">
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/build.xml (+12 lines)
Lines 9-14 Link Here
9
<property file="${buildProperties}"/>
9
<property file="${buildProperties}"/>
10
<property name="customTargets" location="${builderDirectory}/customTargets.xml"/>
10
<property name="customTargets" location="${builderDirectory}/customTargets.xml"/>
11
<property name="genericTargets" location="genericTargets.xml"/>
11
<property name="genericTargets" location="genericTargets.xml"/>
12
<!-- temparily enabled for testing -->
13
<property name="buildSourceDrop" value="true"/>
12
14
13
<!-- ===================================================================== -->
15
<!-- ===================================================================== -->
14
<!-- main entry point to setup, fetch, generate, build etc. Use -->
16
<!-- main entry point to setup, fetch, generate, build etc. Use -->
Lines 19-24 Link Here
19
<target name="main" description="the main build target">	
21
<target name="main" description="the main build target">	
20
  	<antcall target="preBuild" /> 
22
  	<antcall target="preBuild" /> 
21
 	<antcall target="fetch" />
23
 	<antcall target="fetch" />
24
	<antcall target="buildSourceDrop" />
22
	<antcall target="generate" /> 
25
	<antcall target="generate" /> 
23
	<antcall target="process" /> 
26
	<antcall target="process" /> 
24
	<antcall target="assemble" />
27
	<antcall target="assemble" />
Lines 65-70 Link Here
65
</target>
68
</target>
66
69
67
<!-- ===================================================================== -->
70
<!-- ===================================================================== -->
71
<!-- Make a buildable source zip -->
72
<!-- ===================================================================== -->
73
<target name="buildSourceDrop" if="buildSourceDrop" >
74
	<ant antfile="${customTargets}" target="allElements">
75
		<property name="target" value="buildSourceDrop" />
76
	</ant>
77
</target>
78
79
<!-- ===================================================================== -->
68
<!-- Run the build scripts for each element identified in the customTargets -->
80
<!-- Run the build scripts for each element identified in the customTargets -->
69
<!-- ===================================================================== -->
81
<!-- ===================================================================== -->
70
<target name="process">
82
<target name="process">
(-)scripts/genericTargets.xml (+28 lines)
Lines 8-13 Link Here
8
	recursiveGeneration
8
	recursiveGeneration
9
	workingDirectory
9
	workingDirectory
10
	configInfo
10
	configInfo
11
	buildId
11
-->
12
-->
12
13
13
<!-- ===================================================================== -->
14
<!-- ===================================================================== -->
Lines 64-69 Link Here
64
</target>
65
</target>
65
66
66
<!-- ===================================================================== -->
67
<!-- ===================================================================== -->
68
<!-- Make a build.xml for use in a buildable source zip -->
69
<!-- ===================================================================== -->
70
<target name="buildSourceDrop">
71
72
	<eclipse.sourceBuildScript 
73
		type="${type}"
74
		id="${id}" 
75
		buildDirectory="${buildDirectory}"
76
		buildId="${buildId}"
77
	/>
78
	
79
	<delete> 
80
		<fileset dir="${buildDirectory}" includes="**/*.so,**/*.dll" />
81
	</delete>
82
	
83
	<!-- TODO add logic for plugin only -->
84
	<zip destfile="${buildDirectory}/${id}-${buildId}-sourceBuild.zip">
85
    	<zipfileset dir="${buildDirectory}/features" prefix="eclipse/features"/>
86
    	<zipfileset file="${buildDirectory}/featureVersions.properties" />
87
    	<zipfileset dir="${buildDirectory}/plugins" prefix="eclipse/plugins"/>
88
    	<zipfileset file="${buildDirectory}/pluginVersions.properties" />
89
    	<zipfileset file="${buildDirectory}/${id}-build.xml" fullpath="build.xml" />
90
    </zip>
91
</target>
92
93
94
<!-- ===================================================================== -->
67
<!-- Run build.xml for a single element-->
95
<!-- Run build.xml for a single element-->
68
<!-- ===================================================================== -->
96
<!-- ===================================================================== -->
69
<target name="processElement" description="Processing build scripts..." depends="init">
97
<target name="processElement" description="Processing build scripts..." depends="init">
(-)src/org/eclipse/pde/internal/build/ant/AntScript.java (+65 lines)
Lines 83-88 Link Here
83
	}
83
	}
84
84
85
	/**
85
	/**
86
	 * FIXME javadocs
87
	 * Print an <code>antcall</code> task to the script. This calls Ant on the given 
88
	 * target which is located within the same build file. 
89
	 * 
90
	 * @param target the target of the ant call
91
	 * @param inheritAll <code>true</code> if the parameters should be pass to the
92
	 * 	called target
93
	 * @param params table of parameters for the call
94
	 */
95
	public void printAnt(String antfile, String dir, String target, String inheritAll, Map params) {
96
		printTab();
97
		output.print("<ant"); //$NON-NLS-1$
98
		printAttribute("antfile", antfile, false); //$NON-NLS-1$
99
		printAttribute("dir", dir, false); //$NON-NLS-1$
100
		printAttribute("target", target, false); //$NON-NLS-1$
101
		printAttribute("inheritAll", inheritAll, false); //$NON-NLS-1$
102
		if (params == null)
103
			output.println("/>"); //$NON-NLS-1$
104
		else {
105
			output.println(">"); //$NON-NLS-1$
106
			indent++;
107
			Set entries = params.entrySet();
108
			for (Iterator iter = entries.iterator(); iter.hasNext();) {
109
				Map.Entry entry = (Map.Entry) iter.next();
110
				printParam((String) entry.getKey(), (String) entry.getValue());
111
			}
112
			indent--;
113
			printTab();
114
			output.println("</ant>"); //$NON-NLS-1$
115
		}
116
	}
117
	
118
	
119
	/**
86
	 * Print a <code>jar</code> Ant task to this script. This jars together a group of 
120
	 * Print a <code>jar</code> Ant task to this script. This jars together a group of 
87
	 * files into a single file.
121
	 * files into a single file.
88
	 * 
122
	 * 
Lines 397-402 Link Here
397
	}
431
	}
398
432
399
	/**
433
	/**
434
	 FIXME java-doc
435
	 */
436
	public void printBuildScriptTask(String element, String buildDirectory, 
437
			String configInfo, String baseLocation, boolean buildingOSGi) {
438
		printTab();
439
		indent++;
440
		print("<eclipse.buildScript"); //$NON-NLS-1$
441
		println(); printTab(); 
442
		printAttribute("elements", element, true); //$NON-NLS-1$
443
		println(); printTab(); 
444
		printAttribute("buildDirectory", buildDirectory, true); //$NON-NLS-1$
445
		println(); printTab(); 
446
		printAttribute("configInfo", configInfo, true); //$NON-NLS-1$
447
		println(); printTab(); 
448
		printAttribute("baseLocation", baseLocation, true); //$NON-NLS-1$
449
		println(); printTab(); 
450
		printAttribute("buildingOSGi", buildingOSGi ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
451
		println(); printTab(); 
452
		indent--;
453
		println("/>"); //$NON-NLS-1$
454
	}
455
	
456
	/**
400
	 * Print an <code>echo</code> task to the Ant script.
457
	 * Print an <code>echo</code> task to the Ant script.
401
	 * 
458
	 * 
402
	 * @param message the message to echo to the output
459
	 * @param message the message to echo to the output
Lines 687-690 Link Here
687
		printAttribute("file", file, true); //$NON-NLS-1$
744
		printAttribute("file", file, true); //$NON-NLS-1$
688
		output.println("/>"); //$NON-NLS-1$
745
		output.println("/>"); //$NON-NLS-1$
689
	}
746
	}
747
748
	public void printTouch(String file) {
749
		printTab();
750
		output.print("<touch"); //$NON-NLS-1$
751
		printAttribute("file", file, true); //$NON-NLS-1$
752
		output.println("/>");  //$NON-NLS-1$
753
	}
754
	
690
}
755
}
(-)src/org/eclipse/pde/internal/build/SourceBuildScriptGenerator.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 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.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.core.runtime.CoreException;
17
18
public class SourceBuildScriptGenerator extends AbstractScriptGenerator {
19
20
	private final static String PROPERTY_CONFIG = "config"; //$NON-NLS-1$
21
	private final static String PROPERTY_BASE_LOCATION = "baseLocation"; //$NON-NLS-1$
22
	private final static String PROPERTY_BUILD_TEMP_FOLDER = "buildTempFolder"; //$NON-NLS-1$
23
	private final static String TARGET_BUILD = "build"; //$NON-NLS-1$
24
	private final static String TARGET_GENERATE = "generate"; //$NON-NLS-1$
25
	private final static String TARGET_ASSEMBLE = "assemble";  //$NON-NLS-1$
26
	private final static String PREFIX = "eclipse"; //$NON-NLS-1$
27
	
28
	
29
	
30
	private String type;
31
	private String id;
32
	private String buildId;
33
34
	/**
35
	 * TODO: add javadocs
36
	 * @throws CoreException
37
	 */
38
	public void generate() throws CoreException {
39
		
40
		openScript(workingDirectory, id + "-" + DEFAULT_BUILD_SCRIPT_FILENAME); //$NON-NLS-1$
41
		script.println();
42
		script.printComment("\"" + PROPERTY_BASE_LOCATION + "\" must be set by the caller of this script"); //$NON-NLS-1$ //$NON-NLS-2$
43
		script.printProjectDeclaration("Build " + id, TARGET_MAIN, null); //$NON-NLS-1$
44
		script.println();
45
		
46
		//TODO add logic to make ant fail if baseLocation isn't set (use condition task)
47
		script.printTargetDeclaration(TARGET_INIT, null, null, null, null);
48
		//TODO only allow builds on config triplets that the feature supports
49
		script.printProperty(PROPERTY_CONFIG, getDefaultConfigInfos());
50
		script.printProperty(PROPERTY_OS, "${osgi.os}"); //$NON-NLS-1$
51
		script.printProperty(PROPERTY_WS, "${osgi.ws}"); //$NON-NLS-1$
52
		script.printProperty(PROPERTY_ARCH, "${osgi.arch}"); //$NON-NLS-1$
53
		script.printProperty(PROPERTY_BUILD_TEMP_FOLDER, getPropertyFormat(PROPERTY_BASEDIR) + "/results"); //$NON-NLS-1$
54
		script.printProperty(PROPERTY_JAVAC_FAIL_ON_ERROR, TRUE);
55
		script.printProperty(PROPERTY_JAVAC_VERBOSE, FALSE);
56
		script.printTargetEnd();
57
		script.println();
58
	
59
		script.printTargetDeclaration(TARGET_MAIN, TARGET_INIT, null, null, null);
60
		script.printAntCallTask(TARGET_GENERATE, null, null);
61
		script.printAntCallTask(TARGET_BUILD, null, null);
62
		script.printAntCallTask(TARGET_ASSEMBLE, null, null);
63
		script.printTargetEnd();
64
		script.println();
65
		
66
		script.printTargetDeclaration(TARGET_GENERATE, null, null, null, null);
67
		script.printBuildScriptTask(type + '@' + id, PREFIX, getPropertyFormat(PROPERTY_CONFIG), getPropertyFormat(PROPERTY_BASE_LOCATION), true); //$NON-NLS-1$
68
		script.printTargetEnd();
69
		script.println();
70
		
71
		script.printTargetDeclaration(TARGET_BUILD, null, null, null, null);
72
		script.printAnt(DEFAULT_BUILD_SCRIPT_FILENAME, PREFIX + '/' + type + "s/" + id, TARGET_BUILD_JARS, null, null); //$NON-NLS-1$
73
		script.printTargetEnd();
74
		script.println();
75
		
76
		script.printTargetDeclaration(TARGET_ASSEMBLE, null, null, null, null);
77
		Map map = new HashMap(1, 1F);
78
		map.put("buildId", buildId); //$NON-NLS-1$
79
		script.printAnt("assemble." + id + ".xml", PREFIX, null, null, map);  //$NON-NLS-1$ //$NON-NLS-2$
80
		script.printTargetEnd();
81
		script.println();
82
		
83
		script.printProjectEnd();
84
		script.close();
85
	}	
86
87
	public void setType(String type) {
88
		this.type = type;
89
	}
90
91
	public void setId(String id) {
92
		this.id = id;
93
	}
94
95
	public void setBuildId(String buildId) {
96
		this.buildId = buildId;
97
	}
98
}
(-)src_ant/org/eclipse/pde/internal/build/tasks/SourceBuildScriptGeneratorTask.java (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 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.SourceBuildScriptGenerator;
17
18
/**
19
 * FIXME fix all comments in this class
20
 * Generate build scripts for the listed elements. This is the implementation of the "eclipse.buildScript" Ant task.
21
 */
22
public class SourceBuildScriptGeneratorTask extends Task {
23
24
	/**
25
	 * The application associated with this Ant task.
26
	 */
27
	protected SourceBuildScriptGenerator generator = new SourceBuildScriptGenerator();
28
29
	public void execute() throws BuildException {
30
		try {
31
			run();
32
		} catch (CoreException e) {
33
			throw new BuildException(e);
34
		}
35
	}
36
37
	public void run() throws CoreException {
38
		generator.generate();
39
	}
40
41
	/**
42
	 * Set the source elements for the script to be the given value.
43
	 * 
44
	 * @param id the source elements for the script
45
	 */
46
	public void setId(String id) {
47
		generator.setId(id);
48
	}
49
50
	/**
51
	 * Set the source elements for the script to be the given value.
52
	 * 
53
	 * @param type the source elements for the script
54
	 */
55
	public void setType(String type) {
56
		generator.setType(type);
57
	}
58
	
59
	/** 
60
	 * Set the folder in which the build will occur.
61
	 * @param buildDirectory the location where the build will occur.
62
	 */
63
	public void setBuildDirectory(String buildDirectory) {
64
		generator.setWorkingDirectory(buildDirectory);
65
	}
66
	
67
	/** 
68
	 * Set the folder in which the build will occur.
69
	 * @param buildId the location where the build will occur.
70
	 */
71
	public void setBuildId(String buildId) {
72
		generator.setBuildId(buildId);
73
	}
74
}

Return to bug 92714