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);
649
649
String filename = buildConfig.getOutxmlName();
650
650
// System.err.println("? AjBuildManager.writeOutxmlFile() outxml=" + filename);
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
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();
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);
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>());
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>());
735
((List) outputDirsToAspects.get(outputDir)).add(aspectName);
735
((List) outputDirsToAspects.get(outputDir)).add(aspectName);
738
739
return outputDirsToAspects;
787
788
model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList()));
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());
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();
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);
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);
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>();
898
897
state.recordBinarySource(binSrcs[j].getPath(), ucfl);
973
972
return System.getProperty("user.dir"); //$NON-NLS-1$
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()];
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();
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);
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";
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";
1189
1189
// File destinationPath = buildConfig.getOutputDir();
1190
1190
// if (destinationPath == null) {
1191
1191
// filename = new File(filename).getName();