~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
                                // System.err.println("XXXX start inc ");
288
288
                                AsmManager.setLastActiveStructureModel(state.getStructureModel());
289
289
                                binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
290
 
                                Set files = state.getFilesToCompile(true);
 
290
                                Set<File> files = state.getFilesToCompile(true);
291
291
                                if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
292
292
                                        if (AsmManager.attemptIncrementalModelRepairs) {
293
293
                                                state.getStructureModel().resetDeltaProcessing();
462
462
                if (buildConfig.getSourcePathResources() != null) {
463
463
                        for (Iterator i = buildConfig.getSourcePathResources().keySet().iterator(); i.hasNext();) {
464
464
                                String resource = (String) i.next();
465
 
                                File from = (File) buildConfig.getSourcePathResources().get(resource);
 
465
                                File from = buildConfig.getSourcePathResources().get(resource);
466
466
                                copyResourcesFromFile(from, resource, from);
467
467
                        }
468
468
                }
649
649
                String filename = buildConfig.getOutxmlName();
650
650
                // System.err.println("? AjBuildManager.writeOutxmlFile() outxml=" + filename);
651
651
 
652
 
                Map outputDirsAndAspects = findOutputDirsForAspects();
653
 
                Set outputDirs = outputDirsAndAspects.entrySet();
654
 
                for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
655
 
                        Map.Entry entry = (Map.Entry) iterator.next();
656
 
                        File outputDir = (File) entry.getKey();
657
 
                        List aspects = (List) entry.getValue();
 
652
                Map<File, List<String>> outputDirsAndAspects = findOutputDirsForAspects();
 
653
                Set<Map.Entry<File, List<String>>> outputDirs = outputDirsAndAspects.entrySet();
 
654
                for (Iterator<Map.Entry<File, List<String>>> iterator = outputDirs.iterator(); iterator.hasNext();) {
 
655
                        Map.Entry<File, List<String>> entry = iterator.next();
 
656
                        File outputDir = entry.getKey();
 
657
                        List<String> aspects = entry.getValue();
658
658
                        ByteArrayOutputStream baos = getOutxmlContents(aspects);
659
659
                        if (zos != null) {
660
660
                                ZipEntry newEntry = new ZipEntry(filename);
697
697
         * Returns a map where the keys are File objects corresponding to all the output directories and the values are a list of
698
698
         * aspects which are sent to that ouptut directory
699
699
         */
700
 
        private Map /* File --> List (String) */findOutputDirsForAspects() {
701
 
                Map outputDirsToAspects = new HashMap();
702
 
                Map aspectNamesToFileNames = state.getAspectNamesToFileNameMap();
 
700
        private Map<File, List<String>> findOutputDirsForAspects() {
 
701
                Map<File, List<String>> outputDirsToAspects = new HashMap<File, List<String>>();
 
702
                Map<String, char[]> aspectNamesToFileNames = state.getAspectNamesToFileNameMap();
703
703
                if (buildConfig.getCompilationResultDestinationManager() == null
704
704
                                || buildConfig.getCompilationResultDestinationManager().getAllOutputLocations().size() == 1) {
705
705
                        // we only have one output directory...which simplifies things
707
707
                        if (buildConfig.getCompilationResultDestinationManager() != null) {
708
708
                                outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
709
709
                        }
710
 
                        List aspectNames = new ArrayList();
 
710
                        List<String> aspectNames = new ArrayList<String>();
711
711
                        if (aspectNamesToFileNames != null) {
712
 
                                Set keys = aspectNamesToFileNames.keySet();
713
 
                                for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
714
 
                                        String name = (String) iterator.next();
 
712
                                Set<String> keys = aspectNamesToFileNames.keySet();
 
713
                                for (String name : keys) {
715
714
                                        aspectNames.add(name);
716
715
                                }
717
716
                        }
720
719
                        List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations();
721
720
                        for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
722
721
                                File outputDir = (File) iterator.next();
723
 
                                outputDirsToAspects.put(outputDir, new ArrayList());
 
722
                                outputDirsToAspects.put(outputDir, new ArrayList<String>());
724
723
                        }
725
 
                        Set entrySet = aspectNamesToFileNames.entrySet();
726
 
                        for (Iterator iterator = entrySet.iterator(); iterator.hasNext();) {
727
 
                                Map.Entry entry = (Map.Entry) iterator.next();
728
 
                                String aspectName = (String) entry.getKey();
729
 
                                char[] fileName = (char[]) entry.getValue();
730
 
                                File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
731
 
                                                new File(new String(fileName)));
732
 
                                if (!outputDirsToAspects.containsKey(outputDir)) {
733
 
                                        outputDirsToAspects.put(outputDir, new ArrayList());
 
724
                        if (aspectNamesToFileNames != null) {
 
725
                                Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet();
 
726
                                for (Iterator<Map.Entry<String, char[]>> iterator = entrySet.iterator(); iterator.hasNext();) {
 
727
                                        Map.Entry<String, char[]> entry = iterator.next();
 
728
                                        String aspectName = entry.getKey();
 
729
                                        char[] fileName = entry.getValue();
 
730
                                        File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
 
731
                                                        new File(new String(fileName)));
 
732
                                        if (!outputDirsToAspects.containsKey(outputDir)) {
 
733
                                                outputDirsToAspects.put(outputDir, new ArrayList<String>());
 
734
                                        }
 
735
                                        ((List) outputDirsToAspects.get(outputDir)).add(aspectName);
734
736
                                }
735
 
                                ((List) outputDirsToAspects.get(outputDir)).add(aspectName);
736
737
                        }
737
738
                }
738
739
                return outputDirsToAspects;
786
787
                }
787
788
                model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList()));
788
789
 
789
 
                model.setFileMap(new HashMap());
 
790
                model.setFileMap(new HashMap<String, IProgramElement>());
790
791
                // setStructureModel(model);
791
792
                state.setStructureModel(structureModel);
792
793
                // state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap());
793
794
        }
