]> source.dussan.org Git - aspectj.git/commitdiff
latest HEAD changes
authoraclement <aclement>
Wed, 14 May 2008 17:00:11 +0000 (17:00 +0000)
committeraclement <aclement>
Wed, 14 May 2008 17:00:11 +0000 (17:00 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java

index b63f6bf58c11391e4e0da1f56931c6063159f4b4..b8d925505a1366e89d992673eb3fcffb9e5263d0 100644 (file)
@@ -545,6 +545,15 @@ public class BuildArgParser extends Main {
                        } else if (arg.equals("-crossrefs")) {
                                buildConfig.setGenerateCrossRefsMode(true);
                                buildConfig.setGenerateModelMode(true);
+                       } else if (arg.startsWith("-checkRuntimeVersion:")) {
+                               String lcArg = arg.toLowerCase();
+                               if (lcArg.endsWith(":false")) {
+                                       buildConfig.setCheckRuntimeVersion(false);
+                               } else if (lcArg.endsWith(":true")) {
+                                       buildConfig.setCheckRuntimeVersion(true);
+                               } else {
+                                       showError("bad value for -checkRuntimeVersion option, must be true or false");
+                               }
                        } else if (arg.equals("-emacssym")) {
                                buildConfig.setEmacsSymMode(true);
                                buildConfig.setGenerateModelMode(true);
index 963951deeb9ff10d0fb279255af9ec7c560736b8..dc495fead3396190aa757bdbb9ba640f85adab26 100644 (file)
@@ -355,6 +355,11 @@ public class AjBuildConfig {
         if (!incrementalMode && global.incrementalMode) {
             incrementalMode = true;
         }
+        
+        if (isCheckRuntimeVersion() && !global.isCheckRuntimeVersion()) {
+               setCheckRuntimeVersion(false);
+        }
+        
         join(inJars, global.inJars);
         join(inPath, global.inPath);
         if ((null == lintMode) 
@@ -563,6 +568,14 @@ public class AjBuildConfig {
        public void setGenerateCrossRefsMode(boolean on) {
                options.generateCrossRefs = on;
        }
+
+       public boolean isCheckRuntimeVersion() {
+               return options.checkRuntimeVersion;
+       }
+       
+       public void setCheckRuntimeVersion(boolean on) {
+               options.checkRuntimeVersion = on;
+       }
        
        public boolean isEmacsSymMode() {
                return options.generateEmacsSymFiles;
index 0b936dd8c828b9b9f5f9bc38369f3d89196f3002..13488e22487a8a4f53841bd34e7adc1569abb2d4 100644 (file)
@@ -73,7 +73,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
 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;
@@ -84,6 +84,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
 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;
@@ -156,6 +157,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
        public BcelWorld getBcelWorld() { return state.getBcelWorld();}
        
        public CountingMessageHandler handler;
+       private CustomMungerFactory customMungerFactory;
 
        public AjBuildManager(IMessageHandler holder) {
                super();
@@ -216,18 +218,20 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
             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);
@@ -278,7 +282,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
 //                }
                 // 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());
@@ -459,7 +463,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                                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);
                                }
@@ -492,7 +496,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
        }
        
        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);
@@ -570,7 +574,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                }
        }
 
-       private boolean acceptResource(String resourceName) {
+       private boolean acceptResource(String resourceName,boolean fromFile) {
                if (  
                                (resourceName.startsWith("CVS/")) ||
                                (resourceName.indexOf("/CVS/") != -1) ||
@@ -579,7 +583,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                                (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;
@@ -749,6 +754,16 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
 //     }
 //    }
     
+    //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 = 
@@ -767,6 +782,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                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();
@@ -886,9 +902,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                // 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() {
@@ -930,7 +946,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
        }
     
     
-       public void performCompilation(List files) {
+       public void performCompilation(Collection files) {
                if (progressListener != null) {
                        compiledCount=0;
                        sourceFileCount = files.size();
@@ -940,9 +956,11 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                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);
@@ -1173,8 +1191,10 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
                        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() );
index 469d7ea78dd94b6bf846a7be34cf8383a6842655..9ca9e7ea142368a8741c392e424420a17471fbe9 100644 (file)
@@ -94,6 +94,9 @@ public class AjCompilerOptions extends CompilerOptions {
         */
        public boolean generateCrossRefs = false;
        
+       // Check aspectjrt*.jar exists and within it the version number is right (see AjBuildManager.checkRtJar())
+       public boolean checkRuntimeVersion = true;
+       
        public boolean proceedOnError = false;