From 51123f3abcedbf7e56228699ab1880543218a4ba Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 5 Nov 2024 17:00:23 +0100 Subject: [PATCH] Remove unused class (#1866) --- .../impl/ConsumerPomBuilderTest.java | 49 +------------------ .../api/services/model/ModelCacheFactory.java | 1 - 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java b/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java index 6e3d7ae56b..510d5d6196 100644 --- a/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java +++ b/impl/maven-core/src/test/java/org/apache/maven/internal/transformation/impl/ConsumerPomBuilderTest.java @@ -22,7 +22,6 @@ import javax.inject.Inject; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.List; import java.util.function.Consumer; @@ -30,14 +29,11 @@ import org.apache.maven.api.RemoteRepository; import org.apache.maven.api.Session; import org.apache.maven.api.SessionData; import org.apache.maven.api.model.Model; -import org.apache.maven.api.model.Parent; import org.apache.maven.api.services.ModelBuilder; import org.apache.maven.api.services.ModelBuilderRequest; import org.apache.maven.api.services.ModelSource; import org.apache.maven.api.services.model.ModelResolver; import org.apache.maven.api.services.model.ModelResolverException; -import org.apache.maven.api.spi.ModelTransformer; -import org.apache.maven.api.spi.ModelTransformerException; import org.apache.maven.di.Injector; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.internal.impl.InternalMavenSession; @@ -60,15 +56,7 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase { @BeforeEach void setupTransformerContext() throws Exception { - // We need to hack things a bit here to get the transformer context to work - // * we cannot use the CIFriendlyVersionModelTransformer directly because - // it's a session scoped bean and all tests using a model builder would have - // to use a session and initialize the scope in order for DI to start - // * the transformer context is supposed to be immutable but in this case - // we don't build the full projects before, so we need to pass a mutable - // context to the model builder - // * we also need to bind the model resolver explicitly to avoid going - // to maven central + // We need bind the model resolver explicitly to avoid going to maven central getContainer().lookup(Injector.class).bindImplicit(MyModelResolver.class); InternalSession iSession = InternalSession.from(session); // set up the model resolver @@ -150,39 +138,4 @@ public class ConsumerPomBuilderTest extends AbstractRepositoryTestCase { return null; } } - - static class CIFriendlyVersionModelTransformer implements ModelTransformer { - private static final String SHA1_PROPERTY = "sha1"; - private static final String CHANGELIST_PROPERTY = "changelist"; - private static final String REVISION_PROPERTY = "revision"; - private final Session session; - - CIFriendlyVersionModelTransformer(Session session) { - this.session = session; - } - - @Override - public Model transformFileModel(Model model) throws ModelTransformerException { - return model.with() - .version(replaceCiFriendlyVersion(model.getVersion())) - .parent(replaceParent(model.getParent())) - .build(); - } - - Parent replaceParent(Parent parent) { - return parent != null ? parent.withVersion(replaceCiFriendlyVersion(parent.getVersion())) : null; - } - - String replaceCiFriendlyVersion(String version) { - if (version != null) { - for (String key : Arrays.asList(SHA1_PROPERTY, CHANGELIST_PROPERTY, REVISION_PROPERTY)) { - String val = session.getUserProperties().get(key); - if (val != null) { - version = version.replace("${" + key + "}", val); - } - } - } - return version; - } - } } diff --git a/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelCacheFactory.java b/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelCacheFactory.java index 3c8c9be789..340121d21f 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelCacheFactory.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/api/services/model/ModelCacheFactory.java @@ -29,7 +29,6 @@ import org.apache.maven.api.annotations.Nonnull; *

* The cache implementation could be annotated with {@code SessionScoped} to be created once per session, but * this would make tests more complicated to write as they would all need to enter the session scope. - * This is similar to the {@code CIFriendlyVersionModelTransformer}. * * @since 4.0.0 */