diff options
author | wisberg <wisberg> | 2003-05-14 05:23:47 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2003-05-14 05:23:47 +0000 |
commit | 93fdea6a045967c3ff08c6408a6dc7fca87c46d1 (patch) | |
tree | 6a5664fc870c7b1bc8473a9b87b7e7ea66726bf4 /build | |
parent | bef3169a67e33bf3925f8741be1aefe9448f4bab (diff) | |
download | aspectj-93fdea6a045967c3ff08c6408a6dc7fca87c46d1.tar.gz aspectj-93fdea6a045967c3ff08c6408a6dc7fca87c46d1.zip |
absolutizing temp dir path.
When File.getTempFile() fails, workaround temp dir
is relative, which messes up the zip resource copying.
Diffstat (limited to 'build')
-rw-r--r-- | build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java index bdeb456c6..518f8efc4 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java @@ -44,7 +44,7 @@ public class AJInstaller extends MatchingTask { static final String MAIN_CLASS = "$installer$.org.aspectj.Main"; static final String CONTENTS_FILE = "$installer$/org/aspectj/resources/contents.txt"; private String htmlSrc; - + public void setHtmlSrc(String v) { htmlSrc = v; } private String resourcesSrc; @@ -91,10 +91,8 @@ public class AJInstaller extends MatchingTask { protected void finishZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException { writeContents(zOut); writeManifest(zOut); - File tmpDirF = File.createTempFile("tgz", ".di"); - File tmpDir = new File(tmpDirF.getAbsolutePath() + "r"); - tmpDirF.delete(); - String tmp = tmpDir.getAbsolutePath(); + File tempDir = setupTempDir(); + String tmp = tempDir.getAbsolutePath(); // installer class files Expand expand = new Expand(); @@ -134,15 +132,16 @@ public class AJInstaller extends MatchingTask { cd.execute(); // now move these files into the jar setBasedir(tmp); - writeFiles(zOut, getFiles(tmpDir)); + writeFiles(zOut, getFiles(tempDir)); // and delete the tmp dir Delete dt = (Delete)project.createTask("delete"); if (null == dt) { dt = new Delete(); dt.setProject(getProject()); } - dt.setDir(new File(tmp)); + dt.setDir(tempDir); dt.execute(); + tempDir = null; } static final char NEWLINE = '\n'; @@ -277,7 +276,25 @@ public class AJInstaller extends MatchingTask { fIn.close(); } } - + private File setupTempDir() throws BuildException { + File tmpDirF = null; + File tmpDir = null; + try { + tmpDirF = File.createTempFile("tgz", ".di"); + tmpDir = new File(tmpDirF.getParentFile(), "AJInstaller"); + tmpDirF.delete(); + } catch (IOException e) { + // retrying below + } + if (null == tmpDir || !tmpDir.mkdirs()) { + tmpDir = new File("AJInstaller.finishZipOutputStream.tmp"); + if (!tmpDir.mkdirs()) { + throw new BuildException("unable to make temp dir"); + } + } + return tmpDir; + } + public void execute() throws BuildException { if (installerClassJar == null) { throw new BuildException("installerClassJar attribute must be set!"); @@ -313,7 +330,7 @@ public class AJInstaller extends MatchingTask { initZipOutputStream(zOut); writeDirs(zOut, dirs); writeFiles(zOut, files); - finishZipOutputStream(zOut); + finishZipOutputStream(zOut); // deletes temp dir } catch (IOException ioe) { String msg = "Problem creating " + archiveType + " " + ioe.getMessage(); throw new BuildException(msg, ioe, location); |