aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java4
-rw-r--r--ajde/src/org/aspectj/ajde/OutputLocationManager.java47
-rw-r--r--ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java6
-rw-r--r--ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java6
-rw-r--r--ajde/src/org/aspectj/ajde/internal/OutputLocationAdapter.java35
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/CompilationResultDestinationManager.java46
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java10
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java10
-rw-r--r--testing/src/org/aspectj/testing/ajde/CompileCommand.java5
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java5
11 files changed, 176 insertions, 2 deletions
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
index 75c8169c2..286bac0d5 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
@@ -113,6 +113,10 @@ public class BrowserProperties implements ProjectPropertiesAdapter {
public void setOutputPath(String path) {
preferencesAdapter.setProjectPreference("build.outputpath", path);
}
+
+ public OutputLocationManager getOutputLocationManager() {
+ return null;
+ }
public String getUserClasspath() {
return preferencesAdapter.getProjectPreference("build.classpath");
diff --git a/ajde/src/org/aspectj/ajde/OutputLocationManager.java b/ajde/src/org/aspectj/ajde/OutputLocationManager.java
new file mode 100644
index 000000000..9a8c46d5f
--- /dev/null
+++ b/ajde/src/org/aspectj/ajde/OutputLocationManager.java
@@ -0,0 +1,47 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.ajde;
+
+import java.io.File;
+
+/**
+ * Interface to be implemented by clients that wish to control the output
+ * folder used to write the results of compiling individual source files.
+ * @author adrian colyer
+ *
+ */
+public interface OutputLocationManager {
+
+ /**
+ * Return the directory root under which the results of compiling the given
+ * source file. For example, if the source file contains the type a.b.C, and
+ * this method returns "target/classes" the resulting class file will be written
+ * to "target/classes/a/b/C.class"
+ *
+ * @param compilationUnitName the fully-qualified name of the compilation unit that has been
+ * compiled
+ * @return a File object representing the root directory under which compilation results for this
+ * unit should be written
+ */
+ File getOutputLocationForClass(String compilationUnitName);
+
+ /**
+ * When copying resources from source folders to output location, return the
+ * root directory under which the resource should be copied.
+ *
+ * @param resourceName the fully-qualified name of the resource to be copied
+ * @return a File object representing the root directory under which this resource
+ * should be copied
+ */
+ File getOutputLocationForResource(String resourceName);
+
+}
diff --git a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
index 19d08e4a3..b48c062bc 100644
--- a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
+++ b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
@@ -44,6 +44,12 @@ public interface ProjectPropertiesAdapter {
public String getClasspath();
public String getOutputPath();
+
+ /**
+ * A non-null OutputLocationManager takes precedence over getOutputPath...
+ * @return
+ */
+ public OutputLocationManager getOutputLocationManager();
// public String getAjcWorkingDir();
diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
index 47f1e32c9..9afe186a7 100644
--- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
+++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
@@ -576,6 +576,12 @@ public class CompilerAdapter {
config.setOutputJar(new File( outJar ) );
}
}
+
+ // set compilation result destination manager if not set
+ if (config.getCompilationResultDestinationManager() == null &&
+ properties.getOutputLocationManager() != null) {
+ config.setCompilationResultDestinationManager(new OutputLocationAdapter(properties.getOutputLocationManager()));
+ }
join(config.getSourceRoots(), properties.getSourceRoots());
join(config.getInJars(), properties.getInJars());
diff --git a/ajde/src/org/aspectj/ajde/internal/OutputLocationAdapter.java b/ajde/src/org/aspectj/ajde/internal/OutputLocationAdapter.java
new file mode 100644
index 000000000..81c54b457
--- /dev/null
+++ b/ajde/src/org/aspectj/ajde/internal/OutputLocationAdapter.java
@@ -0,0 +1,35 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.ajde.internal;
+
+import java.io.File;
+
+import org.aspectj.ajde.OutputLocationManager;
+import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
+
+public class OutputLocationAdapter implements CompilationResultDestinationManager {
+
+ private OutputLocationManager locationManager;
+
+ public OutputLocationAdapter(OutputLocationManager mgr) {
+ this.locationManager = mgr;
+ }
+
+ public File getOutputLocationForClass(String compilationUnitName) {
+ return this.locationManager.getOutputLocationForClass(compilationUnitName);
+ }
+
+ public File getOutputLocationForResource(String resourceName) {
+ return this.locationManager.getOutputLocationForResource(resourceName);
+ }
+
+}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
index 233933a7a..e65f9ab26 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
@@ -83,6 +83,10 @@ public class NullIdeProperties implements ProjectPropertiesAdapter {
this.outputPath = outputPath;
}
+ public OutputLocationManager getOutputLocationManager() {
+ return null;
+ }
+
public String getAjcWorkingDir() {
return testProjectPath + "/ajworkingdir";
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/CompilationResultDestinationManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/CompilationResultDestinationManager.java
new file mode 100644
index 000000000..9c544594f
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/CompilationResultDestinationManager.java
@@ -0,0 +1,46 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.ajdt.internal.compiler;
+
+import java.io.File;
+
+/**
+ * acts as a bridge from ajde's OutputLocationManager interface to the compiler internals
+ * @author adrian
+ *
+ */
+public interface CompilationResultDestinationManager {
+
+ /**
+ * Return the directory root under which the results of compiling the given
+ * source file. For example, if the source file contains the type a.b.C, and
+ * this method returns "target/classes" the resulting class file will be written
+ * to "target/classes/a/b/C.class"
+ *
+ * @param compilationUnitName the fully-qualified name of the compilation unit that has been
+ * compiled
+ * @return a File object representing the root directory under which compilation results for this
+ * unit should be written
+ */
+ File getOutputLocationForClass(String compilationUnitName);
+
+ /**
+ * When copying resources from source folders to output location, return the
+ * root directory under which the resource should be copied.
+ *
+ * @param resourceName the fully-qualified name of the resource to be copied
+ * @return a File object representing the root directory under which this resource
+ * should be copied
+ */
+ File getOutputLocationForResource(String resourceName);
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
index 472180fd6..9e5f37b90 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
import org.aspectj.util.FileUtil;
/**
@@ -43,6 +44,7 @@ public class AjBuildConfig {
private File outputDir;
private File outputJar;
private String outxmlName;
+ private CompilationResultDestinationManager compilationResultDestinationManager = null;
private List/*File*/ sourceRoots = new ArrayList();
private List/*File*/ files = new ArrayList();
private List /*File*/ binaryFiles = new ArrayList(); // .class files in indirs...
@@ -131,7 +133,15 @@ public class AjBuildConfig {
public File getOutputDir() {
return outputDir;
}
+
+ public CompilationResultDestinationManager getCompilationResultDestinationManager() {
+ return this.compilationResultDestinationManager;
+ }
+ public void setCompilationResultDestinationManager(CompilationResultDestinationManager mgr) {
+ this.compilationResultDestinationManager = mgr;
+ }
+
public void setFiles(List files) {
this.files = files;
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index 7e6678278..a6fbe2970 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -501,8 +501,12 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
zos.write(content);
zos.closeEntry();
} else {
+ File destDir = buildConfig.getOutputDir();
+ if (buildConfig.getCompilationResultDestinationManager() != null) {
+ destDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForResource(srcLocation.getAbsolutePath());
+ }
OutputStream fos =
- FileUtil.makeOutputStream(new File(buildConfig.getOutputDir(),filename));
+ FileUtil.makeOutputStream(new File(destDir,filename));
fos.write(content);
fos.close();
}
@@ -940,6 +944,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
String filename)
throws IOException {
File destinationPath = buildConfig.getOutputDir();
+ if (buildConfig.getCompilationResultDestinationManager() != null) {
+ destinationPath =
+ buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(new String(unitResult.fileName));
+ }
String outFile;
if (destinationPath == null) {
outFile = new File(filename).getName();
diff --git a/testing/src/org/aspectj/testing/ajde/CompileCommand.java b/testing/src/org/aspectj/testing/ajde/CompileCommand.java
index fd69ab9de..898d88f3b 100644
--- a/testing/src/org/aspectj/testing/ajde/CompileCommand.java
+++ b/testing/src/org/aspectj/testing/ajde/CompileCommand.java
@@ -23,7 +23,6 @@ import org.aspectj.ajde.ui.*;
import org.aspectj.ajde.ui.internal.*;
import org.aspectj.ajde.ui.swing.*;
import org.aspectj.asm.*;
-import org.aspectj.asm.IProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.util.FileUtil;
@@ -376,6 +375,10 @@ class ProjectProperties implements ProjectPropertiesAdapter {
public void setOutJar(String input){ outJar = input; }
public String getOutJar() { return outJar; }
public String getOutputPath() { return outputDir; }
+
+ public OutputLocationManager getOutputLocationManager() {
+ return null;
+ }
// not known if used - log any calls to it
public List getBuildConfigFiles() { return logs("buildConfigFiles"); }
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
index 38be2dd60..582d8ecc8 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
@@ -27,6 +27,7 @@ import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.BuildOptionsAdapter;
import org.aspectj.ajde.BuildProgressMonitor;
import org.aspectj.ajde.ErrorHandler;
+import org.aspectj.ajde.OutputLocationManager;
import org.aspectj.ajde.ProjectPropertiesAdapter;
import org.aspectj.ajde.TaskListManager;
import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
@@ -480,6 +481,10 @@ public class AjdeInteractionTestbed extends TestCase {
log("MyProjectProperties.getOutputPath() [returning "+dir+"]");
return dir;
}
+
+ public OutputLocationManager getOutputLocationManager() {
+ return null;
+ }
public String getBootClasspath() {
log("MyProjectProperties.getBootClasspath()");