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 269201 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java (-1 / +173 lines)
Lines 11-22 Link Here
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 220257 [jar application] ANT build file does not create Class-Path Entry in Manifest
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 220257 [jar application] ANT build file does not create Class-Path Entry in Manifest
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
14
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 269201 [jar exporter] ant file produced by Export runnable jar contains absolut paths instead of relative to workspace
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.jdt.internal.ui.jarpackagerfat;
16
package org.eclipse.jdt.internal.ui.jarpackagerfat;
16
17
18
import java.io.File;
17
import java.io.FileNotFoundException;
19
import java.io.FileNotFoundException;
18
import java.io.IOException;
20
import java.io.IOException;
19
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.HashMap;
23
import java.util.Map;
24
25
import org.w3c.dom.Document;
26
import org.w3c.dom.Element;
27
import org.w3c.dom.Node;
20
28
21
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
Lines 25-30 Link Here
25
import org.eclipse.core.runtime.Path;
33
import org.eclipse.core.runtime.Path;
26
import org.eclipse.core.runtime.Status;
34
import org.eclipse.core.runtime.Status;
27
35
36
import org.eclipse.core.resources.ResourcesPlugin;
37
28
import org.eclipse.debug.core.ILaunchConfiguration;
38
import org.eclipse.debug.core.ILaunchConfiguration;
29
39
30
import org.eclipse.jdt.internal.corext.util.Messages;
40
import org.eclipse.jdt.internal.corext.util.Messages;
Lines 47-52 Link Here
47
 */
57
 */
48
public abstract class FatJarAntExporter {
58
public abstract class FatJarAntExporter {
49
59
60
	private static final String ANT_PROPERTYNAME_DIR_BUILDFILE= "dir.buildfile"; //$NON-NLS-1$
61
	private static final String ANT_PROPERTYNAME_DIR_WORKSPACE= "dir.workspace"; //$NON-NLS-1$
62
	private static final String ANT_PROPERTYNAME_DIR_JARFILE= "dir.jarfile"; //$NON-NLS-1$
63
	
64
	private static final String ANT_PROPERTY_DIR_BUILDFILE= "${"+ANT_PROPERTYNAME_DIR_BUILDFILE+"}"; //$NON-NLS-1$ //$NON-NLS-2$
65
	private static final String ANT_PROPERTY_DIR_WORKSPACE= "${"+ANT_PROPERTYNAME_DIR_WORKSPACE+"}"; //$NON-NLS-1$ //$NON-NLS-2$
66
	private static final String ANT_PROPERTY_DIR_JARFILE= "${"+ANT_PROPERTYNAME_DIR_JARFILE+"}"; //$NON-NLS-1$ //$NON-NLS-2$
67
50
	protected static class SourceInfo {
68
	protected static class SourceInfo {
51
69
52
		public final boolean isJar;
70
		public final boolean isJar;
Lines 60-69 Link Here
60
		}
78
		}
61
	}
79
	}
62
80
81
	/**
82
	 * Helper class for path-substitutions.
83
	 * This class manages a set of path substitutions.
84
	 * On apply the longest substitution is chosen.  
85
	 */
86
	private static class PathSubstituter {
87
		private Map<String, String> pathSubstitutions = new HashMap<String, String>();
88
		public PathSubstituter addSubstitution(String basePath, String baseReplacement) {
89
			pathSubstitutions.put(basePath, baseReplacement);
90
			return this;
91
		}
92
		public String substitute(String path) {
93
			int len = 0;
94
			String result = path;
95
			for (String basePath:pathSubstitutions.keySet()) {
96
				if (basePath.length() < len) {
97
					continue;
98
				}
99
				if (path.equals(basePath)) {
100
					result = pathSubstitutions.get(basePath);
101
					break;
102
				}
103
				if (path.startsWith(basePath+File.separator)) {
104
					len = basePath.length();
105
					result = pathSubstitutions.get(basePath)+path.substring(len);
106
				}
107
			}
108
			return result;
109
		}
110
	}
111
	
