use of org.apache.maven.MavenExecutionException in project tycho by eclipse.
the class TychoMavenLifecycleParticipant method afterProjectsRead.
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
try {
if (disableLifecycleParticipation(session)) {
return;
}
List<MavenProject> projects = session.getProjects();
validate(projects);
// setting this system property to let EF figure out where the traffic
// is coming from (#467418)
System.setProperty(P2_USER_AGENT_KEY, P2_USER_AGENT_VALUE + TychoVersion.getTychoVersion());
configureComponents(session);
for (MavenProject project : projects) {
resolver.setupProject(session, project, DefaultReactorProject.adapt(project));
}
List<ReactorProject> reactorProjects = DefaultReactorProject.adapt(session);
for (MavenProject project : projects) {
resolver.resolveProject(session, project, reactorProjects);
}
} catch (BuildFailureException e) {
// trace by wrapping it in MavenExecutionException
throw new MavenExecutionException(e.getMessage(), e);
}
}
use of org.apache.maven.MavenExecutionException in project tycho by eclipse.
the class TychoOsgiRuntimeLocator method addRuntimeArtifact.
private void addRuntimeArtifact(EquinoxRuntimeDescription description, MavenSession session, Dependency dependency) throws MavenExecutionException {
Artifact artifact = resolveDependency(session, dependency);
if ("zip".equals(dependency.getType())) {
File artifactFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepository().pathOf(artifact));
File eclipseDir = new File(artifactFile.getParentFile(), "eclipse");
FileLocker locker = fileLockService.getFileLocker(artifactFile);
locker.lock();
try {
if (!eclipseDir.exists() || artifact.isSnapshot()) {
logger.debug("Extracting Tycho's OSGi runtime");
if (artifact.getFile().lastModified() > eclipseDir.lastModified()) {
logger.debug("Unpacking Tycho's OSGi runtime to " + eclipseDir);
try {
FileUtils.deleteDirectory(eclipseDir);
} catch (IOException e) {
logger.warn("Failed to delete Tycho's OSGi runtime " + eclipseDir + ": " + e.getMessage());
}
unArchiver.setSourceFile(artifact.getFile());
unArchiver.setDestDirectory(eclipseDir.getParentFile());
try {
unArchiver.extract();
} catch (ArchiverException e) {
throw new MavenExecutionException("Failed to unpack Tycho's OSGi runtime: " + e.getMessage(), e);
}
eclipseDir.setLastModified(artifact.getFile().lastModified());
}
}
} finally {
locker.release();
}
description.addInstallation(eclipseDir);
} else {
description.addBundle(artifact.getFile());
}
}
use of org.apache.maven.MavenExecutionException in project tycho by eclipse.
the class TychoOsgiRuntimeLocator method resolveDependency.
public Artifact resolveDependency(MavenSession session, Dependency dependency) throws MavenExecutionException {
Artifact artifact = repositorySystem.createArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getType());
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setResolveRoot(true).setResolveTransitively(false);
request.setLocalRepository(session.getLocalRepository());
request.setRemoteRepositories(getPluginRepositories(session));
request.setCache(session.getRepositoryCache());
request.setOffline(session.isOffline());
request.setProxies(session.getSettings().getProxies());
request.setForceUpdate(session.getRequest().isUpdateSnapshots());
ArtifactResolutionResult result = repositorySystem.resolve(request);
try {
resolutionErrorHandler.throwErrors(request, result);
} catch (ArtifactResolutionException e) {
throw new MavenExecutionException("Could not resolve artifact for Tycho's OSGi runtime", e);
}
return artifact;
}
Aggregations