Search in sources :

Example 6 with BuildFailureException

use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testExtraRequirementMissingVersionRange.

@Test
public void testExtraRequirementMissingVersionRange() throws Exception {
    Xpp3Dom dom = createConfigurationDom("type", "id");
    try {
        configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("Element <versionRange> is missing in <extraRequirements><requirement> section."));
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 7 with BuildFailureException

use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testAddTargetWithMissingVersionInTargetDefinition.

@Test
public void testAddTargetWithMissingVersionInTargetDefinition() {
    Xpp3Dom dom = createGavConfiguration("myGroupId", "myArtifactId", null);
    MavenSession session = setupMockSession();
    TargetPlatformConfiguration configuration = new TargetPlatformConfiguration();
    try {
        configurationReader.addTargetArtifact(configuration, session, null, dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("The target artifact configuration is invalid"));
    }
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 8 with BuildFailureException

use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReaderTest method testExtraRequirementMissingType.

@Test
public void testExtraRequirementMissingType() throws Exception {
    Xpp3Dom dom = createConfigurationDom("id", "versionRange");
    try {
        configurationReader.readExtraRequirements(new TargetPlatformConfiguration(), dom);
        fail();
    } catch (BuildFailureException e) {
        assertTrue(e.getMessage().contains("Element <type> is missing in <extraRequirements><requirement> section."));
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Test(org.junit.Test)

Example 9 with BuildFailureException

use of org.eclipse.tycho.core.shared.BuildFailureException 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 10 with BuildFailureException

use of org.eclipse.tycho.core.shared.BuildFailureException in project tycho by eclipse.

the class DefaultTargetPlatformConfigurationReader method readExtraRequirements.

protected void readExtraRequirements(TargetPlatformConfiguration result, Xpp3Dom resolverDom) throws BuildFailureException {
    Xpp3Dom requirementsDom = resolverDom.getChild("extraRequirements");
    if (requirementsDom == null) {
        return;
    }
    for (Xpp3Dom requirementDom : requirementsDom.getChildren("requirement")) {
        Dependency d = new Dependency();
        if (requirementDom.getChild("type") == null) {
            throw new BuildFailureException("Element <type> is missing in <extraRequirements><requirement> section.");
        }
        if (requirementDom.getChild("id") == null) {
            throw new BuildFailureException("Element <id> is missing in <extraRequirements><requirement> section.");
        }
        if (requirementDom.getChild("versionRange") == null) {
            throw new BuildFailureException("Element <versionRange> is missing in <extraRequirements><requirement> section.");
        }
        d.setType(requirementDom.getChild("type").getValue());
        d.setArtifactId(requirementDom.getChild("id").getValue());
        d.setVersion(requirementDom.getChild("versionRange").getValue());
        result.addExtraRequirement(d);
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) Dependency(org.apache.maven.model.Dependency)

Aggregations

BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)10 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)8 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)6 Test (org.junit.Test)6 MavenSession (org.apache.maven.execution.MavenSession)3 File (java.io.File)2 Dependency (org.apache.maven.model.Dependency)2 MavenProject (org.apache.maven.project.MavenProject)2 ReactorProject (org.eclipse.tycho.ReactorProject)2 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 MavenExecutionException (org.apache.maven.MavenExecutionException)1 Artifact (org.apache.maven.artifact.Artifact)1 ArtifactResolutionRequest (org.apache.maven.artifact.resolver.ArtifactResolutionRequest)1 ComponentDependency (org.codehaus.plexus.component.repository.ComponentDependency)1 IllegalArtifactReferenceException (org.eclipse.tycho.artifacts.IllegalArtifactReferenceException)1 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)1 MultiEnvironmentDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1