@@ -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"); |
@@ -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); | |||
} |
@@ -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(); | |||
@@ -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()); |
@@ -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); | |||
} | |||
} |
@@ -83,6 +83,10 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { | |||
this.outputPath = outputPath; | |||
} | |||
public OutputLocationManager getOutputLocationManager() { | |||
return null; | |||
} | |||
public String getAjcWorkingDir() { | |||
return testProjectPath + "/ajworkingdir"; | |||
} |
@@ -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); | |||
} |
@@ -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; | |||
} |
@@ -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(); |
@@ -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"); } |
@@ -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()"); |