Search in sources :

Example 1 with IU

use of org.eclipse.tycho.model.IU in project tycho by eclipse.

the class P2iuXmlManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    if (!isIu(project)) {
        return;
    }
    IU iu = getIU(project);
    VersionChange change = versionChangeContext.findVersionChangeByArtifactId(iu.getId());
    if (change != null && change.getVersion().equals(iu.getVersion())) {
        logger.info("  p2iu.xml//unit/@version: " + change.getVersion() + " => " + change.getNewVersion());
        iu.setVersion(change.getNewVersion());
        // version changed, so put the iu into the metadata so that the writeMetadata method can pick it up
        project.putMetadata(iu);
    }
}
Also used : VersionChange(org.eclipse.tycho.versions.engine.VersionChange) IU(org.eclipse.tycho.model.IU)

Example 2 with IU

use of org.eclipse.tycho.model.IU in project tycho by eclipse.

the class IUXmlTransformerTest method testExpandVersion.

@Test
public void testExpandVersion() throws Exception {
    subject = new IUXmlTransformer();
    IU iu = IU.read(new File(TestUtil.getBasedir("projects/iuXmlValueReplacement/"), "p2iu.xml"));
    subject.replaceSelfQualifiers(iu, "1.0.0.ABC", "ABC");
    assertEquals(iu.getVersion(), "1.0.0.ABC");
    assertThat(iu.getProvidedCapabilites(), hasItem(capability("demo.iu", "1.0.0.ABC")));
    assertThat(iu.getArtifacts(), hasItem(artifact("demo.iu", "1.0.0.ABC")));
}
Also used : IU(org.eclipse.tycho.model.IU) File(java.io.File) Test(org.junit.Test)

Example 3 with IU

use of org.eclipse.tycho.model.IU in project tycho by eclipse.

the class PackageIUMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    outputDirectory.mkdirs();
    IU iu = IU.loadIU(basedir);
    File iuXML = new File(outputDirectory, IU.SOURCE_FILE_NAME);
    try {
        addSelfCapability(iu);
        addArtifactReference(iu);
        addMavenProperties(iu);
        expandVersions(iu);
        IU.write(iu, iuXML);
    } catch (IOException e) {
        throw new MojoExecutionException("Error updating " + IU.SOURCE_FILE_NAME, e);
    }
    // Create the artifact
    File artifactForIU = createArtifact();
    project.getArtifact().setFile(artifactForIU);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) IU(org.eclipse.tycho.model.IU) File(java.io.File)

Example 4 with IU

use of org.eclipse.tycho.model.IU in project tycho by eclipse.

the class PackageIUMojoTest method testArtifactWithoutPayload.

public void testArtifactWithoutPayload() throws Exception {
    File basedir = getBasedir("projects/iuWithoutPayload");
    File platform = new File("src/test/resources/eclipse");
    List<MavenProject> projects = getSortedProjects(basedir, platform);
    MavenProject project = getProject(projects, "iuWithoutPayload");
    MavenSession session = newMavenSession(project, projects);
    // set build qualifier
    lookupMojoWithDefaultConfiguration(project, session, "build-qualifier").execute();
    PackageIUMojo mojo = (PackageIUMojo) lookupConfiguredMojo(project, "package-iu");
    mojo.execute();
    IU iu = IU.loadIU(new File(basedir, "target"));
    Element artifact = iu.getSelfArtifact();
    assertThat(artifact, nullValue());
    assertThat(new File(basedir, "target/iuWithoutPayload-1.0.0.zip").exists(), is(true));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) Element(de.pdark.decentxml.Element) PackageIUMojo(org.eclipse.tycho.packaging.PackageIUMojo) IU(org.eclipse.tycho.model.IU) File(java.io.File)

Example 5 with IU

use of org.eclipse.tycho.model.IU in project tycho by eclipse.

the class IUXmlTransformerTest method testExpandReferences.

@Test
public void testExpandReferences() throws Exception {
    subject = new IUXmlTransformer();
    IU iu = IU.read(new File(TestUtil.getBasedir("projects/iuXmlValueReplacement/"), "p2iu.xml"));
    TargetPlatform tp = mock(TargetPlatform.class);
    when(tp.resolveArtifact("p2-installable-unit", "org.junit4", "0.0.0")).thenReturn(junit4InTP);
    when(tp.resolveArtifact("p2-installable-unit", "org.hamcrest.core", "1.1.0.qualifier")).thenReturn(hamcrestInTP);
    subject.replaceZerosInRequirements(iu, tp);
    subject.replaceQualifierInRequirements(iu, tp);
    assertThat(iu.getRequiredCapabilites(), hasItem(requirement("org.junit4", "4.8.1.v20100302")));
    assertThat(iu.getRequiredCapabilites(), hasItem(requirement("org.hamcrest.core", "1.1.0.v20090501071000")));
}
Also used : TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) IU(org.eclipse.tycho.model.IU) File(java.io.File) Test(org.junit.Test)

Aggregations

IU (org.eclipse.tycho.model.IU)7 File (java.io.File)6 Test (org.junit.Test)3 Element (de.pdark.decentxml.Element)2 MavenSession (org.apache.maven.execution.MavenSession)2 MavenProject (org.apache.maven.project.MavenProject)2 PackageIUMojo (org.eclipse.tycho.packaging.PackageIUMojo)2 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)1 VersionChange (org.eclipse.tycho.versions.engine.VersionChange)1