Skip to content

Commit

Permalink
[MRESOLVER-330] Introduce file-static name mapper (s4u#258)
Browse files Browse the repository at this point in the history
As static does not work with file-lock factory.

---

https://issues.apache.org/jira/browse/MRESOLVER-330
  • Loading branch information
cstamas authored Mar 1, 2023
1 parent 15d0560 commit 5ad3ac1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -48,6 +53,13 @@ public static NameMapper fileGavNameMapper() {
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()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit 5ad3ac1

Please sign in to comment.