Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[MNG-8362] Adding some missing config properties #1861

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,25 @@ public final class Constants {

/**
* User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
* {@code org.eclipse.aether.util.repository.ChainedLocalRepositoryManager}.
* <code>org.eclipse.aether.util.repository.ChainedLocalRepositoryManager</code>.
* Default value: <code>null</code>, no chained LRM is used.
*
* @since 3.9.0
*/
@Config
public static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";

/**
* User property for chained LRM: whether to ignore "availability check" in tail or not. Usually you do want
* to ignore it. This property is mapped onto corresponding Resolver 2.x property, is like a synonym for it.
* Default value: <code>true</code>.
*
* @since 3.9.0
* @see <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration: aether.chainedLocalRepository.ignoreTailAvailability</a>
*/
@Config
public static final String MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY = "maven.repo.local.tail.ignoreAvailability";

/**
* User property for reverse dependency tree. If enabled, Maven will record ".tracking" directory into local
* repository with "reverse dependency tree", essentially explaining WHY given artifact is present in local
Expand Down Expand Up @@ -386,5 +397,28 @@ public final class Constants {
@Config(type = "java.lang.Boolean", defaultValue = "true")
public static final String MAVEN_CONSUMER_POM = "maven.consumer.pom";

/**
* User property for disabling version resolver cache.
*
* @since 3.0.0
*/
@Config(type = "java.lang.Boolean", defaultValue = "false")
public static final String MAVEN_VERSION_RESOLVER_NO_CACHE = "maven.versionResolver.noCache";

/**
* User property for overriding calculated "build number" for snapshot deploys. Caution: this property should
* be RARELY used (if used at all). It may help in special cases like "aligning" a reactor build subprojects
* build numbers to perform a "snapshot lock down". Value given here must be <code>maxRemoteBuildNumber + 1</code>
* or greater, otherwise build will fail. How the number to be obtained is left to user (ie by inspecting
* snapshot repository metadata or alike).
*
* Note: this feature is present in Maven 3.9.7 but with different key: <code>maven.buildNumber</code>. In Maven 4
* as part of cleanup effort this key was renamed to properly reflect its purpose.
*
* @since 4.0.0
*/
@Config(type = "java.lang.Integer")
public static final String MAVEN_DEPLOY_SNAPSHOT_BUILD_NUMBER = "maven.deploy.snapshot.buildNumber";

private Constants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.eclipse.aether.util.graph.version.PredicateVersionFilter;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
import org.eclipse.aether.util.repository.ChainedLocalRepositoryManager;
import org.eclipse.aether.util.repository.DefaultAuthenticationSelector;
import org.eclipse.aether.util.repository.DefaultMirrorSelector;
import org.eclipse.aether.util.repository.DefaultProxySelector;
Expand Down Expand Up @@ -401,6 +402,12 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
.forEach(paths::add);
}
sessionBuilder.withLocalRepositoryBaseDirectories(paths);
// Pass over property supported by Maven 3.9.x
if (mergedProps.containsKey(Constants.MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY)) {
configProps.put(
ChainedLocalRepositoryManager.CONFIG_PROP_IGNORE_TAIL_AVAILABILITY,
mergedProps.get(Constants.MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY));
}

for (RepositorySystemSessionExtender extender : sessionExtenders.values()) {
extender.extend(request, configProps, mirrorSelector, proxySelector, authSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Objects;

import org.apache.maven.api.Constants;
import org.apache.maven.api.di.Inject;
import org.apache.maven.api.di.Named;
import org.apache.maven.api.di.Singleton;
Expand Down Expand Up @@ -104,7 +105,7 @@ public VersionResult resolveVersion(RepositorySystemSession session, VersionRequ

Key cacheKey = null;
RepositoryCache cache = session.getCache();
if (cache != null && !ConfigUtils.getBoolean(session, false, "aether.versionResolver.noCache")) {
if (cache != null && !ConfigUtils.getBoolean(session, false, Constants.MAVEN_VERSION_RESOLVER_NO_CACHE)) {
cacheKey = new Key(session, request);

Object obj = cache.get(session, cacheKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.maven.api.Constants;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.deployment.DeployRequest;
Expand All @@ -46,7 +47,7 @@ class RemoteSnapshotMetadataGenerator implements MetadataGenerator {

RemoteSnapshotMetadataGenerator(RepositorySystemSession session, DeployRequest request) {
timestamp = (Date) ConfigUtils.getObject(session, new Date(), "maven.startTime");
Object bn = ConfigUtils.getObject(session, null, "maven.buildNumber");
Object bn = ConfigUtils.getObject(session, null, Constants.MAVEN_DEPLOY_SNAPSHOT_BUILD_NUMBER);
if (bn instanceof Integer) {
this.buildNumber = (Integer) bn;
} else if (bn instanceof String) {
Expand Down
Loading