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-8370] Add maven.repo.local.head #1881

Merged
merged 1 commit into from
Nov 7, 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 @@ -310,6 +310,17 @@ public final class Constants {
@Config
public static final String MAVEN_VERSION_FILTERS = "maven.versionFilters";

/**
* User property for chained LRM: the new "head" local repository to use, and "push" the existing into tail.
* Similar to <code>maven.repo.local.tail</code>, this property may contain comma separated list of paths to be
* used as local repositories (combine with chained local repository), but while latter is "appending" this
* one is "prepending".
*
* @since 4.0.0
*/
@Config
public static final String MAVEN_REPO_LOCAL_HEAD = "maven.repo.local.head";

/**
* 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>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,19 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
supplier.getDependencyManager(Boolean.parseBoolean(resolverDependencyManagerTransitivity)));

ArrayList<Path> paths = new ArrayList<>();
String localRepoHead = mergedProps.get(Constants.MAVEN_REPO_LOCAL_HEAD);
if (localRepoHead != null) {
Arrays.stream(localRepoHead.split(","))
.filter(p -> p != null && !p.trim().isEmpty())
.map(this::resolve)
.forEach(paths::add);
}
paths.add(Paths.get(request.getLocalRepository().getBasedir()));
String localRepoTail = mergedProps.get(Constants.MAVEN_REPO_LOCAL_TAIL);
if (localRepoTail != null) {
Arrays.stream(localRepoTail.split(","))
.filter(p -> p != null && !p.trim().isEmpty())
.map(Paths::get)
.map(this::resolve)
.forEach(paths::add);
}
sessionBuilder.withLocalRepositoryBaseDirectories(paths);
Expand Down Expand Up @@ -426,6 +433,19 @@ public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request)
return sessionBuilder;
}

private Path resolve(String string) {
if (string.startsWith("~/") || string.startsWith("~\\")) {
// resolve based on $HOME
return Paths.get(System.getProperty("user.home"))
.resolve(string.substring(2))
.normalize()
.toAbsolutePath();
} else {
// resolve based on $CWD
return Paths.get(string).normalize().toAbsolutePath();
}
}

private VersionFilter buildVersionFilter(String filterExpression) {
ArrayList<VersionFilter> filters = new ArrayList<>();
if (filterExpression != null) {
Expand Down
150 changes: 78 additions & 72 deletions src/site/markdown/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.
#
props.count = 41
props.count = 42
props.1.key = maven.build.timestamp.format
props.1.configurationType = String
props.1.description = Build timestamp format.
Expand Down Expand Up @@ -124,141 +124,147 @@ props.18.description = Maven local repository.
props.18.defaultValue = ${maven.user.conf}/repository
props.18.since = 3.0.0
props.18.configurationSource = User properties
props.19.key = maven.repo.local.recordReverseTree
props.19.key = maven.repo.local.head
props.19.configurationType = String
props.19.description = 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 repository. Default: <code>false</code>, will not record anything.
props.19.defaultValue = false
props.19.since = 3.9.0
props.19.description = User property for chained LRM: the new "head" local repository to use, and "push" the existing into tail. Similar to <code>maven.repo.local.tail</code>, this property may contain comma separated list of paths to be used as local repositories (combine with chained local repository), but while latter is "appending" this one is "prepending".
props.19.defaultValue =
props.19.since = 4.0.0
props.19.configurationSource = User properties
props.20.key = maven.repo.local.tail
props.20.key = maven.repo.local.recordReverseTree
props.20.configurationType = String
props.20.description = 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>. Default value: <code>null</code>, no chained LRM is used.
props.20.defaultValue =
props.20.description = 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 repository. Default: <code>false</code>, will not record anything.
props.20.defaultValue = false
props.20.since = 3.9.0
props.20.configurationSource = User properties
props.21.key = maven.repo.local.tail.ignoreAvailability
props.21.key = maven.repo.local.tail
props.21.configurationType = String
props.21.description = 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>.
props.21.description = 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>. Default value: <code>null</code>, no chained LRM is used.
props.21.defaultValue =
props.21.since = 3.9.0
props.21.configurationSource = User properties
props.22.key = maven.resolver.dependencyManagerTransitivity
props.22.key = maven.repo.local.tail.ignoreAvailability
props.22.configurationType = String
props.22.description = User property for selecting dependency manager behaviour regarding transitive dependencies and dependency management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence unlike Maven2, obeys dependency management entries deep in dependency graph as well. <br/> Default: <code>"true"</code>.
props.22.defaultValue = true
props.22.since = 4.0.0
props.22.description = 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>.
props.22.defaultValue =
props.22.since = 3.9.0
props.22.configurationSource = User properties
props.23.key = maven.resolver.transport
props.23.key = maven.resolver.dependencyManagerTransitivity
props.23.configurationType = String
props.23.description = Resolver transport to use. Can be <code>default</code>, <code>wagon</code>, <code>apache</code>, <code>jdk</code> or <code>auto</code>.
props.23.defaultValue = default
props.23.description = User property for selecting dependency manager behaviour regarding transitive dependencies and dependency management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence unlike Maven2, obeys dependency management entries deep in dependency graph as well. <br/> Default: <code>"true"</code>.
props.23.defaultValue = true
props.23.since = 4.0.0
props.23.configurationSource = User properties
props.24.key = maven.style.color
props.24.key = maven.resolver.transport
props.24.configurationType = String
props.24.description = Maven output color mode. Allowed values are <code>auto</code>, <code>always</code>, <code>never</code>.
props.24.defaultValue = auto
props.24.description = Resolver transport to use. Can be <code>default</code>, <code>wagon</code>, <code>apache</code>, <code>jdk</code> or <code>auto</code>.
props.24.defaultValue = default
props.24.since = 4.0.0
props.24.configurationSource = User properties
props.25.key = maven.style.debug
props.25.key = maven.style.color
props.25.configurationType = String
props.25.description = Color style for debug messages.
props.25.defaultValue = bold,f:cyan
props.25.description = Maven output color mode. Allowed values are <code>auto</code>, <code>always</code>, <code>never</code>.
props.25.defaultValue = auto
props.25.since = 4.0.0
props.25.configurationSource = User properties
props.26.key = maven.style.error
props.26.key = maven.style.debug
props.26.configurationType = String
props.26.description = Color style for error messages.
props.26.defaultValue = bold,f:red
props.26.description = Color style for debug messages.
props.26.defaultValue = bold,f:cyan
props.26.since = 4.0.0
props.26.configurationSource = User properties
props.27.key = maven.style.failure
props.27.key = maven.style.error
props.27.configurationType = String
props.27.description = Color style for failure messages.
props.27.description = Color style for error messages.
props.27.defaultValue = bold,f:red
props.27.since = 4.0.0
props.27.configurationSource = User properties
props.28.key = maven.style.info
props.28.key = maven.style.failure
props.28.configurationType = String
props.28.description = Color style for info messages.
props.28.defaultValue = bold,f:blue
props.28.description = Color style for failure messages.
props.28.defaultValue = bold,f:red
props.28.since = 4.0.0
props.28.configurationSource = User properties
props.29.key = maven.style.mojo
props.29.key = maven.style.info
props.29.configurationType = String
props.29.description = Color style for mojo messages.
props.29.defaultValue = f:green
props.29.description = Color style for info messages.
props.29.defaultValue = bold,f:blue
props.29.since = 4.0.0
props.29.configurationSource = User properties
props.30.key = maven.style.project
props.30.key = maven.style.mojo
props.30.configurationType = String
props.30.description = Color style for project messages.
props.30.defaultValue = f:cyan
props.30.description = Color style for mojo messages.
props.30.defaultValue = f:green
props.30.since = 4.0.0
props.30.configurationSource = User properties
props.31.key = maven.style.strong
props.31.key = maven.style.project
props.31.configurationType = String
props.31.description = Color style for strong messages.
props.31.defaultValue = bold
props.31.description = Color style for project messages.
props.31.defaultValue = f:cyan
props.31.since = 4.0.0
props.31.configurationSource = User properties
props.32.key = maven.style.success
props.32.key = maven.style.strong
props.32.configurationType = String
props.32.description = Color style for success messages.
props.32.defaultValue = bold,f:green
props.32.description = Color style for strong messages.
props.32.defaultValue = bold
props.32.since = 4.0.0
props.32.configurationSource = User properties
props.33.key = maven.style.trace
props.33.key = maven.style.success
props.33.configurationType = String
props.33.description = Color style for trace messages.
props.33.defaultValue = bold,f:magenta
props.33.description = Color style for success messages.
props.33.defaultValue = bold,f:green
props.33.since = 4.0.0
props.33.configurationSource = User properties
props.34.key = maven.style.transfer
props.34.key = maven.style.trace
props.34.configurationType = String
props.34.description = Color style for transfer messages.
props.34.defaultValue = f:bright-black
props.34.description = Color style for trace messages.
props.34.defaultValue = bold,f:magenta
props.34.since = 4.0.0
props.34.configurationSource = User properties
props.35.key = maven.style.warning
props.35.key = maven.style.transfer
props.35.configurationType = String
props.35.description = Color style for warning messages.
props.35.defaultValue = bold,f:yellow
props.35.description = Color style for transfer messages.
props.35.defaultValue = f:bright-black
props.35.since = 4.0.0
props.35.configurationSource = User properties
props.36.key = maven.user.conf
props.36.key = maven.style.warning
props.36.configurationType = String
props.36.description = Maven user configuration directory.
props.36.defaultValue = ${user.home}/.m2
props.36.description = Color style for warning messages.
props.36.defaultValue = bold,f:yellow
props.36.since = 4.0.0
props.36.configurationSource = User properties
props.37.key = maven.user.extensions
props.37.key = maven.user.conf
props.37.configurationType = String
props.37.description = Maven user extensions.
props.37.defaultValue = ${maven.user.conf}/extensions.xml
props.37.description = Maven user configuration directory.
props.37.defaultValue = ${user.home}/.m2
props.37.since = 4.0.0
props.37.configurationSource = User properties
props.38.key = maven.user.settings
props.38.key = maven.user.extensions
props.38.configurationType = String
props.38.description = Maven user settings.
props.38.defaultValue = ${maven.user.conf}/settings.xml
props.38.description = Maven user extensions.
props.38.defaultValue = ${maven.user.conf}/extensions.xml
props.38.since = 4.0.0
props.38.configurationSource = User properties
props.39.key = maven.user.toolchains
props.39.key = maven.user.settings
props.39.configurationType = String
props.39.description = Maven user toolchains.
props.39.defaultValue = ${maven.user.home}/toolchains.xml
props.39.description = Maven user settings.
props.39.defaultValue = ${maven.user.conf}/settings.xml
props.39.since = 4.0.0
props.39.configurationSource = User properties
props.40.key = maven.versionFilters
props.40.key = maven.user.toolchains
props.40.configurationType = String
props.40.description = User property for version filters expression, a semicolon separated list of filters to apply. By default, no version filter is applied (like in Maven 3). <br/> Supported filters: <ul> <li>"h" or "h(num)" - highest version or top list of highest ones filter</li> <li>"l" or "l(num)" - lowest version or bottom list of lowest ones filter</li> <li>"s" - contextual snapshot filter</li> <li>"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)</li> </ul> Example filter expression: <code>"h(5);s;e(org.foo:bar:1)</code> will cause: ranges are filtered for "top 5" (instead full range), snapshots are banned if root project is not a snapshot, and if range for <code>org.foo:bar</code> is being processed, version 1 is omitted.
props.40.defaultValue =
props.40.description = Maven user toolchains.
props.40.defaultValue = ${maven.user.home}/toolchains.xml
props.40.since = 4.0.0
props.40.configurationSource = User properties
props.41.key = maven.versionResolver.noCache
props.41.configurationType = Boolean
props.41.description = User property for disabling version resolver cache.
props.41.defaultValue = false
props.41.since = 3.0.0
props.41.key = maven.versionFilters
props.41.configurationType = String
props.41.description = User property for version filters expression, a semicolon separated list of filters to apply. By default, no version filter is applied (like in Maven 3). <br/> Supported filters: <ul> <li>"h" or "h(num)" - highest version or top list of highest ones filter</li> <li>"l" or "l(num)" - lowest version or bottom list of lowest ones filter</li> <li>"s" - contextual snapshot filter</li> <li>"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)</li> </ul> Example filter expression: <code>"h(5);s;e(org.foo:bar:1)</code> will cause: ranges are filtered for "top 5" (instead full range), snapshots are banned if root project is not a snapshot, and if range for <code>org.foo:bar</code> is being processed, version 1 is omitted.
props.41.defaultValue =
props.41.since = 4.0.0
props.41.configurationSource = User properties
props.42.key = maven.versionResolver.noCache
props.42.configurationType = Boolean
props.42.description = User property for disabling version resolver cache.
props.42.defaultValue = false
props.42.since = 3.0.0
props.42.configurationSource = User properties
6 changes: 6 additions & 0 deletions src/site/markdown/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ props:
defaultValue: ${maven.user.conf}/repository
since: 3.0.0
configurationSource: User properties
- key: maven.repo.local.head
configurationType: String
description: "User property for chained LRM: the new \"head\" local repository to use, and \"push\" the existing into tail. Similar to <code>maven.repo.local.tail</code>, this property may contain comma separated list of paths to be used as local repositories (combine with chained local repository), but while latter is \"appending\" this one is \"prepending\"."
defaultValue:
since: 4.0.0
configurationSource: User properties
- key: maven.repo.local.recordReverseTree
configurationType: String
description: "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 repository. Default: <code>false</code>, will not record anything."
Expand Down
Loading