blob: 52d1540c43905c587129b229b66676ed1802d149 (
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
|
/********************************************************************
* Copyright (c) 2006 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.util.Collection;
import java.util.Hashtable;
import java.util.Map;
import org.aspectj.ajde.core.AjCompiler;
/**
* Manages the different compilers for the different projects within one test run
*/
public class CompilerFactory {
private static Map<String,AjCompiler> compilerMap = new Hashtable<>();
/**
* If an AjCompiler exists for the given projectDir then returns
* that, otherwise creates a new one.
*/
public static AjCompiler getCompilerForProjectWithDir(String projectDir) {
if (compilerMap.containsKey(projectDir)) {
return (AjCompiler) compilerMap.get(projectDir);
}
AjCompiler compiler = new AjCompiler(
projectDir,
new MultiProjTestCompilerConfiguration(projectDir),
new MultiProjTestBuildProgressMonitor(),
new MultiProjTestMessageHandler());
compilerMap.put(projectDir,compiler);
return compiler;
}
/**
* Clears the current map - before doing so clears the state of
* each compiler (this ensures everything is cleaned up in the
* IncrementalStateManager)
*/
public static void clearCompilerMap() {
Collection<AjCompiler> compilers = compilerMap.values();
for (AjCompiler compiler: compilers) {
compiler.clearLastState();
}
compilerMap.clear();
}
}
|