Class GroupIdRemoteRepositoryFilterSource
- java.lang.Object
-
- org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
-
- org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource
-
- All Implemented Interfaces:
RemoteRepositoryFilterSource
,ArtifactResolverPostProcessor
@Singleton @Named("groupId") public final class GroupIdRemoteRepositoryFilterSource extends RemoteRepositoryFilterSourceSupport implements ArtifactResolverPostProcessor
Remote repository filter source filtering on G coordinate. It is backed by a file that lists all allowed groupIds and groupId not present in this file are filtered out.The file can be authored manually: format is one groupId per line, comments starting with "#" (hash) amd empty lines for structuring are supported. The file can also be pre-populated by "record" functionality of this filter. When "recording", this filter will not filter out anything, but will instead populate the file with all encountered groupIds.
The groupId file is expected on path "${basedir}/groupId-${repository.id}.txt".
The groupId file once loaded are cached in component, so in-flight groupId file change during component existence are NOT noticed.
- Since:
- 1.9.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
GroupIdRemoteRepositoryFilterSource.GroupIdFilter
-
Nested classes/interfaces inherited from class org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
RemoteRepositoryFilterSourceSupport.SimpleResult
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.lang.Boolean>
changedRules
private static java.lang.String
CONF_NAME_RECORD
(package private) static java.lang.String
GROUP_ID_FILE_PREFIX
(package private) static java.lang.String
GROUP_ID_FILE_SUFFIX
private static org.slf4j.Logger
LOGGER
static java.lang.String
NAME
private static java.util.TreeSet<java.lang.String>
NOT_PRESENT
private static RemoteRepositoryFilter.Result
NOT_PRESENT_RESULT
private java.util.concurrent.atomic.AtomicBoolean
onShutdownHandlerRegistered
private RepositorySystemLifecycle
repositorySystemLifecycle
private java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.util.Set<java.lang.String>>
rules
-
Fields inherited from class org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
LOCAL_REPO_PREFIX_DIR
-
-
Constructor Summary
Constructors Constructor Description GroupIdRemoteRepositoryFilterSource(RepositorySystemLifecycle repositorySystemLifecycle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Set<java.lang.String>
cacheRules(RepositorySystemSession session, RemoteRepository remoteRepository)
private java.nio.file.Path
filePath(java.nio.file.Path basedir, java.lang.String remoteRepositoryId)
Returns the groupId path.RemoteRepositoryFilter
getRemoteRepositoryFilter(RepositorySystemSession session)
Provides the filter instance for given session, ornull
if this instance wants to abstain from participating in filtering.private boolean
isRecord(RepositorySystemSession session)
Returnstrue
if given session is recording.private java.util.Set<java.lang.String>
loadRepositoryRules(java.nio.file.Path filePath)
void
postProcess(RepositorySystemSession session, java.util.List<ArtifactResult> artifactResults)
Receives resolver results just before it would return it to caller.private void
saveRecordedLines()
On-close handler that saves recorded rules, if any.-
Methods inherited from class org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
configPropKey, getBasedir, isEnabled
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
CONF_NAME_RECORD
private static final java.lang.String CONF_NAME_RECORD
- See Also:
- Constant Field Values
-
GROUP_ID_FILE_PREFIX
static final java.lang.String GROUP_ID_FILE_PREFIX
- See Also:
- Constant Field Values
-
GROUP_ID_FILE_SUFFIX
static final java.lang.String GROUP_ID_FILE_SUFFIX
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
repositorySystemLifecycle
private final RepositorySystemLifecycle repositorySystemLifecycle
-
rules
private final java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.util.Set<java.lang.String>> rules
-
changedRules
private final java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.lang.Boolean> changedRules
-
onShutdownHandlerRegistered
private final java.util.concurrent.atomic.AtomicBoolean onShutdownHandlerRegistered
-
NOT_PRESENT
private static final java.util.TreeSet<java.lang.String> NOT_PRESENT
-
NOT_PRESENT_RESULT
private static final RemoteRepositoryFilter.Result NOT_PRESENT_RESULT
-
-
Constructor Detail
-
GroupIdRemoteRepositoryFilterSource
@Inject public GroupIdRemoteRepositoryFilterSource(RepositorySystemLifecycle repositorySystemLifecycle)
-
-
Method Detail
-
getRemoteRepositoryFilter
public RemoteRepositoryFilter getRemoteRepositoryFilter(RepositorySystemSession session)
Description copied from interface:RemoteRepositoryFilterSource
Provides the filter instance for given session, ornull
if this instance wants to abstain from participating in filtering.- Specified by:
getRemoteRepositoryFilter
in interfaceRemoteRepositoryFilterSource
- Returns:
- The filter for given session or
null
.
-
postProcess
public void postProcess(RepositorySystemSession session, java.util.List<ArtifactResult> artifactResults)
Description copied from interface:ArtifactResolverPostProcessor
Receives resolver results just before it would return it to caller. Is able to generate "resolution failure" by augmenting passed inArtifactResult
s (artifacts should be "unresolved" and exceptions added).Implementations must be aware that the passed in list of
ArtifactResult
s may have failed resolutions, best to check that usingArtifactResult.isResolved()
method.The implementations must be aware that this call may be "hot", so it directly affects the performance of resolver in general.
- Specified by:
postProcess
in interfaceArtifactResolverPostProcessor
-
filePath
private java.nio.file.Path filePath(java.nio.file.Path basedir, java.lang.String remoteRepositoryId)
Returns the groupId path. The file and parents may not exist, this method merely calculate the path.
-
cacheRules
private java.util.Set<java.lang.String> cacheRules(RepositorySystemSession session, RemoteRepository remoteRepository)
-
loadRepositoryRules
private java.util.Set<java.lang.String> loadRepositoryRules(java.nio.file.Path filePath)
-
isRecord
private boolean isRecord(RepositorySystemSession session)
Returnstrue
if given session is recording.
-
saveRecordedLines
private void saveRecordedLines()
On-close handler that saves recorded rules, if any.
-
-