Skip to content

Commit f1c12d7

Browse files
author
Christoph Läubrich
committed
Store Objects in the DefaultContext in a map
Fix #48
1 parent f28ab02 commit f1c12d7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/java/org/codehaus/plexus/build/DefaultBuildContext.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,33 @@
2121
import java.io.OutputStream;
2222
import java.nio.file.Files;
2323
import java.util.List;
24+
import java.util.Map;
25+
import java.util.concurrent.ConcurrentHashMap;
2426

2527
import org.codehaus.plexus.util.DirectoryScanner;
2628
import org.codehaus.plexus.util.Scanner;
2729
import org.slf4j.Logger;
2830
import org.slf4j.LoggerFactory;
2931

3032
/**
31-
* Filesystem based non-incremental build context implementation which behaves as if all files
32-
* were just created. More specifically,
33+
* Filesystem based non-incremental build context implementation which behaves
34+
* as if all files were just created. More specifically,
3335
*
34-
* hasDelta returns <code>true</code> for all paths
35-
* newScanner returns Scanner that scans all files under provided basedir
36-
* newDeletedScanner always returns empty scanner.
37-
* isIncremental returns false
38-
* getValue always returns null
36+
* <ol>
37+
* <li>hasDelta returns <code>true</code> for all paths</li>
38+
* <li>newScanner returns Scanner that scans all files under provided
39+
* basedir</li>
40+
* <li>newDeletedScanner always returns empty scanner</li>
41+
* <li>isIncremental returns <code>false</code></li>
42+
* <li>getValue always returns the last set value in this session and only
43+
* stores to memory</li>
44+
* </ol>
3945
*/
4046
@Named("default")
4147
@Singleton
4248
public class DefaultBuildContext implements BuildContext {
4349

50+
private final Map<String, Object> contextMap = new ConcurrentHashMap<>();
4451
private final Logger logger = LoggerFactory.getLogger(DefaultBuildContext.class);
4552
/** {@inheritDoc} */
4653
public boolean hasDelta(String relpath) {
@@ -105,11 +112,12 @@ public boolean isIncremental() {
105112

106113
/** {@inheritDoc} */
107114
public Object getValue(String key) {
108-
return null;
115+
return contextMap.get(key);
109116
}
110117

111118
/** {@inheritDoc} */
112119
public void setValue(String key, Object value) {
120+
contextMap.put(key, value);
113121
}
114122

115123
private String getMessage(File file, int line, int column, String message) {

0 commit comments

Comments
 (0)