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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -386,5 +386,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}
* 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}. 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 @@ -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