Skip to content

Store Objects in the DefaultContext in a map #50

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/main/java/org/codehaus/plexus/build/DefaultBuildContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,33 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.Scanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Filesystem based non-incremental build context implementation which behaves as if all files
* were just created. More specifically,
* Filesystem based non-incremental build context implementation which behaves
* as if all files were just created. More specifically,
*
* hasDelta returns <code>true</code> for all paths
* newScanner returns Scanner that scans all files under provided basedir
* newDeletedScanner always returns empty scanner.
* isIncremental returns false
* getValue always returns null
* <ol>
* <li>hasDelta returns <code>true</code> for all paths</li>
* <li>newScanner returns Scanner that scans all files under provided
* basedir</li>
* <li>newDeletedScanner always returns empty scanner</li>
* <li>isIncremental returns <code>false</code></li>
* <li>getValue always returns the last set value in this session and only
* stores to memory</li>
* </ol>
*/
@Named("default")
@Singleton
public class DefaultBuildContext implements BuildContext {

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

/** {@inheritDoc} */
public Object getValue(String key) {
return null;
return contextMap.get(key);
}

/** {@inheritDoc} */
public void setValue(String key, Object value) {
contextMap.put(key, value);
}

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