blob: d48fab5234f3d81099afc79aa2413c73b655a504 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/********************************************************************
* Copyright (c) 2007 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v 2.0
* which accompanies this distribution and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version (bug 148190)
*******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.aspectj.ajde.core.IOutputLocationManager;
/**
* An IOutputLocationManager which by default sends all output to the testProjectPath\bin directory. However, there are getter
* methods which enable sending resources and classes to different output dirs. Doesn't enable sending different classes to
* different output locations.
*/
public class MultiProjTestOutputLocationManager implements IOutputLocationManager {
private final String testProjectOutputPath;
private File classOutputLoc;
private File resourceOutputLoc;
private final Map sourceFolders = new HashMap();
private List<File> allOutputLocations;
public MultiProjTestOutputLocationManager(String testProjectPath) {
this.testProjectOutputPath = testProjectPath + File.separator + "bin";
}
public File getOutputLocationForClass(File compilationUnit) {
initLocations();
return classOutputLoc;
}
public Map getInpathMap() {
return Collections.EMPTY_MAP;
}
public File getOutputLocationForResource(File resource) {
initLocations();
return resourceOutputLoc;
}
public List<File> getAllOutputLocations() {
if (allOutputLocations == null) {
allOutputLocations = new ArrayList<>();
initLocations();
allOutputLocations.add(classOutputLoc);
if (!classOutputLoc.equals(resourceOutputLoc)) {
allOutputLocations.add(resourceOutputLoc);
}
}
return allOutputLocations;
}
public File getDefaultOutputLocation() {
return classOutputLoc;
}
private void initLocations() {
if (classOutputLoc == null) {
classOutputLoc = new File(testProjectOutputPath);
}
if (resourceOutputLoc == null) {
resourceOutputLoc = new File(testProjectOutputPath);
}
}
// -------------- setter methods useful for testing -------------
public void setOutputLocForClass(File f) {
classOutputLoc = f;
}
public void setSourceFolderFor(File sourceFile, String sourceFolder) {
try {
sourceFolders.put(sourceFile.getCanonicalPath(), sourceFolder);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void setOutputLocForResource(File f) {
resourceOutputLoc = f;
}
public String getSourceFolderForFile(File sourceFile) {
try {
String f = (String) sourceFolders.get(sourceFile.getCanonicalPath());
return f;
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void reportFileWrite(String outputfile, int filetype) {
// System.err.println(">>>" + outputfile);
}
public void reportFileRemove(String outputfile, int filetype) {
}
public int discoverChangesSince(File dir, long buildtime) {
// TODO Auto-generated method stub
return 0;
}
}
|