Search in sources :

Example 16 with MavenExecutionException

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);
    }
}
Also used : MavenExecutionException(org.apache.maven.MavenExecutionException) MavenProject(org.apache.maven.project.MavenProject) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject)

Example 17 with MavenExecutionException

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());
    }
}
Also used : FileLocker(org.eclipse.tycho.locking.facade.FileLocker) MavenExecutionException(org.apache.maven.MavenExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) IOException(java.io.IOException) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 18 with MavenExecutionException

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;
}
Also used : ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) MavenExecutionException(org.apache.maven.MavenExecutionException) ArtifactResolutionRequest(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) ArtifactResolutionResult(org.apache.maven.artifact.resolver.ArtifactResolutionResult) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

MavenExecutionException (org.apache.maven.MavenExecutionException)18 IOException (java.io.IOException)8 File (java.io.File)7 Artifact (org.apache.maven.artifact.Artifact)6 Model (org.apache.sling.provisioning.model.Model)5 Feature (org.apache.sling.provisioning.model.Feature)4 Traceable (org.apache.sling.provisioning.model.Traceable)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MavenProject (org.apache.maven.project.MavenProject)3 ArtifactGroup (org.apache.sling.provisioning.model.ArtifactGroup)3 RunMode (org.apache.sling.provisioning.model.RunMode)3 FileReader (java.io.FileReader)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 AbstractMavenLifecycleParticipant (org.apache.maven.AbstractMavenLifecycleParticipant)2 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)2 MavenSession (org.apache.maven.execution.MavenSession)2 Plugin (org.apache.maven.model.Plugin)2