63
	private ILaunchConfiguration fLaunchConfiguration;
112
	private ILaunchConfiguration fLaunchConfiguration;
64
	private IPath fAbsJarfile;
113
	private IPath fAbsJarfile;
65
	private IPath fAntScriptLocation;
114
	private IPath fAntScriptLocation;
66
115
	
116
	private String fBuildfileDir;
117
	private String fWorkspaceDir;
118
	private String fJarfileDir;
119
	
120
	private PathSubstituter pathSubstituter;
121
	
67
	/**
122
	/**
68
	 * Create an instance of the ANT exporter. An ANT exporter can generate an ANT script
123
	 * Create an instance of the ANT exporter. An ANT exporter can generate an ANT script
69
	 * at the given ant script location for the given launch configuration
124
	 * at the given ant script location for the given launch configuration
Lines 75-80 Link Here
75
		fLaunchConfiguration= launchConfiguration;
130
		fLaunchConfiguration= launchConfiguration;
76
		fAbsJarfile= jarLocation;
131
		fAbsJarfile= jarLocation;
77
		fAntScriptLocation= antScriptLocation;
132
		fAntScriptLocation= antScriptLocation;
133
		pathSubstituter = new PathSubstituter();
134
		try {
135
			fBuildfileDir = antScriptLocation.toFile().getParentFile().getCanonicalPath();
136
			pathSubstituter.addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE);
137
		} catch (Exception e) {
138
			JavaPlugin.log(e);
139
			fBuildfileDir= "?"; //$NON-NLS-1$
140
		}
141
		try {
142
			fJarfileDir = jarLocation.toFile().getParentFile().getCanonicalPath();
143
			pathSubstituter.addSubstitution(fJarfileDir, ANT_PROPERTY_DIR_JARFILE);
144
		} catch (Exception e) {
145
			JavaPlugin.log(e);
146
			fJarfileDir= "?"; //$NON-NLS-1$
147
		}
148
		try {
149
			fWorkspaceDir= ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalPath();
150
			pathSubstituter.addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE);
151
		} catch (Exception e) {
152
			JavaPlugin.log(e);
153
			fWorkspaceDir= "?"; //$NON-NLS-1$
154
		}
78
	}
155
	}
79
156
80
	/**
157
	/**
Lines 164-169 Link Here
164
		return result;
241
		return result;
165
	}
242
	}
166
243
244
	
245
	/**
246
	 * add dir properties to ANT-Buildfile.
247
	 * <ul>
248
	 * <li>&lt;property name="dir.buildfile" value="." /&gt;</li>
249
	 * <li>&lt;property name="dir.workspace" value="${dir.buildfile}/../.." /&gt;</li>
250
	 * <li>&lt;property name="dir.jarfile" value="C:/TEMP" /&gt;</li>
251
	 * </ul>
252
	 * 
253
	 * @param document the dom document of the ant buildscript
254
	 * @param project the project tag
255
	 */
256
	protected void addBaseDirProperties(Document document, Element project) {
257
		
258
		Node comment= document.createComment("define folder properties"); //$NON-NLS-1$
259
		project.appendChild(comment);
260
		
261
		Element property= document.createElement("property"); //$NON-NLS-1$
262
		property.setAttribute("name", ANT_PROPERTYNAME_DIR_BUILDFILE); //$NON-NLS-1$ 
263
		property.setAttribute("value", "."); //$NON-NLS-1$ //$NON-NLS-2$ 
264
		project.appendChild(property);
265
266
		property= document.createElement("property"); //$NON-NLS-1$
267
		property.setAttribute("name", ANT_PROPERTYNAME_DIR_WORKSPACE); //$NON-NLS-1$ 
268
		property.setAttribute("value", getWorkspaceRelativeDir()); //$NON-NLS-1$ 
269
		project.appendChild(property);
270
271
		property= document.createElement("property"); //$NON-NLS-1$
272
		property.setAttribute("name", ANT_PROPERTYNAME_DIR_JARFILE); //$NON-NLS-1$ 
273
		property.setAttribute("value", getJarfileRelativeDir()); //$NON-NLS-1$ 
274
		project.appendChild(property);
275
	}
