Class PrefixesRemoteRepositoryFilterSource
- java.lang.Object
-
- org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
-
- org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource
-
- All Implemented Interfaces:
org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource
@Singleton @Named("prefixes") public final class PrefixesRemoteRepositoryFilterSource extends RemoteRepositoryFilterSourceSupportRemote repository filter source filtering on path prefixes. It is backed by a file that lists all allowed path prefixes from remote repository. Artifact that layout converted path (using remote repository layout) results in path with no corresponding prefix present in this file is filtered out.The file can be authored manually: format is one prefix per line, comments starting with "#" (hash) and empty lines for structuring are supported, The "/" (slash) character is used as file separator. Some remote repositories and MRMs publish these kind of files, they can be downloaded from corresponding URLs.
The prefix file is expected on path "${basedir}/prefixes-${repository.id}.txt".
The prefixes file is once loaded and cached, so in-flight prefixes file change during component existence are not noticed.
Examples of published prefix files:
- Central: prefixes.txt
- Apache Releases: prefixes.txt
- Since:
- 1.9.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIG_PROP_BASEDIRThe basedir where to store filter files.static java.lang.StringCONFIG_PROP_ENABLEDConfiguration to enable the Prefixes filter (enabled by default).static java.lang.StringCONFIG_PROP_NO_INPUT_OUTCOMEDetermines what happens when the filter is enabled, but has no prefixes available for given remote repository to work with.static java.lang.StringCONFIG_PROP_RESOLVE_PREFIX_FILESConfiguration to allow Prefixes file resolution attempt from remote repository as "auto discovery".static java.lang.StringCONFIG_PROP_SKIPPEDConfiguration to skip the Prefixes filter for given request.static java.lang.StringCONFIG_PROP_USE_MIRRORED_REPOSITORIESConfiguration to allow Prefixes filter to auto-discover prefixes from mirrored repositories as well.static java.lang.StringCONFIG_PROP_USE_REPOSITORY_MANAGERSConfiguration to allow Prefixes filter to auto-discover prefixes from repository managers as well.static booleanDEFAULT_ENABLEDstatic booleanDEFAULT_NO_INPUT_OUTCOMEstatic booleanDEFAULT_RESOLVE_PREFIX_FILESstatic booleanDEFAULT_SKIPPEDstatic booleanDEFAULT_USE_MIRRORED_REPOSITORIESstatic booleanDEFAULT_USE_REPOSITORY_MANAGERSstatic java.lang.StringLOCAL_REPO_PREFIX_DIRstatic java.lang.StringNAME-
Fields inherited from class org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
CONFIG_PROP_REPOSITORY_KEY_FUNCTION, CONFIG_PROPS_PREFIX, DEFAULT_REPOSITORY_KEY_FUNCTION
-
-
Constructor Summary
Constructors Constructor Description PrefixesRemoteRepositoryFilterSource(org.eclipse.aether.spi.remoterepo.RepositoryKeyFunctionFactory repositoryKeyFunctionFactory, java.util.function.Supplier<MetadataResolver> metadataResolver, java.util.function.Supplier<RemoteRepositoryManager> remoteRepositoryManager, org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider repositoryLayoutProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.aether.spi.connector.filter.RemoteRepositoryFiltergetRemoteRepositoryFilter(org.eclipse.aether.RepositorySystemSession session)protected booleanisEnabled(org.eclipse.aether.RepositorySystemSession session)Returnstrueif session configuration contains this name set totrue.-
Methods inherited from class org.eclipse.aether.internal.impl.filter.RemoteRepositoryFilterSourceSupport
getBasedir, normalizeRemoteRepository, repositoryKey
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
CONFIG_PROP_ENABLED
public static final java.lang.String CONFIG_PROP_ENABLED
Configuration to enable the Prefixes filter (enabled by default). Can be fine-tuned per repository using repository ID suffixes. Important: For this filter to take effect, configuration files must be available. Without configuration files, the enabled filter remains dormant and does not interfere with resolution. Configuration File Resolution:- User-provided files: Checked first from directory specified by
CONFIG_PROP_BASEDIR(defaults to$LOCAL_REPO/.remoteRepositoryFilters) - Auto-discovery: If not found, attempts to download from remote repository and cache locally
prefixes-$(repository.id).txtRecommended Setup (Auto-Discovery with Override Capability): Start with auto-discovery, but prepare for project-specific overrides. Add to.mvn/maven.config:-Daether.remoteRepositoryFilter.prefixes=true -Daether.remoteRepositoryFilter.prefixes.basedir=${session.rootDirectory}/.mvn/rrf/Initial setup: Don't provide any files - rely on auto-discovery as repositories are accessed. Override when needed: Createprefixes-myrepoId.txtfiles in.mvn/rrf/and commit to version control. Caching: Auto-discovered prefix files are cached in the local repository.- See Also:
- Constant Field Values
- User-provided files: Checked first from directory specified by
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLED
- See Also:
- Constant Field Values
-
CONFIG_PROP_SKIPPED
public static final java.lang.String CONFIG_PROP_SKIPPED
Configuration to skip the Prefixes filter for given request. This configuration is evaluated and iftruethe prefixes remote filter will not kick in. Main use case is by filter itself, to prevent recursion during discovery of remote prefixes file, but this also allows other components to control prefix filter discovery, while leaving configuration likeCONFIG_PROP_ENABLEDstill show the "real state".- Since:
- 2.0.14
- See Also:
- Constant Field Values
-
DEFAULT_SKIPPED
public static final boolean DEFAULT_SKIPPED
- See Also:
- Constant Field Values
-
CONFIG_PROP_NO_INPUT_OUTCOME
public static final java.lang.String CONFIG_PROP_NO_INPUT_OUTCOME
Determines what happens when the filter is enabled, but has no prefixes available for given remote repository to work with. When set totrue(default), the filter allows all requests to proceed for given remote repository when no prefixes are available. When set tofalse, the filter blocks all requests toward given remote repository when no prefixes are available. This setting allows repoId suffix, hence, can determine "global" or "repository targeted" behaviors.- Since:
- 2.0.14
- See Also:
- Constant Field Values
-
DEFAULT_NO_INPUT_OUTCOME
public static final boolean DEFAULT_NO_INPUT_OUTCOME
- See Also:
- Constant Field Values
-
CONFIG_PROP_RESOLVE_PREFIX_FILES
public static final java.lang.String CONFIG_PROP_RESOLVE_PREFIX_FILES
Configuration to allow Prefixes file resolution attempt from remote repository as "auto discovery". If this configuration set tofalseonly user-provided prefixes will be used.- Since:
- 2.0.14
- See Also:
- Constant Field Values
-
DEFAULT_RESOLVE_PREFIX_FILES
public static final boolean DEFAULT_RESOLVE_PREFIX_FILES
- See Also:
- Constant Field Values
-
CONFIG_PROP_USE_MIRRORED_REPOSITORIES
public static final java.lang.String CONFIG_PROP_USE_MIRRORED_REPOSITORIES
Configuration to allow Prefixes filter to auto-discover prefixes from mirrored repositories as well. For this to work Maven should be aware that given remote repository is mirror and is usually backed by MRM. Given multiple MRM implementations messes up prefixes file, is better to just skip these. In other case, one may useCONFIG_PROP_ENABLEDwith repository ID suffix.- Since:
- 2.0.14
- See Also:
- Constant Field Values
-
DEFAULT_USE_MIRRORED_REPOSITORIES
public static final boolean DEFAULT_USE_MIRRORED_REPOSITORIES
- See Also:
- Constant Field Values
-
CONFIG_PROP_USE_REPOSITORY_MANAGERS
public static final java.lang.String CONFIG_PROP_USE_REPOSITORY_MANAGERS
Configuration to allow Prefixes filter to auto-discover prefixes from repository managers as well. For this to work Maven should be aware that given remote repository is backed by repository manager. Given multiple MRM implementations messes up prefixes file, is better to just skip these. In other case, one may useCONFIG_PROP_ENABLEDwith repository ID suffix. Note: as of today, nothing sets this on remote repositories, but is added for future.- Since:
- 2.0.14
- See Also:
- Constant Field Values
-
DEFAULT_USE_REPOSITORY_MANAGERS
public static final boolean DEFAULT_USE_REPOSITORY_MANAGERS
- See Also:
- Constant Field Values
-
CONFIG_PROP_BASEDIR
public static final java.lang.String CONFIG_PROP_BASEDIR
The basedir where to store filter files. If path is relative, it is resolved from local repository root.- See Also:
- Constant Field Values
-
LOCAL_REPO_PREFIX_DIR
public static final java.lang.String LOCAL_REPO_PREFIX_DIR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PrefixesRemoteRepositoryFilterSource
@Inject public PrefixesRemoteRepositoryFilterSource(org.eclipse.aether.spi.remoterepo.RepositoryKeyFunctionFactory repositoryKeyFunctionFactory, java.util.function.Supplier<MetadataResolver> metadataResolver, java.util.function.Supplier<RemoteRepositoryManager> remoteRepositoryManager, org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider repositoryLayoutProvider)
-
-
Method Detail
-
isEnabled
protected boolean isEnabled(org.eclipse.aether.RepositorySystemSession session)
Description copied from class:RemoteRepositoryFilterSourceSupportReturnstrueif session configuration contains this name set totrue.Default is
true.- Specified by:
isEnabledin classRemoteRepositoryFilterSourceSupport
-
getRemoteRepositoryFilter
public org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilter getRemoteRepositoryFilter(org.eclipse.aether.RepositorySystemSession session)
-
-