mirror of https://github.com/apache/maven.git
[MNG-8108] Fix problem when building the consumer pom
This commit is contained in:
parent
d296927de2
commit
bde81a4d85
|
@ -66,7 +66,6 @@ import org.apache.maven.internal.impl.model.DefaultModelBuilder;
|
||||||
import org.apache.maven.internal.impl.model.DefaultProfileSelector;
|
import org.apache.maven.internal.impl.model.DefaultProfileSelector;
|
||||||
import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator;
|
import org.apache.maven.internal.impl.model.ProfileActivationFilePathInterpolator;
|
||||||
import org.apache.maven.internal.impl.resolver.DefaultModelCache;
|
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.model.v4.MavenModelVersion;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.eclipse.aether.RepositorySystem;
|
import org.eclipse.aether.RepositorySystem;
|
||||||
|
@ -139,9 +138,6 @@ class DefaultConsumerPomBuilder implements ConsumerPomBuilder {
|
||||||
@Inject
|
@Inject
|
||||||
private ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator;
|
private ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ModelResolver modelResolver;
|
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(getClass());
|
Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,8 +201,7 @@ class DefaultConsumerPomBuilder implements ConsumerPomBuilder {
|
||||||
request.source(ModelSource.fromPath(src));
|
request.source(ModelSource.fromPath(src));
|
||||||
request.validationLevel(ModelBuilderRequest.VALIDATION_LEVEL_MINIMAL);
|
request.validationLevel(ModelBuilderRequest.VALIDATION_LEVEL_MINIMAL);
|
||||||
request.locationTracking(false);
|
request.locationTracking(false);
|
||||||
request.modelResolver(modelResolver);
|
request.modelResolver(iSession.getData().get(SessionData.key(ModelResolver.class)));
|
||||||
request.modelRepositoryHolder(iSession.getData().get(SessionData.key(DefaultModelRepositoryHolder.class)));
|
|
||||||
request.transformerContextBuilder(modelBuilder.newTransformerContextBuilder());
|
request.transformerContextBuilder(modelBuilder.newTransformerContextBuilder());
|
||||||
request.systemProperties(session.getSystemProperties());
|
request.systemProperties(session.getSystemProperties());
|
||||||
request.userProperties(session.getUserProperties());
|
request.userProperties(session.getUserProperties());
|
||||||
|
|
|
@ -282,6 +282,7 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
private final ModelTransformerContextBuilder transformerContextBuilder;
|
private final ModelTransformerContextBuilder transformerContextBuilder;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
private final ModelCache modelCache;
|
private final ModelCache modelCache;
|
||||||
|
private final ModelResolver modelResolver;
|
||||||
|
|
||||||
BuildSession(ProjectBuildingRequest request, boolean localProjects) {
|
BuildSession(ProjectBuildingRequest request, boolean localProjects) {
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
@ -299,6 +300,21 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
}
|
}
|
||||||
this.parentCache = new ConcurrentHashMap<>();
|
this.parentCache = new ConcurrentHashMap<>();
|
||||||
this.modelCache = DefaultModelCache.newInstance(session, true);
|
this.modelCache = DefaultModelCache.newInstance(session, true);
|
||||||
|
this.modelResolver = new ModelResolverWrapper() {
|
||||||
|
@Override
|
||||||
|
protected org.apache.maven.model.resolution.ModelResolver getResolver(
|
||||||
|
List<RemoteRepository> repositories) {
|
||||||
|
return new ProjectModelResolver(
|
||||||
|
session,
|
||||||
|
RequestTrace.newChild(null, request),
|
||||||
|
repoSystem,
|
||||||
|
repositoryManager,
|
||||||
|
repositories,
|
||||||
|
request.getRepositoryMerging(),
|
||||||
|
modelPool,
|
||||||
|
parentCache);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorService createExecutor(int parallelism) {
|
ExecutorService createExecutor(int parallelism) {
|
||||||
|
@ -1006,24 +1022,6 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
private ModelBuilderRequest.ModelBuilderRequestBuilder getModelBuildingRequest() {
|
private ModelBuilderRequest.ModelBuilderRequestBuilder getModelBuildingRequest() {
|
||||||
ModelBuilderRequest.ModelBuilderRequestBuilder modelBuildingRequest = ModelBuilderRequest.builder();
|
ModelBuilderRequest.ModelBuilderRequestBuilder modelBuildingRequest = ModelBuilderRequest.builder();
|
||||||
|
|
||||||
RequestTrace trace = RequestTrace.newChild(null, request).newChild(modelBuildingRequest);
|
|
||||||
|
|
||||||
ModelResolver resolver = new ModelResolverWrapper() {
|
|
||||||
@Override
|
|
||||||
protected org.apache.maven.model.resolution.ModelResolver getResolver(
|
|
||||||
List<RemoteRepository> repositories) {
|
|
||||||
return new ProjectModelResolver(
|
|
||||||
session,
|
|
||||||
trace,
|
|
||||||
repoSystem,
|
|
||||||
repositoryManager,
|
|
||||||
repositories,
|
|
||||||
request.getRepositoryMerging(),
|
|
||||||
modelPool,
|
|
||||||
parentCache);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
InternalSession internalSession = InternalSession.from(session);
|
InternalSession internalSession = InternalSession.from(session);
|
||||||
modelBuildingRequest.session(internalSession.withRemoteRepositories(request.getRemoteRepositories().stream()
|
modelBuildingRequest.session(internalSession.withRemoteRepositories(request.getRemoteRepositories().stream()
|
||||||
.map(r -> internalSession.getRemoteRepository(RepositoryUtils.toRepo(r)))
|
.map(r -> internalSession.getRemoteRepository(RepositoryUtils.toRepo(r)))
|
||||||
|
@ -1041,7 +1039,7 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
modelBuildingRequest.systemProperties(toMap(request.getSystemProperties()));
|
modelBuildingRequest.systemProperties(toMap(request.getSystemProperties()));
|
||||||
modelBuildingRequest.userProperties(toMap(request.getUserProperties()));
|
modelBuildingRequest.userProperties(toMap(request.getUserProperties()));
|
||||||
// bv4: modelBuildingRequest.setBuildStartTime(request.getBuildStartTime());
|
// bv4: modelBuildingRequest.setBuildStartTime(request.getBuildStartTime());
|
||||||
modelBuildingRequest.modelResolver(resolver);
|
modelBuildingRequest.modelResolver(modelResolver);
|
||||||
DefaultModelRepositoryHolder holder = new DefaultModelRepositoryHolder(
|
DefaultModelRepositoryHolder holder = new DefaultModelRepositoryHolder(
|
||||||
internalSession,
|
internalSession,
|
||||||
DefaultModelRepositoryHolder.RepositoryMerging.valueOf(
|
DefaultModelRepositoryHolder.RepositoryMerging.valueOf(
|
||||||
|
@ -1049,7 +1047,6 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
repositories.stream()
|
repositories.stream()
|
||||||
.map(internalSession::getRemoteRepository)
|
.map(internalSession::getRemoteRepository)
|
||||||
.toList());
|
.toList());
|
||||||
internalSession.getData().set(SessionData.key(DefaultModelRepositoryHolder.class), holder);
|
|
||||||
modelBuildingRequest.modelRepositoryHolder(holder);
|
modelBuildingRequest.modelRepositoryHolder(holder);
|
||||||
modelBuildingRequest.modelCache(modelCache);
|
modelBuildingRequest.modelCache(modelCache);
|
||||||
modelBuildingRequest.transformerContextBuilder(transformerContextBuilder);
|
modelBuildingRequest.transformerContextBuilder(transformerContextBuilder);
|
||||||
|
@ -1064,6 +1061,7 @@ public class DefaultProjectBuilder implements ProjectBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
internalSession.getData().set(SessionData.key(ModelResolver.class), modelResolver);
|
||||||
|
|
||||||
return modelBuildingRequest;
|
return modelBuildingRequest;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue