import org.aspectj.org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.aspectj.org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathDirectory;
+import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathLocation;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.aspectj.tools.ajc.Main;
import org.aspectj.util.FileUtil;
+import org.aspectj.weaver.CustomMungerFactory;
import org.aspectj.weaver.Dump;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.World;
public BcelWorld getBcelWorld() { return state.getBcelWorld();}
public CountingMessageHandler handler;
+ private CustomMungerFactory customMungerFactory;
public AjBuildManager(IMessageHandler holder) {
super();
this.handler =
CountingMessageHandler.makeCountingMessageHandler(baseHandler);
- if (DO_RUNTIME_VERSION_CHECK) {
- String check = checkRtJar(buildConfig);
- if (check != null) {
- if (FAIL_IF_RUNTIME_NOT_FOUND) {
- MessageUtil.error(handler, check);
- CompilationAndWeavingContext.leavingPhase(ct);
- return false;
- } else {
- MessageUtil.warn(handler, check);
- }
- }
- }
+ if (buildConfig==null || buildConfig.isCheckRuntimeVersion()) {
+ if (DO_RUNTIME_VERSION_CHECK) {
+ String check = checkRtJar(buildConfig);
+ if (check != null) {
+ if (FAIL_IF_RUNTIME_NOT_FOUND) {
+ MessageUtil.error(handler, check);
+ CompilationAndWeavingContext.leavingPhase(ct);
+ return false;
+ } else {
+ MessageUtil.warn(handler, check);
+ }
+ }
+ }
+ }
// if (batch) {
setBuildConfig(buildConfig);
// }
// System.err.println("XXXX start inc ");
binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
- List files = state.getFilesToCompile(true);
+ Set files = state.getFilesToCompile(true);
if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode())
if (AsmManager.attemptIncrementalModelRepairs)
AsmManager.getDefault().processDelta(files,state.getAddedFiles(),state.getDeletedFiles());
String filename = entry.getName();
// System.out.println("? copyResourcesFromJarFile() filename='" + filename +"'");
- if (!entry.isDirectory() && acceptResource(filename)) {
+ if (!entry.isDirectory() && acceptResource(filename,false)) {
byte[] bytes = FileUtil.readAsByteArray(inStream);
writeResource(filename,bytes,jarFile);
}
}
private void copyResourcesFromFile(File f,String filename,File src) throws IOException {
- if (!acceptResource(filename)) return;
+ if (!acceptResource(filename,true)) return;
FileInputStream fis = null;
try {
fis = new FileInputStream(f);
}
}
- private boolean acceptResource(String resourceName) {
+ private boolean acceptResource(String resourceName,boolean fromFile) {
if (
(resourceName.startsWith("CVS/")) ||
(resourceName.indexOf("/CVS/") != -1) ||
(resourceName.startsWith(".svn/")) ||
(resourceName.indexOf("/.svn/")!=-1) ||
(resourceName.endsWith("/.svn")) ||
- (resourceName.toUpperCase().equals(MANIFEST_NAME))
+ // Do not copy manifests if either they are coming from a jar or we are writing to a jar
+ (resourceName.toUpperCase().equals(MANIFEST_NAME) && (!fromFile || zos!=null))
)
{
return false;
// }
// }
+ //LTODO delegate to BcelWeaver?
+ // XXX hideous, should not be Object
+ public void setCustomMungerFactory(Object o) {
+ customMungerFactory = (CustomMungerFactory)o;
+ }
+
+ public Object getCustomMungerFactory() {
+ return customMungerFactory;
+ }
+
/** init only on initial batch compile? no file-specific options */
private void initBcelWorld(IMessageHandler handler) throws IOException {
List cp =
bcelWorld.setPinpointMode(buildConfig.isXdevPinpoint());
bcelWorld.setErrorAndWarningThreshold(buildConfig.getOptions().errorThreshold,buildConfig.getOptions().warningThreshold);
BcelWeaver bcelWeaver = new BcelWeaver(bcelWorld);
+ bcelWeaver.setCustomMungerFactory(customMungerFactory);
state.setWorld(bcelWorld);
state.setWeaver(bcelWeaver);
state.clearBinarySourceFiles();
// element of the classpath is likely to be a directory. If we ensure every element of the array is set to
// only look for BINARY, then we make sure that for any classpath element that is a directory, we won't build
// a classpathDirectory object that will attempt to look for source when it can't find binary.
- int[] classpathModes = new int[classpaths.length];
- for (int i =0 ;i<classpaths.length;i++) classpathModes[i]=ClasspathDirectory.BINARY;
- return new FileSystem(classpaths, filenames, defaultEncoding,classpathModes);
+// int[] classpathModes = new int[classpaths.length];
+// for (int i =0 ;i<classpaths.length;i++) classpathModes[i]=ClasspathDirectory.BINARY;
+ return new FileSystem(classpaths, filenames, defaultEncoding,ClasspathLocation.BINARY);
}
public IProblemFactory getProblemFactory() {
}
- public void performCompilation(List files) {
+ public void performCompilation(Collection files) {
if (progressListener != null) {
compiledCount=0;
sourceFileCount = files.size();
String[] filenames = new String[files.size()];
String[] encodings = new String[files.size()];
//System.err.println("filename: " + this.filenames);
- for (int i=0; i < files.size(); i++) {
- filenames[i] = ((File)files.get(i)).getPath();
- }
+ int ii = 0;
+ for (Iterator fIterator = files.iterator(); fIterator.hasNext();) {
+ File f = (File) fIterator.next();
+ filenames[ii++] = f.getPath();
+ }
List cps = buildConfig.getFullClasspath();
Dump.saveFullClasspath(cps);
return null;
}
+
if (buildConfig == null || buildConfig.getFullClasspath() == null) return "no classpath specified";
+
String ret = null;
for (Iterator it = buildConfig.getFullClasspath().iterator(); it.hasNext(); ) {
File p = new File( (String)it.next() );