diff options
author | mwebster <mwebster> | 2006-06-15 12:58:38 +0000 |
---|---|---|
committer | mwebster <mwebster> | 2006-06-15 12:58:38 +0000 |
commit | 81abede5115df2b032b846c5ff8bf23050f68e34 (patch) | |
tree | fc8b9972315fc1dce4eecf8d630183eb95433e77 /org.aspectj.ajdt.core/testsrc | |
parent | f4cd0bfb01911ae5f8aaf4a114fac0b921806f50 (diff) | |
download | aspectj-81abede5115df2b032b846c5ff8bf23050f68e34.tar.gz aspectj-81abede5115df2b032b846c5ff8bf23050f68e34.zip |
Fix build: move createEmptySandbox() from FileUtil back to Ajc to avoid JUnit dependency problem in util project
Diffstat (limited to 'org.aspectj.ajdt.core/testsrc')
-rw-r--r-- | org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java index aa2e70861..6114bef57 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; +import junit.framework.AssertionFailedError; + import org.aspectj.bridge.AbortException; import org.aspectj.bridge.ICommand; @@ -44,6 +46,8 @@ import org.aspectj.util.FileUtil; */ public class Ajc { + private static final String SANDBOX_NAME = "ajcSandbox"; + private static final String TESTER_PATH = ".."+File.separator+"testing-client"+File.separator+"bin" + File.pathSeparator+".."+File.separator+"runtime" +File.separator+"bin" @@ -180,7 +184,7 @@ public class Ajc { try { if (!isIncremental && shouldEmptySandbox) { - sandbox = FileUtil.createEmptySandbox(); + sandbox = createEmptySandbox(); } args = adjustToSandbox(args,!isIncremental); MessageHandler holder = new MessageHandler(); @@ -253,7 +257,7 @@ public class Ajc { * Get the sandbox directory used for the compilation. */ public File getSandboxDirectory() { - if (sandbox == null) {sandbox = FileUtil.createEmptySandbox();} + if (sandbox == null) {sandbox = createEmptySandbox();} return sandbox; } @@ -278,7 +282,50 @@ public class Ajc { } return false; } + + public static File createEmptySandbox() { + File sandbox; + + String os = System.getProperty("os.name"); + File tempDir = null; + // AMC - I did this rather than use the JDK default as I hate having to go look + // in c:\documents and settings\......... for the results of a failed test. + if (os.startsWith("Windows")) { + tempDir = new File("C:\\temp"); + if (!tempDir.exists()) {tempDir.mkdir();} + } else { + tempDir = new File("/tmp"); + } + File sandboxRoot = new File(tempDir,SANDBOX_NAME); + if (!sandboxRoot.exists()) { + sandboxRoot.mkdir(); + } + + + try { + File workspace = new File(".." + File.separator); + String workspaceName = workspace.getCanonicalPath(); + int index = workspaceName.lastIndexOf(File.separator); + workspaceName = workspaceName.substring(index+1); + File workspaceRoot = new File(sandboxRoot,workspaceName); + if (!workspaceRoot.exists()) { + workspaceRoot.mkdir(); + } + + FileUtil.deleteContents(workspaceRoot); + + sandbox = File.createTempFile("ajcTest",".tmp",workspaceRoot); + sandbox.delete(); + sandbox.mkdir(); + + } catch (IOException ioEx) { + throw new AssertionFailedError("Unable to create sandbox directory for test"); + } + + return sandbox; + } + /** * Make every relative file name and dir be absolute under sandbox * Add TESTER_PATH to classpath |