use of org.apache.maven.MavenExecutionException in project che by eclipse.
the class MavenServerImpl method loadExtensions.
private void loadExtensions(MavenProject project, List<Exception> exceptions) {
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
Collection<AbstractMavenLifecycleParticipant> participants = getLifecycleParticipants(Collections.singletonList(project));
if (!participants.isEmpty()) {
LegacySupport legacySupport = getMavenComponent(LegacySupport.class);
MavenSession session = legacySupport.getSession();
session.setCurrentProject(project);
session.setProjects(Collections.singletonList(project));
for (AbstractMavenLifecycleParticipant participant : participants) {
Thread.currentThread().setContextClassLoader(participant.getClass().getClassLoader());
try {
participant.afterProjectsRead(session);
} catch (MavenExecutionException e) {
exceptions.add(e);
} finally {
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
}
}
use of org.apache.maven.MavenExecutionException in project sling by apache.
the class LaunchpadPluginLifecycleParticipant method afterProjectsRead.
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
try {
Map<String, MavenProject> projectMap = new HashMap<String, MavenProject>();
for (MavenProject project : session.getProjects()) {
projectMap.put(project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(), project);
}
for (MavenProject project : session.getProjects()) {
for (Plugin plugin : project.getBuild().getPlugins()) {
if (plugin.getArtifactId().equals(PLUGIN_ID)) {
BundleListDependencyAdder performer = new BundleListDependencyAdder(session, project, plugin);
performer.addDependencies();
}
}
}
} catch (Exception e) {
throw new MavenExecutionException("Unable to determine launchpad plugin-based dependencies", e);
}
super.afterProjectsRead(session);
}
use of org.apache.maven.MavenExecutionException in project sling by apache.
the class PreparePackageMojo method getBaseArtifact.
/**
* Return the base artifact
*/
private Artifact getBaseArtifact(final Model model, final String classifier, final String type) throws MojoExecutionException {
try {
final org.apache.sling.provisioning.model.Artifact baseArtifact = ModelUtils.findBaseArtifact(model);
final Artifact a = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver, baseArtifact.getGroupId(), baseArtifact.getArtifactId(), baseArtifact.getVersion(), type, classifier);
if (a == null) {
throw new MojoExecutionException(String.format("Project doesn't have a base dependency of groupId %s and artifactId %s", baseArtifact.getGroupId(), baseArtifact.getArtifactId()));
}
return a;
} catch (final MavenExecutionException mee) {
throw new MojoExecutionException(mee.getMessage(), mee.getCause());
}
}
use of org.apache.maven.MavenExecutionException in project sling by apache.
the class ModelPreprocessor method processAttachments.
private void processAttachments(final Environment env, final ProjectInfo info) throws MavenExecutionException {
final Xpp3Dom config = info.plugin == null ? null : (Xpp3Dom) info.plugin.getConfiguration();
final Xpp3Dom[] nodes = (config == null ? null : config.getChildren("attach"));
if (nodes != null) {
for (final Xpp3Dom node : nodes) {
final String type = nodeValue(node, "type", null);
if (type == null) {
throw new MavenExecutionException("Attachment for provisioning model has no type.", (File) null);
}
final String classifier = nodeValue(node, "classifier", null);
final String featureName = nodeValue(node, "feature", null);
int startLevel = 0;
final String level = nodeValue(node, "startLevel", null);
if (level != null) {
startLevel = Integer.valueOf(level);
}
final Feature f;
if (featureName != null) {
f = info.localModel.getFeature(featureName);
} else if (info.localModel.getFeatures().isEmpty()) {
f = null;
} else {
f = info.localModel.getFeatures().get(0);
}
if (f == null) {
if (featureName == null) {
throw new MavenExecutionException("No feature found in provisioning model for attachment.", (File) null);
}
throw new MavenExecutionException("Feature with name '" + featureName + "' not found in provisioning model for attachment.", (File) null);
}
final RunMode runMode = f.getOrCreateRunMode(null);
final ArtifactGroup group = runMode.getOrCreateArtifactGroup(startLevel);
final org.apache.sling.provisioning.model.Artifact artifact = new org.apache.sling.provisioning.model.Artifact(info.project.getGroupId(), info.project.getArtifactId(), info.project.getVersion(), classifier, type);
env.logger.debug("Attaching " + artifact + " to feature " + f.getName());
group.add(artifact);
}
}
}
use of org.apache.maven.MavenExecutionException in project tycho by eclipse.
the class WorkspaceTychoOsgiRuntimeLocator method addPlatformProperties.
public void addPlatformProperties(EquinoxRuntimeDescription result) throws MavenExecutionException {
result.addPlatformProperty("osgi.install.area", stateLocation.getAbsolutePath());
File devproperties = new File(stateLocation, "dev.properties");
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(devproperties));
try {
deventries.store(os, null);
} finally {
IOUtil.close(os);
}
result.addPlatformProperty("osgi.dev", devproperties.toURI().toURL().toExternalForm());
} catch (IOException e) {
throw new MavenExecutionException("Could not write dev.properties", e);
}
}
Aggregations