Skip to content

Commit 490b1ca

Browse files
committed
Work out the TODO
1 parent 7eae084 commit 490b1ca

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/filter/PrefixesRemoteRepositoryFilterSource.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@ public final class PrefixesRemoteRepositoryFilterSource extends RemoteRepository
150150

151151
public static final boolean DEFAULT_USE_MIRRORED_REPOSITORIES = false;
152152

153+
/**
154+
* Configuration to allow Prefixes filter to auto-discover prefixes from repository managers as well. For this to
155+
* work <em>Maven should be aware</em> that given remote repository is backed by repository manager.
156+
* Given multiple MRM implementations messes up prefixes file, is better to just skip these. In other case, one may use
157+
* {@link #CONFIG_PROP_ENABLED} with repository ID suffix.
158+
* <em>Note: as of today, nothing sets this on remote repositories, but is added for future.</em>
159+
*
160+
* @since 2.0.14
161+
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
162+
* @configurationType {@link java.lang.Boolean}
163+
* @configurationRepoIdSuffix Yes
164+
* @configurationDefaultValue {@link #DEFAULT_USE_REPOSITORY_MANAGERS}
165+
*/
166+
public static final String CONFIG_PROP_USE_REPOSITORY_MANAGERS =
167+
RemoteRepositoryFilterSourceSupport.CONFIG_PROPS_PREFIX + NAME + ".useRepositoryManagers";
168+
169+
public static final boolean DEFAULT_USE_REPOSITORY_MANAGERS = false;
170+
153171
/**
154172
* The basedir where to store filter files. If path is relative, it is resolved from local repository root.
155173
*
@@ -301,10 +319,14 @@ private Path resolvePrefixesFromLocalConfiguration(
301319

302320
private boolean supportedResolvePrefixesForRemoteRepository(
303321
RepositorySystemSession session, RemoteRepository remoteRepository) {
304-
// TODO: RemoteRepository.isRepositoryManager() is still unused in Maven; once used, factor it in
305-
return remoteRepository.getMirroredRepositories().isEmpty()
306-
|| ConfigUtils.getBoolean(
307-
session, DEFAULT_USE_MIRRORED_REPOSITORIES, CONFIG_PROP_USE_MIRRORED_REPOSITORIES);
322+
if (remoteRepository.isRepositoryManager()) {
323+
return ConfigUtils.getBoolean(
324+
session, DEFAULT_USE_REPOSITORY_MANAGERS, CONFIG_PROP_USE_REPOSITORY_MANAGERS);
325+
} else {
326+
return remoteRepository.getMirroredRepositories().isEmpty()
327+
|| ConfigUtils.getBoolean(
328+
session, DEFAULT_USE_MIRRORED_REPOSITORIES, CONFIG_PROP_USE_MIRRORED_REPOSITORIES);
329+
}
308330
}
309331

310332
private Path resolvePrefixesFromRemoteRepository(

src/site/markdown/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ To modify this file, edit the template and regenerate.
106106
| `"aether.remoteRepositoryFilter.prefixes.basedir"` | `String` | The basedir where to store filter files. If path is relative, it is resolved from local repository root. | `".remoteRepositoryFilters"` | 1.9.0 | No | Session Configuration |
107107
| `"aether.remoteRepositoryFilter.prefixes.skipped"` | `Boolean` | Configuration to skip the Prefixes filter for given request. This configuration is evaluated and if <code>true</code> 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 <code>#CONFIG_PROP_ENABLED</code> still show the "real state". | `false` | 2.0.14 | Yes | Session Configuration |
108108
| `"aether.remoteRepositoryFilter.prefixes.useMirroredRepositories"` | `Boolean` | Configuration to allow Prefixes filter to auto-discover prefixes from mirrored repositories as well. For this to work <em>Maven should be aware</em> 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 <code>#CONFIG_PROP_ENABLED</code> with repository ID suffix. | `false` | 2.0.14 | Yes | Session Configuration |
109+
| `"aether.remoteRepositoryFilter.prefixes.useRepositoryManagers"` | `Boolean` | Configuration to allow Prefixes filter to auto-discover prefixes from repository managers as well. For this to work <em>Maven should be aware</em> 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 <code>#CONFIG_PROP_ENABLED</code> with repository ID suffix. <em>Note: as of today, nothing sets this on remote repositories, but is added for future.</em> | `false` | 2.0.14 | Yes | Session Configuration |
109110
| `"aether.snapshotFilter"` | `Boolean` | The key in the repository session's <code>RepositorySystemSession#getConfigProperties() configurationproperties</code> used to store a <code>Boolean</code> flag whether this filter should be forced to ban snapshots. By default, snapshots are only filtered if the root artifact is not a snapshot. | `false` | | No | Session Configuration |
110111
| `"aether.syncContext.named.basedir.locksDir"` | `String` | The location of the directory toi use for locks. If relative path, it is resolved from the local repository root. | `".locks"` | 1.9.0 | No | Session Configuration |
111112
| `"aether.syncContext.named.discriminating.discriminator"` | `String` | Configuration property to pass in discriminator, if needed. If not present, it is auto-calculated. | - | 1.7.0 | No | Session Configuration |

0 commit comments

Comments
 (0)