From 1babfdc7862eb881426d5afd881e4d99519d5361 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 13 Dec 2024 12:43:07 +0100 Subject: [PATCH] [MRESOLVER-646] Move supplier to proper Maven4 classes WIP --- https://issues.apache.org/jira/browse/MRESOLVER-646 --- maven-resolver-supplier-mvn4/pom.xml | 43 +------- .../supplier/RepositorySystemSupplier.java | 98 +++++++++++++------ .../supplier/SessionBuilderSupplier.java | 9 +- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/maven-resolver-supplier-mvn4/pom.xml b/maven-resolver-supplier-mvn4/pom.xml index 10f2d602a..a7fccca99 100644 --- a/maven-resolver-supplier-mvn4/pom.xml +++ b/maven-resolver-supplier-mvn4/pom.xml @@ -74,49 +74,8 @@ org.apache.maven - maven-resolver-provider + maven-impl ${maven4Version} - - - javax.inject - javax.inject - - - org.eclipse.sisu - org.eclipse.sisu.inject - - - com.google.inject - guice - - - org.ow2.asm - asm - - - - - org.apache.maven - maven-model-builder - ${maven4Version} - - - javax.inject - javax.inject - - - jakarta.inject - jakarta.inject-api - - - org.eclipse.sisu - org.eclipse.sisu.inject - - - org.eclipse.sisu - org.eclipse.sisu.plexus - - diff --git a/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java b/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java index ca3f1ac65..e98478a87 100644 --- a/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java +++ b/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/RepositorySystemSupplier.java @@ -20,23 +20,50 @@ import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; -import org.apache.maven.model.building.DefaultModelBuilderFactory; -import org.apache.maven.model.building.ModelBuilder; -import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; -import org.apache.maven.repository.internal.DefaultModelCacheFactory; -import org.apache.maven.repository.internal.DefaultVersionRangeResolver; -import org.apache.maven.repository.internal.DefaultVersionResolver; -import org.apache.maven.repository.internal.MavenArtifactRelocationSource; -import org.apache.maven.repository.internal.ModelCacheFactory; -import org.apache.maven.repository.internal.PluginsMetadataGeneratorFactory; -import org.apache.maven.repository.internal.SnapshotMetadataGeneratorFactory; -import org.apache.maven.repository.internal.VersionsMetadataGeneratorFactory; -import org.apache.maven.repository.internal.relocation.DistributionManagementArtifactRelocationSource; -import org.apache.maven.repository.internal.relocation.UserPropertiesArtifactRelocationSource; +import org.apache.maven.api.services.Interpolator; +import org.apache.maven.api.services.ModelBuilder; +import org.apache.maven.api.services.model.ModelProcessor; +import org.apache.maven.api.services.model.PathTranslator; +import org.apache.maven.api.services.model.RootLocator; +import org.apache.maven.api.services.model.UrlNormalizer; +import org.apache.maven.internal.impl.DefaultModelUrlNormalizer; +import org.apache.maven.internal.impl.DefaultModelVersionParser; +import org.apache.maven.internal.impl.DefaultModelXmlFactory; +import org.apache.maven.internal.impl.DefaultPluginConfigurationExpander; +import org.apache.maven.internal.impl.DefaultSuperPomProvider; +import org.apache.maven.internal.impl.DefaultUrlNormalizer; +import org.apache.maven.internal.impl.model.DefaultDependencyManagementImporter; +import org.apache.maven.internal.impl.model.DefaultDependencyManagementInjector; +import org.apache.maven.internal.impl.model.DefaultInheritanceAssembler; +import org.apache.maven.internal.impl.model.DefaultInterpolator; +import org.apache.maven.internal.impl.model.DefaultModelBuilder; +import org.apache.maven.internal.impl.model.DefaultModelCacheFactory; +import org.apache.maven.internal.impl.model.DefaultModelInterpolator; +import org.apache.maven.internal.impl.model.DefaultModelNormalizer; +import org.apache.maven.internal.impl.model.DefaultModelPathTranslator; +import org.apache.maven.internal.impl.model.DefaultModelProcessor; +import org.apache.maven.internal.impl.model.DefaultModelValidator; +import org.apache.maven.internal.impl.model.DefaultPathTranslator; +import org.apache.maven.internal.impl.model.DefaultPluginManagementInjector; +import org.apache.maven.internal.impl.model.DefaultProfileInjector; +import org.apache.maven.internal.impl.model.DefaultProfileSelector; +import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator; +import org.apache.maven.internal.impl.model.rootlocator.DefaultRootLocator; +import org.apache.maven.internal.impl.resolver.DefaultArtifactDescriptorReader; +import org.apache.maven.internal.impl.resolver.DefaultModelResolver; +import org.apache.maven.internal.impl.resolver.DefaultVersionRangeResolver; +import org.apache.maven.internal.impl.resolver.DefaultVersionResolver; +import org.apache.maven.internal.impl.resolver.MavenArtifactRelocationSource; +import org.apache.maven.internal.impl.resolver.PluginsMetadataGeneratorFactory; +import org.apache.maven.internal.impl.resolver.SnapshotMetadataGeneratorFactory; +import org.apache.maven.internal.impl.resolver.VersionsMetadataGeneratorFactory; +import org.apache.maven.internal.impl.resolver.relocation.DistributionManagementArtifactRelocationSource; +import org.apache.maven.internal.impl.resolver.relocation.UserPropertiesArtifactRelocationSource; import org.eclipse.aether.RepositoryListener; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; @@ -984,13 +1011,10 @@ public final ArtifactDescriptorReader getArtifactDescriptorReader() { protected ArtifactDescriptorReader createArtifactDescriptorReader() { // from maven-resolver-provider return new DefaultArtifactDescriptorReader( - getRemoteRepositoryManager(), getVersionResolver(), - getVersionRangeResolver(), getArtifactResolver(), getModelBuilder(), getRepositoryEventDispatcher(), - getModelCacheFactory(), getMavenArtifactRelocationSources()); } @@ -1038,22 +1062,32 @@ public final ModelBuilder getModelBuilder() { protected ModelBuilder createModelBuilder() { // from maven-model-builder - return new DefaultModelBuilderFactory().newInstance(); - } - - private ModelCacheFactory modelCacheFactory; - - public final ModelCacheFactory getModelCacheFactory() { - checkClosed(); - if (modelCacheFactory == null) { - modelCacheFactory = createModelCacheFactory(); - } - return modelCacheFactory; - } - - protected ModelCacheFactory createModelCacheFactory() { - // from maven-resolver-provider - return new DefaultModelCacheFactory(); + ModelProcessor modelProcessor = new DefaultModelProcessor(new DefaultModelXmlFactory(), List.of()); + PathTranslator pathTranslator = new DefaultPathTranslator(); + UrlNormalizer urlNormalizer = new DefaultUrlNormalizer(); + RootLocator rootLocator = new DefaultRootLocator(); + Interpolator interpolator = new DefaultInterpolator(); + return new DefaultModelBuilder( + modelProcessor, + new DefaultModelValidator(), + new DefaultModelNormalizer(), + new DefaultModelInterpolator(pathTranslator, urlNormalizer, rootLocator, interpolator), + new DefaultModelPathTranslator(pathTranslator), + new DefaultModelUrlNormalizer(urlNormalizer), + new DefaultSuperPomProvider(modelProcessor), + new DefaultInheritanceAssembler(), + new DefaultProfileSelector(), + new DefaultProfileInjector(), + new DefaultPluginManagementInjector(), + new DefaultDependencyManagementInjector(), + new DefaultDependencyManagementImporter(), + new DefaultPluginConfigurationExpander(), + new ProfileActivationFilePathInterpolator(pathTranslator, rootLocator, interpolator), + new DefaultModelVersionParser(getVersionScheme()), + List.of(), + new DefaultModelCacheFactory(), + new DefaultModelResolver(), + new DefaultInterpolator()); } private RepositorySystem repositorySystem; diff --git a/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java b/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java index 2d6a935e1..cc741b67d 100644 --- a/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java +++ b/maven-resolver-supplier-mvn4/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java @@ -20,7 +20,8 @@ import java.util.function.Supplier; -import org.apache.maven.repository.internal.MavenSessionBuilderSupplier; +import org.apache.maven.api.ProtoSession; +import org.apache.maven.internal.impl.resolver.MavenSessionBuilderSupplier; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession.CloseableSession; import org.eclipse.aether.RepositorySystemSession.SessionBuilder; @@ -38,4 +39,10 @@ public class SessionBuilderSupplier extends MavenSessionBuilderSupplier { public SessionBuilderSupplier(RepositorySystem repositorySystem) { super(repositorySystem); } + + @Override + public SessionBuilder get() { + + return super.get(); + } }