Class PrefixesRemoteRepositoryFilterSource

  • All Implemented Interfaces:
    org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource

    @Singleton
    @Named("prefixes")
    public final class PrefixesRemoteRepositoryFilterSource
    extends RemoteRepositoryFilterSourceSupport
    Remote 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:

    Since:
    1.9.0
    • Field Detail

      • 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:
        1. User-provided files: Checked first from directory specified by CONFIG_PROP_BASEDIR (defaults to $LOCAL_REPO/.remoteRepositoryFilters)
        2. Auto-discovery: If not found, attempts to download from remote repository and cache locally
        File Naming: prefixes-$(repository.id).txt Recommended 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: Create prefixes-myrepoId.txt files in .mvn/rrf/ and commit to version control. Caching: Auto-discovered prefix files are cached in the local repository.
        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 if true the 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 like CONFIG_PROP_ENABLED still show the "real state".
        Since:
        2.0.14
        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 to true (default), the filter allows all requests to proceed for given remote repository when no prefixes are available. When set to false, 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
      • 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 to false only user-provided prefixes will be used.
        Since:
        2.0.14
        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 use CONFIG_PROP_ENABLED with repository ID suffix.
        Since:
        2.0.14
        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 use CONFIG_PROP_ENABLED with 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
      • 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
    • 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)