Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 132288 Details for
Bug 269201
[jar exporter] ant file produced by Export runnable jar contains absolute paths instead of relative to workspace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for ant exporter to use workspace relative paths
patch_269201_20090417.txt (text/plain), 19.02 KB, created by
Ferenc Hechler
on 2009-04-17 15:26:49 EDT
(
hide
)
Description:
patch for ant exporter to use workspace relative paths
Filename:
MIME Type:
Creator:
Ferenc Hechler
Created:
2009-04-17 15:26:49 EDT
Size:
19.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarRsrcUrlAntExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarRsrcUrlAntExporter.java,v >retrieving revision 1.3 >diff -u -r1.3 FatJarRsrcUrlAntExporter.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarRsrcUrlAntExporter.java 18 Feb 2009 17:17:23 -0000 1.3 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarRsrcUrlAntExporter.java 17 Apr 2009 19:18:18 -0000 >@@ -10,6 +10,7 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option > * 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 > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter >+ * 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 > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >@@ -74,7 +75,8 @@ > > protected void buildANTScript(OutputStream outputStream, String projectName, IPath absJarfile, String mainClass, SourceInfo[] sourceInfos) throws IOException { > >- String absJarname= absJarfile.toString(); >+ String destDir= makeWorkspaceRelativePath(absJarfile.toFile().getParent()); >+ String destName= absJarfile.removeFileExtension().toFile().getName(); > > DocumentBuilder docBuilder= null; > DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); >@@ -98,12 +100,41 @@ > project.appendChild(comment); > document.appendChild(project); > >+ // <property name="workspace" location="C:/eclipse/workspace-runnableJar" /> >+ Element property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "workspace"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", getWorkspaceDir()); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destdir" location="c:/xx" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destdir"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", destDir); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destname" value="runnableJarOutput" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destname"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("value", destName); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destjar" location="${destdir}/${destname}.jar" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destjar"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", "${destdir}" + File.separator + "${destname}.jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ project.appendChild(property); >+ > Element target= document.createElement("target"); //$NON-NLS-1$ > target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$ > project.appendChild(target); > >+ // <mkdir dir="${destdir}" /> >+ Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$ >+ mkdir.setAttribute("dir", "${destdir}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ project.appendChild(mkdir); >+ > Element jar= document.createElement("jar"); //$NON-NLS-1$ >- jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s >+ jar.setAttribute("destfile", "${destjar}"); //$NON-NLS-1$ //$NON-NLS-2$s > target.appendChild(jar); > > Element manifest= document.createElement("manifest"); //$NON-NLS-1$ >@@ -147,12 +178,12 @@ > if (sourceInfo.isJar) { > File jarFile= new File(sourceInfo.absPath); > Element fileset= document.createElement("zipfileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", jarFile.getParent()); //$NON-NLS-1$ >+ fileset.setAttribute("dir", makeWorkspaceRelativePath(jarFile.getParent())); //$NON-NLS-1$ > fileset.setAttribute("includes", jarFile.getName()); //$NON-NLS-1$ > jar.appendChild(fileset); > } else { > Element fileset= document.createElement("fileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$ >+ fileset.setAttribute("dir", makeWorkspaceRelativePath(sourceInfo.absPath)); //$NON-NLS-1$ > jar.appendChild(fileset); > } > } >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackFatJarAntExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackFatJarAntExporter.java,v >retrieving revision 1.4 >diff -u -r1.4 UnpackFatJarAntExporter.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackFatJarAntExporter.java 18 Feb 2009 17:17:23 -0000 1.4 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackFatJarAntExporter.java 17 Apr 2009 19:18:19 -0000 >@@ -10,9 +10,11 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar > * 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 > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter >+ * 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 > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >+import java.io.File; > import java.io.FileOutputStream; > import java.io.IOException; > import java.io.OutputStream; >@@ -46,7 +48,9 @@ > > protected void buildANTScript(IPath antScriptLocation, String projectName, IPath absJarfile, String mainClass, SourceInfo[] sourceInfos) throws IOException { > OutputStream outputStream= new FileOutputStream(antScriptLocation.toFile()); >- String absJarname= absJarfile.toString(); >+ >+ String destDir= makeWorkspaceRelativePath(absJarfile.toFile().getParent()); >+ String destName= absJarfile.removeFileExtension().toFile().getName(); > > DocumentBuilder docBuilder= null; > DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); >@@ -70,12 +74,41 @@ > project.appendChild(comment); > document.appendChild(project); > >+ // <property name="workspace" location="C:/eclipse/workspace-runnableJar" /> >+ Element property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "workspace"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", getWorkspaceDir()); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destdir" location="c:/xx" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destdir"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", destDir); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destname" value="runnableJarOutput" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destname"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("value", destName); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destjar" location="${destdir}/${destname}.jar" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destjar"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", "${destdir}" + File.separator + "${destname}.jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ project.appendChild(property); >+ > Element target= document.createElement("target"); //$NON-NLS-1$ > target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$ > project.appendChild(target); > >+ // <mkdir dir="${destdir}" /> >+ Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$ >+ mkdir.setAttribute("dir", "${destdir}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ project.appendChild(mkdir); >+ > Element jar= document.createElement("jar"); //$NON-NLS-1$ >- jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s >+ jar.setAttribute("destfile", "${destjar}"); //$NON-NLS-1$ //$NON-NLS-2$ > jar.setAttribute("filesetmanifest", "mergewithoutmain"); //$NON-NLS-1$ //$NON-NLS-2$ > target.appendChild(jar); > >@@ -96,12 +129,12 @@ > SourceInfo sourceInfo= sourceInfos[i]; > if (sourceInfo.isJar) { > Element zipfileset= document.createElement("zipfileset"); //$NON-NLS-1$ >- zipfileset.setAttribute("src", sourceInfo.absPath); //$NON-NLS-1$ >+ zipfileset.setAttribute("src", makeWorkspaceRelativePath(sourceInfo.absPath)); //$NON-NLS-1$ > zipfileset.setAttribute("excludes", "META-INF/*.SF"); //$NON-NLS-1$ //$NON-NLS-2$ > jar.appendChild(zipfileset); > } else { > Element fileset= document.createElement("fileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$ >+ fileset.setAttribute("dir", makeWorkspaceRelativePath(sourceInfo.absPath)); //$NON-NLS-1$ > jar.appendChild(fileset); > } > } >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackJarAntExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackJarAntExporter.java,v >retrieving revision 1.3 >diff -u -r1.3 UnpackJarAntExporter.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackJarAntExporter.java 18 Feb 2009 17:17:23 -0000 1.3 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/UnpackJarAntExporter.java 17 Apr 2009 19:18:19 -0000 >@@ -10,6 +10,7 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option > * 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 > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262763 [jar exporter] remove Built-By attribute in ANT files from Fat JAR Exporter >+ * 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 > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >@@ -50,9 +51,9 @@ > > protected void buildANTScript(IPath antScriptLocation, String projectName, IPath absJarfile, String mainClass, SourceInfo[] sourceInfos) throws IOException { > OutputStream outputStream = new FileOutputStream(antScriptLocation.toFile()); >- String absJarname= absJarfile.toString(); >- String subfolder= absJarfile.removeFileExtension().lastSegment() + "_lib"; //$NON-NLS-1$ >- String absSubfolder= absJarfile.removeLastSegments(1).append(subfolder).toString(); >+ >+ String destDir= makeWorkspaceRelativePath(absJarfile.toFile().getParent()); >+ String destName= absJarfile.removeFileExtension().lastSegment(); > > DocumentBuilder docBuilder= null; > DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); >@@ -76,12 +77,53 @@ > project.appendChild(comment); > document.appendChild(project); > >+ // <property name="workspace" location="C:/eclipse/workspace-runnableJar" /> >+ Element property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "workspace"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", getWorkspaceDir()); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destdir" location="c:/xx" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destdir"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", destDir); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destname" value="runnableJarOutput" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destname"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("value", destName); //$NON-NLS-1$ >+ project.appendChild(property); >+ >+ // <property name="destjar" location="${destdir}/${destname}.jar" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "destjar"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", "${destdir}" + File.separator + "${destname}.jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ project.appendChild(property); >+ >+ // <property name="subdirname" value="${destname}_lib" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "subdirname"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("value", "${destname}_lib"); //$NON-NLS-1$ //$NON-NLS-2$ >+ project.appendChild(property); >+ >+ // <property name="subdir" location="${destdir}/${subdirname}" /> >+ property= document.createElement("property"); //$NON-NLS-1$ >+ property.setAttribute("name", "subdir"); //$NON-NLS-1$ //$NON-NLS-2$ >+ property.setAttribute("location", "${destdir}" + File.separator + "${subdirname}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ project.appendChild(property); >+ > Element target= document.createElement("target"); //$NON-NLS-1$ > target.setAttribute("name", "create_run_jar"); //$NON-NLS-1$ //$NON-NLS-2$ > project.appendChild(target); > >+ // <mkdir dir="${destdir}" /> >+ Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$ >+ mkdir.setAttribute("dir", "${destdir}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ project.appendChild(mkdir); >+ > Element jar= document.createElement("jar"); //$NON-NLS-1$ >- jar.setAttribute("destfile", absJarname); //$NON-NLS-1$s >+ jar.setAttribute("destfile", "${destjar}"); //$NON-NLS-1$ //$NON-NLS-2$ > target.appendChild(jar); > > Element manifest= document.createElement("manifest"); //$NON-NLS-1$ >@@ -99,7 +141,7 @@ > for (int i= 0; i < sourceInfos.length; i++) { > SourceInfo sourceInfo= sourceInfos[i]; > if (sourceInfo.isJar) { >- classPath.append(" ").append(subfolder).append("/") //$NON-NLS-1$ //$NON-NLS-2$ >+ classPath.append(" ").append("${subdirname}").append("/") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > .append(new File(sourceInfo.absPath).getName()); > } > } >@@ -111,18 +153,17 @@ > SourceInfo sourceInfo= sourceInfos[i]; > if (!sourceInfo.isJar) { > Element fileset= document.createElement("fileset"); //$NON-NLS-1$ >- fileset.setAttribute("dir", sourceInfo.absPath); //$NON-NLS-1$ >+ fileset.setAttribute("dir", makeWorkspaceRelativePath(sourceInfo.absPath)); //$NON-NLS-1$ > jar.appendChild(fileset); > } > } > >- > Element delete= document.createElement("delete"); //$NON-NLS-1$ >- delete.setAttribute("dir", absSubfolder); //$NON-NLS-1$s >+ delete.setAttribute("dir", "${subdir}"); //$NON-NLS-1$ //$NON-NLS-2$s > target.appendChild(delete); > >- Element mkdir= document.createElement("mkdir"); //$NON-NLS-1$ >- mkdir.setAttribute("dir", absSubfolder); //$NON-NLS-1$s >+ mkdir= document.createElement("mkdir"); //$NON-NLS-1$ >+ mkdir.setAttribute("dir", "${subdir}"); //$NON-NLS-1$ //$NON-NLS-2$s > target.appendChild(mkdir); > > // add libraries >@@ -130,8 +171,8 @@ > SourceInfo sourceInfo= sourceInfos[i]; > if (sourceInfo.isJar) { > Element copy= document.createElement("copy"); //$NON-NLS-1$ >- copy.setAttribute("file", sourceInfo.absPath); //$NON-NLS-1$ >- copy.setAttribute("todir", absSubfolder); //$NON-NLS-1$ >+ copy.setAttribute("file", makeWorkspaceRelativePath(sourceInfo.absPath)); //$NON-NLS-1$ >+ copy.setAttribute("todir", "${subdir}"); //$NON-NLS-1$ //$NON-NLS-2$ > target.appendChild(copy); > } > } >Index: ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java,v >retrieving revision 1.6 >diff -u -r1.6 FatJarAntExporter.java >--- ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java 18 Feb 2009 16:35:47 -0000 1.6 >+++ ui/org/eclipse/jdt/internal/ui/jarpackagerfat/FatJarAntExporter.java 17 Apr 2009 19:18:18 -0000 >@@ -11,9 +11,11 @@ > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 220257 [jar application] ANT build file does not create Class-Path Entry in Manifest > * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option > * 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 >+ * 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 > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.jarpackagerfat; > >+import java.io.File; > import java.io.FileNotFoundException; > import java.io.IOException; > import java.util.ArrayList; >@@ -25,6 +27,8 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; > >+import org.eclipse.core.resources.ResourcesPlugin; >+ > import org.eclipse.debug.core.ILaunchConfiguration; > > import org.eclipse.jdt.internal.corext.util.Messages; >@@ -64,6 +68,8 @@ > private IPath fAbsJarfile; > private IPath fAntScriptLocation; > >+ private String fWorkspaceDir; >+ > /** > * Create an instance of the ANT exporter. An ANT exporter can generate an ANT script > * at the given ant script location for the given launch configuration >@@ -75,6 +81,12 @@ > fLaunchConfiguration= launchConfiguration; > fAbsJarfile= jarLocation; > fAntScriptLocation= antScriptLocation; >+ try { >+ fWorkspaceDir= ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalPath(); >+ } catch (Exception e) { >+ JavaPlugin.log(e); >+ fWorkspaceDir= "?"; //$NON-NLS-1$ >+ } > } > > /** >@@ -164,6 +176,24 @@ > return result; > } > >+ protected String getWorkspaceDir() { >+ return fWorkspaceDir; >+ } >+ >+ protected String makeWorkspaceRelativePath(String path) { >+ String variablePath; >+ try { >+ variablePath= new File(path).getCanonicalPath().toString(); >+ if (variablePath.equals(getWorkspaceDir())) >+ return "${workspace}"; //$NON-NLS-1$ >+ if (variablePath.startsWith(getWorkspaceDir() + File.separator)) >+ return "${workspace}" + variablePath.substring(getWorkspaceDir().length()); //$NON-NLS-1$ >+ } catch (IOException e) { >+ JavaPlugin.log(e); >+ } >+ return path; >+ } >+ > /** > * Create an ANT script at the given location. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 269201
:
129325
|
129326
|
132288
|
132476
|
222585
|
223065
|
244414