276
277
	
278
	/**
279
	 * Try to make the given filename relative to any of the ant-property-dirs.
280
	 * <ul>
281
	 * <li>buidfile-dir (where the ant script is)</li>
282
	 * <li>workspace-dir (eclipse workspace dir)</li>
283
	 * <li>jarfile-dir (where the jar is written to)</li>
284
	 * </ul>
285
	 * 
286
	 * @param absFilename filename whichs base dir is substituted 
287
	 * @return either the original filename or a relative path from one of the base-dirs
288
	 */
289
	protected String substituteBaseDirs(String absFilename) {
290
		String canonicleFilename;
291
		try {
292
			canonicleFilename= new File(absFilename).getCanonicalPath();
293
		} catch (IOException e) {
294
			e.printStackTrace();
295
			return absFilename;
296
		}
297
		String result = pathSubstituter.substitute(canonicleFilename);
298
		result = result.replace(File.separatorChar, '/');
299
		return result;
300
	}
301
302
	/**
303
	 * @return workspace-dir relative to buildfile-dir if possible
304
	 */
305
	protected String getWorkspaceRelativeDir() {
306
		String result;
307
		if (fBuildfileDir.startsWith(fWorkspaceDir+File.separator)) {
308
			int lastSlash = fWorkspaceDir.length();
309
			result = "${dir.buildfile}"+File.separator+".."; //$NON-NLS-1$ //$NON-NLS-2$
310
			lastSlash = fBuildfileDir.indexOf(File.separator, lastSlash+1);
311
			while (lastSlash != -1) {
312
				result += File.separator+".."; //$NON-NLS-1$
313
				lastSlash = fBuildfileDir.indexOf(File.separator, lastSlash+1);
314
			}
315
		}
316
		else {
317
			result = new PathSubstituter()
318
					.addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE)
319
					.substitute(fWorkspaceDir);
320
		}
321
		result = result.replace(File.separatorChar, '/');
322
		return result;
323
	}
324
325
326
	/**
327
	 * @return jarfile-dir relative to buildfile-dir or workspace-dir if possible
328
	 */
329
	protected String getJarfileRelativeDir() {
330
		String result = new PathSubstituter()
331
				.addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE)
332
				.addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE)
333
				.substitute(fJarfileDir);
334
		result = result.replace(File.separatorChar, '/');
335
		return result;
336
	}
337
338
	
