use of org.apache.maven.project.ProjectBuildingException in project che by eclipse.
the class MavenServerImpl method validate.
private void validate(File pom, List<Exception> exceptions, List<MavenProjectProblem> problems) throws RemoteException {
for (Throwable exception : exceptions) {
if (exception instanceof IllegalStateException && exception.getCause() != null) {
exception = exception.getCause();
}
if (exception instanceof InvalidProjectModelException) {
ModelValidationResult validationResult = ((InvalidProjectModelException) exception).getValidationResult();
if (validationResult != null) {
problems.addAll(validationResult.getMessages().stream().map(s -> MavenProjectProblem.newStructureProblem(pom.getPath(), s)).collect(Collectors.toList()));
} else {
problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), exception.getCause().getMessage()));
}
}
if (exception instanceof ProjectBuildingException) {
String message = exception.getCause() == null ? exception.getMessage() : exception.getCause().getMessage();
problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), message));
} else {
MavenServerContext.getLogger().info(exception);
problems.add(MavenProjectProblem.newStructureProblem(pom.getPath(), exception.getMessage()));
}
}
}
use of org.apache.maven.project.ProjectBuildingException in project asterixdb by apache.
the class GenerateFileMojo method execute.
@java.lang.Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
init();
readExtraMaps();
addDependenciesToLicenseMap();
resolveLicenseContent();
resolveNoticeFiles();
resolveLicenseFiles();
rebuildLicenseContentProjectMap();
combineCommonGavs();
SourcePointerResolver.execute(this);
persistLicenseMap();
buildNoticeProjectMap();
generateFiles();
} catch (IOException | TemplateException | ProjectBuildingException e) {
throw new MojoExecutionException("Unexpected exception: " + e, e);
}
}
use of org.apache.maven.project.ProjectBuildingException in project asterixdb by apache.
the class LicenseMojo method resolveDependency.
protected MavenProject resolveDependency(Artifact depObj) throws ProjectBuildingException {
String key = depObj.getGroupId() + ":" + depObj.getArtifactId() + ":" + depObj.getVersion();
MavenProject depProj = projectCache.get(key);
if (depProj == null) {
try {
depProj = projectBuilder.buildFromRepository(depObj, remoteRepositories, localRepository, false);
} catch (ProjectBuildingException e) {
throw new ProjectBuildingException(key, "Error creating dependent artifacts", e);
}
Model supplement = supplementModels.get(SupplementalModelHelper.generateSupplementMapKey(depObj.getGroupId(), depObj.getArtifactId()));
if (supplement != null) {
Model merged = SupplementalModelHelper.mergeModels(assembler, depProj.getModel(), supplement);
Set<String> origLicenses = depProj.getModel().getLicenses().stream().map(License::getUrl).collect(Collectors.toSet());
Set<String> newLicenses = merged.getLicenses().stream().map(License::getUrl).collect(Collectors.toSet());
if (!origLicenses.equals(newLicenses)) {
getLog().warn("license list for " + toGav(depProj) + " changed with supplemental model; was: " + origLicenses + ", now: " + newLicenses);
}
depProj = new MavenProject(merged);
depProj.setArtifact(depObj);
depProj.setVersion(depObj.getVersion());
}
depProj.getArtifact().setScope(depObj.getScope());
projectCache.put(key, depProj);
}
return depProj;
}
use of org.apache.maven.project.ProjectBuildingException in project asterixdb by apache.
the class DownloadLicensesMojo method execute.
@java.lang.Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
init();
addDependenciesToLicenseMap();
final int timeoutMillis = (int) TimeUnit.SECONDS.toMillis(timeoutSecs);
//noinspection ResultOfMethodCallIgnored
downloadDir.mkdirs();
AtomicInteger counter = new AtomicInteger();
getLicenseMap().values().parallelStream().forEach(entry -> {
final int i = counter.incrementAndGet();
final String url = entry.getLicense().getUrl();
String fileName = entry.getLicense().getContentFile(false);
doDownload(timeoutMillis, i, url, fileName);
});
} catch (IOException | ProjectBuildingException e) {
throw new MojoExecutionException("Unexpected exception: " + e, e);
}
}
use of org.apache.maven.project.ProjectBuildingException in project karaf by apache.
the class MojoSupport method createManagedVersionMap.
protected Map createManagedVersionMap(String projectId, DependencyManagement dependencyManagement) throws ProjectBuildingException {
Map map;
if (dependencyManagement != null && dependencyManagement.getDependencies() != null) {
map = new HashMap();
for (Dependency d : dependencyManagement.getDependencies()) {
try {
VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
Artifact artifact = factory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope());
map.put(d.getManagementKey(), artifact);
} catch (InvalidVersionSpecificationException e) {
throw new ProjectBuildingException(projectId, "Unable to parse version '" + d.getVersion() + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e);
}
}
} else {
map = Collections.EMPTY_MAP;
}
return map;
}
Aggregations