Skip to content
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 @@ -95,8 +95,11 @@
import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
import org.eclipse.aether.internal.impl.synccontext.named.providers.DiscriminatingNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.FileGAECVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.FileGAVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.FileHashingGAECVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.FileHashingGAVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.GAECVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.GAVNameMapperProvider;
import org.eclipse.aether.internal.impl.synccontext.named.providers.StaticNameMapperProvider;
import org.eclipse.aether.named.NamedLockFactory;
Expand Down Expand Up @@ -282,6 +285,10 @@ protected void configure() {
.annotatedWith(Names.named(NameMappers.GAV_NAME))
.toProvider(GAVNameMapperProvider.class)
.in(Singleton.class);
bind(NameMapper.class)
.annotatedWith(Names.named(NameMappers.GAECV_NAME))
.toProvider(GAECVNameMapperProvider.class)
.in(Singleton.class);
bind(NameMapper.class)
.annotatedWith(Names.named(NameMappers.DISCRIMINATING_NAME))
.toProvider(DiscriminatingNameMapperProvider.class)
Expand All @@ -290,10 +297,18 @@ protected void configure() {
.annotatedWith(Names.named(NameMappers.FILE_GAV_NAME))
.toProvider(FileGAVNameMapperProvider.class)
.in(Singleton.class);
bind(NameMapper.class)
.annotatedWith(Names.named(NameMappers.FILE_GAECV_NAME))
.toProvider(FileGAECVNameMapperProvider.class)
.in(Singleton.class);
bind(NameMapper.class)
.annotatedWith(Names.named(NameMappers.FILE_HGAV_NAME))
.toProvider(FileHashingGAVNameMapperProvider.class)
.in(Singleton.class);
bind(NameMapper.class)
.annotatedWith(Names.named(NameMappers.FILE_HGAECV_NAME))
.toProvider(FileHashingGAECVNameMapperProvider.class)
.in(Singleton.class);

bind(NamedLockFactory.class)
.annotatedWith(Names.named(NoopNamedLockFactory.NAME))
Expand Down Expand Up @@ -393,20 +408,27 @@ Map<String, ChecksumAlgorithmFactory> provideChecksumTypes(
return Collections.unmodifiableMap(result);
}

@SuppressWarnings("checkstyle:parameternumber")
@Provides
@Singleton
Map<String, NameMapper> provideNameMappers(
@Named(NameMappers.STATIC_NAME) NameMapper staticNameMapper,
@Named(NameMappers.GAV_NAME) NameMapper gavNameMapper,
@Named(NameMappers.GAECV_NAME) NameMapper gaecvNameMapper,
@Named(NameMappers.DISCRIMINATING_NAME) NameMapper discriminatingNameMapper,
@Named(NameMappers.FILE_GAV_NAME) NameMapper fileGavNameMapper,
@Named(NameMappers.FILE_HGAV_NAME) NameMapper fileHashingGavNameMapper) {
@Named(NameMappers.FILE_GAECV_NAME) NameMapper fileGaecvNameMapper,
@Named(NameMappers.FILE_HGAV_NAME) NameMapper fileHashingGavNameMapper,
@Named(NameMappers.FILE_HGAECV_NAME) NameMapper fileHashingGaecvNameMapper) {
Map<String, NameMapper> result = new HashMap<>();
result.put(NameMappers.STATIC_NAME, staticNameMapper);
result.put(NameMappers.GAV_NAME, gavNameMapper);
result.put(NameMappers.GAECV_NAME, gaecvNameMapper);
result.put(NameMappers.DISCRIMINATING_NAME, discriminatingNameMapper);
result.put(NameMappers.FILE_GAV_NAME, fileGavNameMapper);
result.put(NameMappers.FILE_GAECV_NAME, fileGaecvNameMapper);
result.put(NameMappers.FILE_HGAV_NAME, fileHashingGavNameMapper);
result.put(NameMappers.FILE_HGAECV_NAME, fileHashingGaecvNameMapper);
return Collections.unmodifiableMap(result);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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;

import org.eclipse.aether.artifact.Artifact;

/**
* Artifact GAECV {@link NameMapper} extends {@link GAVNameMapper} and improves artifact name mapping selectivity by
* using all coordinates.
*
* @since 1.9.25
*/
public class GAECVNameMapper extends GAVNameMapper {
public GAECVNameMapper(
boolean fileSystemFriendly,
String artifactPrefix,
String artifactSuffix,
String metadataPrefix,
String metadataSuffix,
String fieldSeparator) {
super(fileSystemFriendly, artifactPrefix, artifactSuffix, metadataPrefix, metadataSuffix, fieldSeparator);
}

@Override
protected String getArtifactName(Artifact artifact) {
if (artifact.getClassifier().isEmpty()) {
return artifactPrefix
+ artifact.getGroupId()
+ fieldSeparator
+ artifact.getArtifactId()
+ fieldSeparator
+ artifact.getExtension()
+ fieldSeparator
+ artifact.getBaseVersion()
+ artifactSuffix;
} else {
return artifactPrefix
+ artifact.getGroupId()
+ fieldSeparator
+ artifact.getArtifactId()
+ fieldSeparator
+ artifact.getExtension()
+ fieldSeparator
+ artifact.getClassifier()
+ fieldSeparator
+ artifact.getBaseVersion()
+ artifactSuffix;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@

/**
* Artifact GAV {@link NameMapper}, uses artifact and metadata coordinates to name their corresponding locks. Is not
* considering local repository, only the artifact coordinates. May use custom prefixes and sufixes and separators,
* considering local repository, only the artifact coordinates. May use custom prefixes and suffixes and separators,
* hence this instance may or may not be filesystem friendly (depends on strings used).
* <p>
* Note: in earlier Resolver 1.9.x versions this mapper was the default, but it changed to {@link GAECVNameMapper}
* in 1.9.25.
*/
public class GAVNameMapper implements NameMapper {
private final boolean fileSystemFriendly;
protected final boolean fileSystemFriendly;

private final String artifactPrefix;
protected final String artifactPrefix;

private final String artifactSuffix;
protected final String artifactSuffix;

private final String metadataPrefix;
protected final String metadataPrefix;

private final String metadataSuffix;
protected final String metadataSuffix;

private final String fieldSeparator;
protected final String fieldSeparator;

public GAVNameMapper(
boolean fileSystemFriendly,
Expand Down Expand Up @@ -88,7 +91,7 @@ public Collection<String> nameLocks(
return keys;
}

private String getArtifactName(Artifact artifact) {
protected String getArtifactName(Artifact artifact) {
return artifactPrefix
+ artifact.getGroupId()
+ fieldSeparator
Expand All @@ -98,9 +101,9 @@ private String getArtifactName(Artifact artifact) {
+ artifactSuffix;
}

private static final String MAVEN_METADATA = "maven-metadata.xml";
protected static final String MAVEN_METADATA = "maven-metadata.xml";

private String getMetadataName(Metadata metadata) {
protected String getMetadataName(Metadata metadata) {
String name = metadataPrefix;
if (!metadata.getGroupId().isEmpty()) {
name += metadata.getGroupId();
Expand All @@ -122,10 +125,18 @@ private String getMetadataName(Metadata metadata) {
return name + metadataSuffix;
}

/**
* @deprecated Use {@link NameMappers} to create name mappers instead.
*/
@Deprecated
public static NameMapper gav() {
return new GAVNameMapper(false, "artifact:", "", "metadata:", "", ":");
}

/**
* @deprecated Use {@link NameMappers} to create name mappers instead.
*/
@Deprecated
public static NameMapper fileGav() {
return new GAVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
/**
* As end-user "mappers" are actually configurations/compositions and are constructed from several NameMapper
* implementations, this helper class constructing them. This class also holds "names" used by service locator and
* Guice/Sisu as well.
* Guice/Sisu as well. Ideally, name mapper you want should exist here, constructing name mappers should not be
* needed (unless some very specific case or testing).
*
* @since 1.9.4
*/
public final class NameMappers {
private NameMappers() {}

public static final String STATIC_NAME = "static";

public static final String GAV_NAME = "gav";
Expand All @@ -34,6 +37,21 @@ public final class NameMappers {

public static final String FILE_HGAV_NAME = "file-hgav";

/**
* @since 1.9.25
*/
public static final String GAECV_NAME = "gaecv";

/**
* @since 1.9.25
*/
public static final String FILE_GAECV_NAME = "file-gaecv";

/**
* @since 1.9.25
*/
public static final String FILE_HGAECV_NAME = "file-hgaecv";

/**
* @since 1.9.6
*/
Expand All @@ -46,11 +64,47 @@ public static NameMapper staticNameMapper() {
}

public static NameMapper gavNameMapper() {
return GAVNameMapper.gav();
return gavNameMapper(false);
}

/**
* @since 1.9.25
*/
public static NameMapper gavNameMapper(boolean fileSystemFriendly) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @since

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if (fileSystemFriendly) {
return new GAVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
} else {
return new GAVNameMapper(false, "artifact:", "", "metadata:", "", ":");
}
}

/**
* @since 1.9.25
*/
public static NameMapper gaecvNameMapper() {
return gaecvNameMapper(false);
}

/**
* @since 1.9.25
*/
public static NameMapper gaecvNameMapper(boolean fileSystemFriendly) {
if (fileSystemFriendly) {
return new GAECVNameMapper(true, "artifact~", ".lock", "metadata~", ".lock", "~");
} else {
return new GAECVNameMapper(false, "artifact:", "", "metadata:", "", ":");
}
}

public static NameMapper fileGavNameMapper() {
return new BasedirNameMapper(GAVNameMapper.fileGav());
return new BasedirNameMapper(gavNameMapper(true));
}

/**
* @since 1.9.25
*/
public static NameMapper fileGaecvNameMapper() {
return new BasedirNameMapper(gaecvNameMapper(true));
}

/**
Expand All @@ -61,10 +115,17 @@ public static NameMapper fileStaticNameMapper() {
}

public static NameMapper fileHashingGavNameMapper() {
return new BasedirNameMapper(new HashingNameMapper(GAVNameMapper.gav()));
return new BasedirNameMapper(new HashingNameMapper(gavNameMapper(false)));
}

/**
* @since 1.9.25
*/
public static NameMapper fileHashingGaecvNameMapper() {
return new BasedirNameMapper(new HashingNameMapper(gaecvNameMapper(false)));
}

public static NameMapper discriminatingNameMapper() {
return new DiscriminatingNameMapper(GAVNameMapper.gav());
return new DiscriminatingNameMapper(gavNameMapper(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
public class NamedLockFactoryAdapterFactoryImpl implements NamedLockFactoryAdapterFactory, Service {
private static final String DEFAULT_FACTORY_NAME = LocalReadWriteLockNamedLockFactory.NAME;

private static final String DEFAULT_NAME_MAPPER_NAME = NameMappers.GAV_NAME;
private static final String DEFAULT_NAME_MAPPER_NAME = NameMappers.GAECV_NAME;

private static Map<String, NamedLockFactory> getManuallyCreatedFactories() {
HashMap<String, NamedLockFactory> factories = new HashMap<>();
Expand All @@ -75,9 +75,12 @@ private static Map<String, NameMapper> getManuallyCreatedNameMappers() {
HashMap<String, NameMapper> mappers = new HashMap<>();
mappers.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
mappers.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
mappers.put(NameMappers.GAECV_NAME, NameMappers.gaecvNameMapper());
mappers.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
mappers.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
mappers.put(NameMappers.FILE_GAECV_NAME, NameMappers.fileGaecvNameMapper());
mappers.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
mappers.put(NameMappers.FILE_HGAECV_NAME, NameMappers.fileHashingGaecvNameMapper());
return Collections.unmodifiableMap(mappers);
}

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-gaecv" name mapper provider.
*
* @since 1.9.25
*/
@Singleton
@Named(NameMappers.FILE_GAECV_NAME)
public class FileGAECVNameMapperProvider implements Provider<NameMapper> {
private final NameMapper mapper;

public FileGAECVNameMapperProvider() {
this.mapper = NameMappers.fileGaecvNameMapper();
}

@Override
public NameMapper get() {
return mapper;
}
}
Loading
Loading