794
795
 
795
 
        //    
 
796
        //
796
797
        // private void dumplist(List l) {
797
798
        // System.err.println("---- "+l.size());
798
799
        // for (int i =0 ;i<l.size();i++) System.err.println(i+"\t "+l.get(i));
873
874
                        outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
874
875
                }
875
876
                // ??? incremental issues
876
 
                for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext();) {
877
 
                        File inJar = (File) i.next();
878
 
                        List unwovenClasses = bcelWeaver.addJarFile(inJar, outputDir, false);
 
877
                for (File inJar : buildConfig.getInJars()) {
 
878
                        List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inJar, outputDir, false);
879
879
                        state.recordBinarySource(inJar.getPath(), unwovenClasses);
880
880
                }
881
881
 
882
 
                for (Iterator i = buildConfig.getInpath().iterator(); i.hasNext();) {
883
 
                        File inPathElement = (File) i.next();
 
882
                for (File inPathElement : buildConfig.getInpath()) {
884
883
                        if (!inPathElement.isDirectory()) {
885
884
                                // its a jar file on the inpath
886
885
                                // the weaver method can actually handle dirs, but we don't call it, see next block
887
 
                                List unwovenClasses = bcelWeaver.addJarFile(inPathElement, outputDir, true);
 
886
                                List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inPathElement, outputDir, true);
888
887
                                state.recordBinarySource(inPathElement.getPath(), unwovenClasses);
889
888
                        } else {
890
889
                                // add each class file in an in-dir individually, this gives us the best error reporting
893
892
                                File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter);
894
893
                                for (int j = 0; j < binSrcs.length; j++) {
895
894
                                        UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrcs[j], inPathElement, outputDir);
896
 
                                        List ucfl = new ArrayList();
 
895
                                        List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
897
896
                                        ucfl.add(ucf);
898
897
                                        state.recordBinarySource(binSrcs[j].getPath(), ucfl);
899
898
                                }
973
972
                return System.getProperty("user.dir"); //$NON-NLS-1$
974
973
        }
975
974
 
