Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRESOLVER-646] Move supplier to proper Maven4 classes #625

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
43 changes: 1 addition & 42 deletions maven-resolver-supplier-mvn4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,8 @@

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-resolver-provider</artifactId>
<artifactId>maven-impl</artifactId>
<version>${maven4Version}</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
<version>${maven4Version}</version>
<exclusions>
<exclusion>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,4 +39,10 @@ public class SessionBuilderSupplier extends MavenSessionBuilderSupplier {
public SessionBuilderSupplier(RepositorySystem repositorySystem) {
super(repositorySystem);
}

@Override
public SessionBuilder get() {

return super.get();
}
}
Loading