Skip to content

Commit

Permalink
[MNG-8108] Fix problem when building the consumer pom (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored May 13, 2024
1 parent 583667a commit 9442164
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.maven.api.SessionData;
import org.apache.maven.api.model.Dependency;
import org.apache.maven.api.model.DependencyManagement;
import org.apache.maven.api.model.DistributionManagement;
Expand Down Expand Up @@ -65,6 +66,7 @@
import org.apache.maven.internal.impl.model.DefaultProfileSelector;
import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator;
import org.apache.maven.internal.impl.resolver.DefaultModelCache;
import org.apache.maven.internal.impl.resolver.DefaultModelRepositoryHolder;
import org.apache.maven.model.v4.MavenModelVersion;
import org.apache.maven.project.MavenProject;
import org.eclipse.aether.RepositorySystem;
Expand Down Expand Up @@ -196,13 +198,15 @@ public List<Profile> getActiveProfiles(
profileActivationFilePathInterpolator,
modelTransformer,
versionParser);
InternalSession iSession = InternalSession.from(session);
ModelBuilderRequest.ModelBuilderRequestBuilder request = ModelBuilderRequest.builder();
request.projectBuild(true);
request.session(InternalSession.from(session));
request.session(iSession);
request.source(ModelSource.fromPath(src));
request.validationLevel(ModelBuilderRequest.VALIDATION_LEVEL_MINIMAL);
request.locationTracking(false);
request.modelResolver(modelResolver);
request.modelRepositoryHolder(iSession.getData().get(SessionData.key(DefaultModelRepositoryHolder.class)));
request.transformerContextBuilder(modelBuilder.newTransformerContextBuilder());
request.systemProperties(session.getSystemProperties());
request.userProperties(session.getUserProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.maven.ProjectCycleException;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.api.Session;
import org.apache.maven.api.SessionData;
import org.apache.maven.api.feature.Features;
import org.apache.maven.api.model.*;
import org.apache.maven.api.services.ModelBuilder;
Expand Down Expand Up @@ -1041,13 +1042,15 @@ protected org.apache.maven.model.resolution.ModelResolver getResolver(
modelBuildingRequest.userProperties(toMap(request.getUserProperties()));
// bv4: modelBuildingRequest.setBuildStartTime(request.getBuildStartTime());
modelBuildingRequest.modelResolver(resolver);
modelBuildingRequest.modelRepositoryHolder(new DefaultModelRepositoryHolder(
DefaultModelRepositoryHolder holder = new DefaultModelRepositoryHolder(
internalSession,
DefaultModelRepositoryHolder.RepositoryMerging.valueOf(
request.getRepositoryMerging().name()),
repositories.stream()
.map(internalSession::getRemoteRepository)
.toList()));
.toList());
internalSession.getData().set(SessionData.key(DefaultModelRepositoryHolder.class), holder);
modelBuildingRequest.modelRepositoryHolder(holder);
modelBuildingRequest.modelCache(modelCache);
modelBuildingRequest.transformerContextBuilder(transformerContextBuilder);
/* TODO: bv4
Expand Down

0 comments on commit 9442164

Please sign in to comment.