976
 
        public void performCompilation(Collection files) {
 
975
        public void performCompilation(Collection<File> files) {
977
976
                if (progressListener != null) {
978
977
                        compiledCount = 0;
979
978
                        sourceFileCount = files.size();
983
982
                // Translate from strings to File objects
984
983
                String[] filenames = new String[files.size()];
985
984
                int idx = 0;
986
 
                for (Iterator fIterator = files.iterator(); fIterator.hasNext();) {
987
 
                        File f = (File) fIterator.next();
 
985
                for (Iterator<File> fIterator = files.iterator(); fIterator.hasNext();) {
 
986
                        File f = fIterator.next();
988
987
                        filenames[idx++] = f.getPath();
989
988
                }
990
989
 
998
997
                }
999
998
 
1000
999
                if (environment == null || environmentNeedsRebuilding) {
1001
 
                        List cps = buildConfig.getFullClasspath();
 
1000
                        List<String> cps = buildConfig.getFullClasspath();
1002
1001
                        Dump.saveFullClasspath(cps);
1003
1002
                        String[] classpaths = new String[cps.size()];
1004
1003
                        for (int i = 0; i < cps.size(); i++) {
1005
 
                                classpaths[i] = (String) cps.get(i);
 
1004
                                classpaths[i] = cps.get(i);
1006
1005
                        }
1007
1006
                        environment = new StatefulNameEnvironment(getLibraryAccess(classpaths, filenames), state.getClassNameToFileMap(), state);
1008
1007
                        state.setNameEnvironment(environment);
1066
1065
                                // this is either a jar file or a file in a directory
1067
1066
                                boolean hasErrors = unitResult.hasErrors();
1068
1067
                                if (!hasErrors || proceedOnError()) {
1069
 
                                        Collection classFiles = unitResult.compiledTypes.values();
 
1068
                                        Collection<ClassFile> classFiles = unitResult.compiledTypes.values();
1070
1069
                                        boolean shouldAddAspectName = (buildConfig.getOutxmlName() != null);
1071
 
                                        for (Iterator iter = classFiles.iterator(); iter.hasNext();) {
1072
 
                                                ClassFile classFile = (ClassFile) iter.next();
 
1070
                                        for (Iterator<ClassFile> iter = classFiles.iterator(); iter.hasNext();) {
 
1071
                                                ClassFile classFile = iter.next();
1073
1072
                                                String filename = new String(classFile.fileName());
1074
1073
                                                String classname = filename.replace('/', '.');
1075
1074
                                                filename = filename.replace('/', File.separatorChar) + ".class";
1077
1076
                                                try {
1078
1077
                                                        if (buildConfig.getOutputJar() == null) {
1079
1078
                                                                String outfile = writeDirectoryEntry(unitResult, classFile, filename);
 
1079
                                                                getWorld().classWriteEvent(classFile.getCompoundName());
1080
1080
                                                                if (environmentSupportsIncrementalCompilation) {
1081
1081
                                                                        if (!classname.endsWith("$ajcMightHaveAspect")) {
1082
1082
                                                                                ResolvedType type = getBcelWorld().resolve(classname);
1185
1185
        // ClassFile classFile = (ClassFile) classFiles.nextElement();
1186
1186
        // String filename = new String(classFile.fileName());
1187
1187
        // filename = filename.replace('/', File.separatorChar) + ".class";
1188
 
        //                              
 
1188
        //
1189
1189
        // File destinationPath = buildConfig.getOutputDir();
1190
1190
        // if (destinationPath == null) {
1191
1191
        // filename = new File(filename).getName();
1193
1193
        // } else {
1194
1194
        // filename = new File(destinationPath, filename).getPath();
1195
1195
        // }
1196
 
        //                              
 
1196
        //
1197
1197
        // //System.out.println("classfile: " + filename);
1198
1198
        // unwovenClassFiles.add(new UnwovenClassFile(filename, classFile.getBytes()));
1199
1199
        // }
1210
1210
        // state.noteClassesFromFile(null, sourceFileName, Collections.EMPTY_LIST);
1211
1211
        // }
1212
1212
        // }
1213
 
        //    
 
1213
        //
1214
1214
 
1215
1215
        private void setBuildConfig(AjBuildConfig buildConfig) {
1216
1216
                this.buildConfig = buildConfig;