Bug 245952 - Enhance ant build.xml generation
Summary: Enhance ant build.xml generation
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-02 06:19 EDT by Jarkko Lietolahti CLA
Modified: 2019-09-06 16:13 EDT (History)
0 users

See Also:


Attachments
Patch to make build directory present as property and possibility to override properties from a file. (112.28 KB, patch)
2008-09-02 06:19 EDT, Jarkko Lietolahti CLA
no flags Details | Diff
BuildFileCreator.java (53.00 KB, text/x-java)
2008-09-02 06:19 EDT, Jarkko Lietolahti CLA
no flags Details
New java source file with a little bug fixed (52.93 KB, text/x-java)
2008-09-02 06:46 EDT, Jarkko Lietolahti CLA
no flags Details
BuildFileCreator.java (53.25 KB, text/x-java)
2008-09-02 06:53 EDT, Jarkko Lietolahti CLA
no flags Details
eclipse-export-build-xml-patch.txt (111.73 KB, patch)
2008-09-02 07:05 EDT, Jarkko Lietolahti CLA
no flags Details | Diff
BuildFileCreator.java (53.20 KB, text/x-java)
2008-09-02 07:06 EDT, Jarkko Lietolahti CLA
no flags Details
BuildFileCreator.java (53.21 KB, text/x-java)
2008-09-02 07:33 EDT, Jarkko Lietolahti CLA
no flags Details
eclipse-export-build-xml-patch.txt (111.74 KB, patch)
2008-09-02 07:33 EDT, Jarkko Lietolahti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jarkko Lietolahti CLA 2008-09-02 06:19:02 EDT
Created attachment 111458 [details]
Patch to make build directory present as property and possibility to override properties from a file.

There's always being two things which haven't quite worked for me in the Eclipse generated Ant build.xml

1) No possibility to override properties set in the generated build.xml, for this I propose fix #1

2) Not possible to change output/build/bin directory with property because all the bin/build paths are not present as property but rather a direct directory name, for this I propose fix #2


Fix #1
// <property environment="env"/>
Element env = doc.createElement("property"); //$NON-NLS-1$
env.setAttribute("environment", "env"); //$NON-NLS-1$ //$NON-NLS-2$
root.insertBefore(env, root.getFirstChild());

// <propertyfile file="override.properties"/>
Element override = doc.createElement("propertyfile"); //$NON-NLS-1$
env.setAttribute("file", "override.properties"); //$NON-NLS-1$ //$NON-NLS-2$
root.insertBefore(override, root.getFirstChild());


Fix #2
Add a method
	private String convertToProperty(String param) {
		String pathPropertyName = "path." + param; //$NON-NLS-1$
		this.variable2valueMap.put(pathPropertyName, param);
		String classDirProperty = "${" + pathPropertyName + "}";
		return classDirProperty;
	}

Then call this method from places where build/bin path is being applied, like
createBuild:
String classDirProperty = convertToProperty(classDir);
javacElement.setAttribute("destdir", classDirProperty); //$NON-NLS-1$

createClasspaths
createClean
String classDirProperty = convertToProperty(classDir);
deleteElement.setAttribute("dir", classDirProperty); //$NON-NLS-1$
element.appendChild(deleteElement);

createCopyResources
if (!EclipseClasspath.isReference(classDir)) {
String pathPropertyValue = convertToProperty(classDir);
Element copyElement = doc.createElement("copy"); //$NON-NLS-1$
copyElement.setAttribute("todir", pathPropertyValue); //$NON-NLS-1$

createInit
String classDirProperty = convertToProperty(classDir);
pathElement.setAttribute("dir", classDirProperty); //$NON-NLS-1$
element.appendChild(pathElement);

Add the same kind of logic where ever build/bin path is being handled.

Sorry for the patch being in bad format, is there a code format rules used by Eclipse project available somewhere so that I can get cleaner patch?
Comment 1 Jarkko Lietolahti CLA 2008-09-02 06:19:34 EDT
Created attachment 111459 [details]
BuildFileCreator.java
Comment 2 Jarkko Lietolahti CLA 2008-09-02 06:46:13 EDT
Created attachment 111461 [details]
New java source file with a little bug fixed
Comment 3 Jarkko Lietolahti CLA 2008-09-02 06:53:42 EDT
Created attachment 111462 [details]
BuildFileCreator.java

Handle pathelement's elements location attribute differently. 
1) Lookup if variable2map contains a property for a path
2) If it does output that
3) If it doesn't output path (original behaviour)

This fixes the situtation when location is already ${..} property.
Comment 4 Jarkko Lietolahti CLA 2008-09-02 07:05:49 EDT
Created attachment 111463 [details]
eclipse-export-build-xml-patch.txt

Now a more tested version of the patch
Comment 5 Jarkko Lietolahti CLA 2008-09-02 07:06:26 EDT
Created attachment 111464 [details]
BuildFileCreator.java

Now a more tested version.
Comment 6 Jarkko Lietolahti CLA 2008-09-02 07:33:23 EDT
Created attachment 111467 [details]
BuildFileCreator.java

Typo in createProperty()
was 
	env.setAttribute("file", "override.properties");
supposed to be
	override.setAttribute("file", "override.properties");
Comment 7 Jarkko Lietolahti CLA 2008-09-02 07:33:55 EDT
Created attachment 111468 [details]
eclipse-export-build-xml-patch.txt
Comment 8 Eclipse Webmaster CLA 2019-09-06 16:13:48 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.