167
	/**
339
	/**
168
	 * Create an ANT script at the given location.
340
	 * Create an ANT script at the given location.
169
	 * 
341
	 * 
(-)ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarRsrcUrlAntExporter.java (-5 / +8 lines)
Lines 11-16 Link Here
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262748 [jar exporter] extract constants for string literals in JarRsrcLoader et al.
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262748 [jar exporter] extract constants for string literals in JarRsrcLoader et al.
14
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 269201 [jar exporter] ant file produced by Export runnable jar contains absolut paths instead of relative to workspace
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.jdt.internal.ui.jarpackagerfat;
16
package org.eclipse.jdt.internal.ui.jarpackagerfat;
16
17
Lines 94-111 Link Here
94
		Element project= document.createElement("project"); //$NON-NLS-1$
95
		Element project= document.createElement("project"); //$NON-NLS-1$
95
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName + " with Jar-in-Jar Loader"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
96
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName + " with Jar-in-Jar Loader"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
96
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
97
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
97
		comment= document.createComment("this file was created by Eclipse Runnable JAR Export Wizard"); //$NON-NLS-1$
98
		comment= document.createComment("this file was created by Eclipse Runnable JAR file Export Wizard"); //$NON-NLS-1$
98
		project.appendChild(comment);
99
		project.appendChild(comment);
99
		comment= document.createComment("ANT 1.7 is required                                        "); //$NON-NLS-1$
100
		comment= document.createComment("ANT 1.7 is required"); //$NON-NLS-1$
100
		project.appendChild(comment);
101
		project.appendChild(comment);
101
		document.appendChild(project);
102
		document.appendChild(project);
102
103
104
		addBaseDirProperties(document, project);
105
103
		Element target= document.createElement("target"); //$NON-NLS-1$
106
		Element target= document.createElement("target"); //$NON-NLS-1$
104
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
107
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
105
		project.appendChild(target);
108
		project.appendChild(target);
106
109
107
		Element jar= document.createElement("jar"); //$NON-NLS-1$
110
		Element jar= document.createElement("jar"); //$NON-NLS-1$
108
		jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s 
111
		jar.setAttribute("destfile", substituteBaseDirs(absJarname)); //$NON-NLS-1$s 
109
		target.appendChild(jar);
112
		target.appendChild(jar);
110
113
111
		Element manifest= document.createElement("manifest"); //$NON-NLS-1$
114
		Element manifest= document.createElement("manifest"); //$NON-NLS-1$
Lines 149-160 Link Here
149
			if (sourceInfo.isJar) {
152
			if (sourceInfo.isJar) {
150
				File jarFile= new File(sourceInfo.absPath);
153
				File jarFile= new File(sourceInfo.absPath);
151
				Element fileset= document.createElement("zipfileset"); //$NON-NLS-1$
154
				Element fileset= document.createElement("zipfileset"); //$NON-NLS-1$
152
				fileset.setAttribute("dir", jarFile.getParent()); //$NON-NLS-1$
155
				fileset.setAttribute("dir", substituteBaseDirs(jarFile.getParent())); //$NON-NLS-1$
153
				fileset.setAttribute("includes", jarFile.getName()); //$NON-NLS-1$ 
156
				fileset.setAttribute("includes", jarFile.getName()); //$NON-NLS-1$ 
154
				jar.appendChild(fileset);
157
				jar.appendChild(fileset);
155
			} else {
158
			} else {
156
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
159
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
157
				fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$
160
				fileset.setAttribute("dir", substituteBaseDirs(sourceInfo.absPath)); //$NON-NLS-1$
158
				jar.appendChild(fileset);
161
				jar.appendChild(fileset);
159
			}
162
			}
160
		}
163
		}
(-)ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackFatJarAntExporter.java (-6 / +10 lines)
Lines 10-15 Link Here
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 269201 [jar exporter] ant file produced by Export runnable jar contains absolut paths instead of relative to workspace
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.internal.ui.jarpackagerfat;
15
package org.eclipse.jdt.internal.ui.jarpackagerfat;
15
16
Lines 55-60 Link Here
55
		try {
56
		try {
56
			docBuilder= factory.newDocumentBuilder();
57
			docBuilder= factory.newDocumentBuilder();
57
		} catch (ParserConfigurationException ex) {
58
		} catch (ParserConfigurationException ex) {
59
			outputStream.close();
58
			throw new IOException(FatJarPackagerMessages.FatJarPackageAntScript_error_couldNotGetXmlBuilder);
60
			throw new IOException(FatJarPackagerMessages.FatJarPackageAntScript_error_couldNotGetXmlBuilder);
59
		}
61
		}
60
		Document document= docBuilder.newDocument();
62
		Document document= docBuilder.newDocument();
Lines 65-82 Link Here
65
		Element project= document.createElement("project"); //$NON-NLS-1$
67
		Element project= document.createElement("project"); //$NON-NLS-1$
66
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName); //$NON-NLS-1$ //$NON-NLS-2$
68
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName); //$NON-NLS-1$ //$NON-NLS-2$
67
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
69
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
68
		comment= document.createComment("this file was created by Eclipse Runnable JAR Export Wizard"); //$NON-NLS-1$
70
		document.appendChild(project);
71
		comment= document.createComment("this file was created by Eclipse Runnable JAR file Export Wizard"); //$NON-NLS-1$
69
		project.appendChild(comment);
72
		project.appendChild(comment);
70
		comment= document.createComment("ANT 1.7 is required                                        "); //$NON-NLS-1$
73
		comment= document.createComment("ANT 1.7 is required"); //$NON-NLS-1$
71
		project.appendChild(comment);
74
		project.appendChild(comment);
72
		document.appendChild(project);
75
76
		addBaseDirProperties(document, project);
73
77
74
		Element target= document.createElement("target"); //$NON-NLS-1$
78
		Element target= document.createElement("target"); //$NON-NLS-1$
75
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
79
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
76
		project.appendChild(target);
80
		project.appendChild(target);
77
81
78
		Element jar= document.createElement("jar"); //$NON-NLS-1$
82
		Element jar= document.createElement("jar"); //$NON-NLS-1$
79
		jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s
83
		jar.setAttribute("destfile", substituteBaseDirs(absJarname)); //$NON-NLS-1$s
80
		jar.setAttribute("filesetmanifest", "mergewithoutmain"); //$NON-NLS-1$ //$NON-NLS-2$
84
		jar.setAttribute("filesetmanifest", "mergewithoutmain"); //$NON-NLS-1$ //$NON-NLS-2$
81
		target.appendChild(jar);
85
		target.appendChild(jar);
82
86
Lines 97-108 Link Here
97
			SourceInfo sourceInfo= sourceInfos[i];
101
			SourceInfo sourceInfo= sourceInfos[i];
98
			if (sourceInfo.isJar) {
102
			if (sourceInfo.isJar) {
99
				Element zipfileset= document.createElement("zipfileset"); //$NON-NLS-1$
103
				Element zipfileset= document.createElement("zipfileset"); //$NON-NLS-1$
100
				zipfileset.setAttribute("src", sourceInfo.absPath); //$NON-NLS-1$
104
				zipfileset.setAttribute("src", substituteBaseDirs(sourceInfo.absPath)); //$NON-NLS-1$
101
				zipfileset.setAttribute("excludes", "META-INF/*.SF"); //$NON-NLS-1$ //$NON-NLS-2$
105
				zipfileset.setAttribute("excludes", "META-INF/*.SF"); //$NON-NLS-1$ //$NON-NLS-2$
102
				jar.appendChild(zipfileset);
106
				jar.appendChild(zipfileset);
103
			} else {
107
			} else {
104
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
108
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
105
				fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$
109
				fileset.setAttribute("dir", substituteBaseDirs(sourceInfo.absPath)); //$NON-NLS-1$
106
				jar.appendChild(fileset);
110
				jar.appendChild(fileset);
107
			}
111
			}
108
		}
112
		}
(-)ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackJarAntExporter.java (-8 / +12 lines)
Lines 10-15 Link Here
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option
10
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
11
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262766 [jar exporter] ANT file for Jar-in-Jar option contains relative path to jar-rsrc-loader.zip
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
12
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter
13
 *     Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 269201 [jar exporter] ant file produced by Export runnable jar contains absolut paths instead of relative to workspace
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.internal.ui.jarpackagerfat;
15
package org.eclipse.jdt.internal.ui.jarpackagerfat;
15
16
Lines 61-66 Link Here
61
		try {
62
		try {
62
			docBuilder= factory.newDocumentBuilder();
63
			docBuilder= factory.newDocumentBuilder();
63
		} catch (ParserConfigurationException ex) {
64
		} catch (ParserConfigurationException ex) {
65
			outputStream.close();
64
			throw new IOException(FatJarPackagerMessages.FatJarPackageAntScript_error_couldNotGetXmlBuilder);
66
			throw new IOException(FatJarPackagerMessages.FatJarPackageAntScript_error_couldNotGetXmlBuilder);
65
		}
67
		}
66
		Document document= docBuilder.newDocument();
68
		Document document= docBuilder.newDocument();
Lines 71-88 Link Here
71
		Element project= document.createElement("project"); //$NON-NLS-1$
73
		Element project= document.createElement("project"); //$NON-NLS-1$
72
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName + " with libraries in sub-folder"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
74
		project.setAttribute("name", "Create Runnable Jar for Project " + projectName + " with libraries in sub-folder"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
73
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
75
		project.setAttribute("default", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
74
		comment= document.createComment("this file was created by Eclipse Runnable JAR Export Wizard"); //$NON-NLS-1$
76
		comment= document.createComment("this file was created by Eclipse Runnable JAR file Export Wizard"); //$NON-NLS-1$
75
		project.appendChild(comment);
77
		project.appendChild(comment);
76
		comment= document.createComment("ANT 1.7 is required                                        "); //$NON-NLS-1$
78
		comment= document.createComment("ANT 1.7 is required"); //$NON-NLS-1$
77
		project.appendChild(comment);
79
		project.appendChild(comment);
78
		document.appendChild(project);
80
		document.appendChild(project);
79
81
82
		addBaseDirProperties(document, project);
83
80
		Element target= document.createElement("target"); //$NON-NLS-1$
84
		Element target= document.createElement("target"); //$NON-NLS-1$
81
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
85
		target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$
82
		project.appendChild(target);
86
		project.appendChild(target);
83
87
84
		Element jar= document.createElement("jar"); //$NON-NLS-1$
88
		Element jar= document.createElement("jar"); //$NON-NLS-1$
85
		jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s 
89
		jar.setAttribute("destfile", substituteBaseDirs(absJarname)); //$NON-NLS-1$s 
86
		target.appendChild(jar);
90
		target.appendChild(jar);
87
91
88
		Element manifest= document.createElement("manifest"); //$NON-NLS-1$
92
		Element manifest= document.createElement("manifest"); //$NON-NLS-1$
Lines 112-129 Link Here
112
			SourceInfo sourceInfo= sourceInfos[i];
116
			SourceInfo sourceInfo= sourceInfos[i];
113
			if (!sourceInfo.isJar) {
117
			if (!sourceInfo.isJar) {
114
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
118
				Element fileset= document.createElement("fileset"); //$NON-NLS-1$
115
				fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$
119
				fileset.setAttribute("dir", substituteBaseDirs(sourceInfo.absPath)); //$NON-NLS-1$
116
				jar.appendChild(fileset);
120
				jar.appendChild(fileset);
117
			}
121
			}
118
		}
122
		}
119
123
120
		
124
		
121
		Element delete= document.createElement("delete"); //$NON-NLS-1$
125
		Element delete= document.createElement("delete"); //$NON-NLS-1$
122
		delete.setAttribute("dir", absSubfolder); //$NON-NLS-1$s 
126
		delete.setAttribute("dir", substituteBaseDirs(absSubfolder)); //$NON-NLS-1$s 
123
		target.appendChild(delete);
127
		target.appendChild(delete);
124
128
125
		Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$
129
		Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$
126
		mkdir.setAttribute("dir", absSubfolder); //$NON-NLS-1$s 
130
		mkdir.setAttribute("dir", substituteBaseDirs(absSubfolder)); //$NON-NLS-1$s 
127
		target.appendChild(mkdir);
131
		target.appendChild(mkdir);
128
132
129
		// add libraries
133
		// add libraries
Lines 131-138 Link Here
131
			SourceInfo sourceInfo= sourceInfos[i];
135
			SourceInfo sourceInfo= sourceInfos[i];
132
			if (sourceInfo.isJar) {
136
			if (sourceInfo.isJar) {
133
				Element copy= document.createElement("copy"); //$NON-NLS-1$
137
				Element copy= document.createElement("copy"); //$NON-NLS-1$
134
				copy.setAttribute("file", sourceInfo.absPath); //$NON-NLS-1$
138
				copy.setAttribute("file", substituteBaseDirs(sourceInfo.absPath)); //$NON-NLS-1$
135
				copy.setAttribute("todir", absSubfolder); //$NON-NLS-1$
139
				copy.setAttribute("todir", substituteBaseDirs(absSubfolder)); //$NON-NLS-1$
136
				target.appendChild(copy);
140
				target.appendChild(copy);
137
			}
141
			}
138
		}
142
		}

Return to bug 269201