Search in sources :

Example 21 with VersionsEngine

use of org.eclipse.tycho.versions.engine.VersionsEngine in project tycho by eclipse.

the class VersionsEngineTest method testProfileNoId.

public void testProfileNoId() throws Exception {
    File basedir = TestUtil.getBasedir("projects/profilenoid");
    VersionsEngine engine = newEngine(basedir);
    engine.addVersionChange("profilenoid", "1.0.1-01");
    engine.apply();
}
Also used : VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) File(java.io.File)

Example 22 with VersionsEngine

use of org.eclipse.tycho.versions.engine.VersionsEngine in project tycho by eclipse.

the class VersionsEngineTest method testBuildPluginNoGroupId.

public void testBuildPluginNoGroupId() throws Exception {
    File basedir = TestUtil.getBasedir("projects/buildpluginnogroupid");
    VersionsEngine engine = newEngine(basedir);
    engine.addVersionChange("buildpluginnogroupid", "1.0.1-01");
    engine.apply();
}
Also used : VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) File(java.io.File)

Example 23 with VersionsEngine

use of org.eclipse.tycho.versions.engine.VersionsEngine in project tycho by eclipse.

the class VersionsEngineTest method assertNonOsgiVersionOsgiProject.

private void assertNonOsgiVersionOsgiProject(String artifactId) throws Exception {
    File basedir = TestUtil.getBasedir("projects/nonosgiversion/" + artifactId);
    VersionsEngine engine = newEngine(basedir);
    engine.addVersionChange(artifactId, "1.0.1-01");
    try {
        engine.apply();
        fail();
    } catch (IllegalVersionChangeException e) {
        // not a valid osgi version
        assertEquals(1, e.getErrors().size());
    }
}
Also used : IllegalVersionChangeException(org.eclipse.tycho.versions.engine.IllegalVersionChangeException) VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) File(java.io.File)

Example 24 with VersionsEngine

use of org.eclipse.tycho.versions.engine.VersionsEngine in project unleash-maven-plugin by shillner.

the class AbstractTychoVersionsStep method rollback.

@RollbackOnError
public void rollback() throws MojoExecutionException, MojoFailureException {
    VersionsEngine versionsEngine = initializeVersionsEngine();
    try {
        // first add all module version changes to the versions engine of tycho and execute the change command
        for (MavenProject module : this.reactorProjects) {
            String version = this.cachedModuleVersions.get(ProjectToCoordinates.EMPTY_VERSION.apply(module));
            versionsEngine.addVersionChange(module.getArtifactId(), version);
        }
        versionsEngine.apply();
        // second step is to revert all pom changes by simply replacing the poms
        for (MavenProject module : this.reactorProjects) {
            this.log.debug("\tRolling back modifications on POM of module '" + ProjectToString.INSTANCE.apply(this.project) + "'");
            ArtifactCoordinates coordinates = ProjectToCoordinates.EMPTY_VERSION.apply(module);
            Document document = this.cachedPOMs.get(coordinates);
            if (document != null) {
                try {
                    PomUtil.writePOM(document, this.project);
                } catch (Throwable t) {
                    throw new MojoExecutionException("Could not revert the version update after a failed release build.", t);
                }
            }
            String version = this.cachedModuleVersions.get(coordinates);
            if (module.getModel().getVersion() != null) {
                module.getModel().setVersion(version);
            }
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Could not revert the version update after a failed release build.", e);
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString) IOException(java.io.IOException) VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) Document(org.w3c.dom.Document) RollbackOnError(com.itemis.maven.plugins.cdi.annotations.RollbackOnError)

Example 25 with VersionsEngine

use of org.eclipse.tycho.versions.engine.VersionsEngine in project unleash-maven-plugin by shillner.

the class AbstractTychoVersionsStep method initializeVersionsEngine.

private VersionsEngine initializeVersionsEngine() throws MojoExecutionException, MojoFailureException {
    if (this.metadataReader == null) {
        this.metadataReader = lookup(ProjectMetadataReader.class);
        try {
            this.metadataReader.addBasedir(this.project.getBasedir());
        } catch (IOException e) {
            throw new MojoExecutionException("Tycho was unable to read the project structure!", e);
        }
    }
    VersionsEngine versionsEngine = lookup(VersionsEngine.class);
    versionsEngine.setUpdateVersionRangeMatchingBounds(false);
    versionsEngine.setProjects(this.metadataReader.getProjects());
    return versionsEngine;
}
Also used : ProjectMetadataReader(org.eclipse.tycho.versions.engine.ProjectMetadataReader) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine)

Aggregations

VersionsEngine (org.eclipse.tycho.versions.engine.VersionsEngine)25 File (java.io.File)21 IOException (java.io.IOException)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)2 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)2 MavenProject (org.apache.maven.project.MavenProject)2 ProjectMetadataReader (org.eclipse.tycho.versions.engine.ProjectMetadataReader)2 Document (org.w3c.dom.Document)2 RollbackOnError (com.itemis.maven.plugins.cdi.annotations.RollbackOnError)1 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)1 IllegalVersionChangeException (org.eclipse.tycho.versions.engine.IllegalVersionChangeException)1