use of org.apache.maven.project.ProjectBuildingRequest in project karaf by apache.
the class GenerateDescriptorMojo method resolveProject.
private MavenProject resolveProject(final Object artifact) throws MojoExecutionException {
MavenProject resolvedProject = project;
if (includeTransitiveVersionRanges) {
resolvedProject = resolvedProjects.get(artifact);
if (resolvedProject == null) {
final ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
// Fixes KARAF-4626; if the system properties are not transferred to the request,
// test-feature-use-version-range-transfer-properties will fail
request.setSystemProperties(System.getProperties());
request.setResolveDependencies(true);
request.setRemoteRepositories(project.getPluginArtifactRepositories());
request.setLocalRepository(localRepo);
request.setProfiles(new ArrayList<>(mavenSession.getRequest().getProfiles()));
request.setActiveProfileIds(new ArrayList<>(mavenSession.getRequest().getActiveProfiles()));
dependencyHelper.setRepositorySession(request);
final Artifact pomArtifact = repoSystem.createArtifact(dependencyHelper.getGroupId(artifact), dependencyHelper.getArtifactId(artifact), dependencyHelper.getBaseVersion(artifact), "pom");
try {
resolvedProject = mavenProjectBuilder.build(pomArtifact, request).getProject();
resolvedProjects.put(pomArtifact, resolvedProject);
} catch (final ProjectBuildingException e) {
throw new MojoExecutionException(format("Maven-project could not be built for artifact %s", pomArtifact), e);
}
}
}
return resolvedProject;
}
Aggregations