This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new 5ad3ac11 [MRESOLVER-330] Introduce file-static name mapper (#258)
5ad3ac11 is described below
commit 5ad3ac1130171d6f8d9bae789e91ea373f591f73
Author: Tamas Cservenak <[email protected]>
AuthorDate: Wed Mar 1 08:36:33 2023 +0100
[MRESOLVER-330] Introduce file-static name mapper (#258)
As static does not work with file-lock factory.
---
https://issues.apache.org/jira/browse/MRESOLVER-330
---
.../impl/synccontext/named/NameMappers.java | 12 ++++++
.../providers/FileStaticNameMapperProvider.java | 46 ++++++++++++++++++++++
.../src/site/markdown/synccontextfactory.md.vm | 3 +-
3 files changed, 60 insertions(+), 1 deletion(-)
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NameMappers.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NameMappers.java
index 156b2105..6297c21b 100644
---
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NameMappers.java
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NameMappers.java
@@ -34,6 +34,11 @@ public final class NameMappers {
public static final String FILE_HGAV_NAME = "file-hgav";
+ /**
+ * @since 1.9.6
+ */
+ public static final String FILE_STATIC_NAME = "file-static";
+
public static final String DISCRIMINATING_NAME = "discriminating";
public static NameMapper staticNameMapper() {
@@ -48,6 +53,13 @@ public final class NameMappers {
return new BasedirNameMapper(GAVNameMapper.fileGav());
}
+ /**
+ * @since 1.9.6
+ */
+ public static NameMapper fileStaticNameMapper() {
+ return new BasedirNameMapper(new StaticNameMapper());
+ }
+
public static NameMapper fileHashingGavNameMapper() {
return new BasedirNameMapper(new
HashingNameMapper(GAVNameMapper.gav()));
}
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/providers/FileStaticNameMapperProvider.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/providers/FileStaticNameMapperProvider.java
new file mode 100644
index 00000000..ffea2e6c
--- /dev/null
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/providers/FileStaticNameMapperProvider.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.eclipse.aether.internal.impl.synccontext.named.providers;
+
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
+import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
+
+/**
+ * The "file-static" name mapper provider.
+ *
+ * @since 1.9.6
+ */
+@Singleton
+@Named(NameMappers.FILE_STATIC_NAME)
+public class FileStaticNameMapperProvider implements Provider<NameMapper> {
+ private final NameMapper mapper;
+
+ public FileStaticNameMapperProvider() {
+ this.mapper = NameMappers.fileStaticNameMapper();
+ }
+
+ @Override
+ public NameMapper get() {
+ return mapper;
+ }
+}
diff --git a/maven-resolver-impl/src/site/markdown/synccontextfactory.md.vm
b/maven-resolver-impl/src/site/markdown/synccontextfactory.md.vm
index afe611fb..c970fa15 100644
--- a/maven-resolver-impl/src/site/markdown/synccontextfactory.md.vm
+++ b/maven-resolver-impl/src/site/markdown/synccontextfactory.md.vm
@@ -66,7 +66,8 @@ For the `aether.syncContext.named.nameMapper` property
following values are allo
- `file-gav` uses GAV and session to create absolute file paths (to be used
with `file-lock` factory)
- `file-hgav` uses more compact layout than `file-gav` by SHA-1 digest,
similar to git (to be used with `file-lock` factory)
- `static` uses static (same) string as lock name for any input. Effectively
providing functionality same as old
- "global" locking SyncContextFactory.
+ "global" locking SyncContextFactory. Mostly for testing/experimental
purposes.
+- `file-static` same as `static` but to be used with `file-lock` factory.
Mostly for testing/experimental purposes.
Extra values for factory (these need extra setup and will work with Sisu DI
only):