Search in sources :

Example 6 with RollbackOnError

use of com.itemis.maven.plugins.cdi.annotations.RollbackOnError in project unleash-maven-plugin by shillner.

the class InstallArtifacts method rollback.

@RollbackOnError
public void rollback() {
    this.log.info("Rolling back local artifact installation due to a processing exception.");
    Collection<org.apache.maven.artifact.Artifact> artifacts = Collections2.transform(this.installedArtifacts, AetherToMavenArtifact.INSTANCE);
    for (org.apache.maven.artifact.Artifact artifact : artifacts) {
        File localArtifact = new File(this.LocalRepository.getBasedir(), this.LocalRepository.pathOf(artifact));
        File localArtifactDirectory = localArtifact.getParentFile();
        try {
            this.log.debug("\tDeleting locally installed artifact (parent directory): " + artifact);
            FileUtils.deleteDirectory(localArtifactDirectory);
        } catch (IOException e) {
            // do not fail in order to ensure that the other executions can also be rolled-back
            this.log.error("Error rolling back artifact installation. Could not delete locally installed artifact: " + artifact, e);
        }
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) Artifact(org.eclipse.aether.artifact.Artifact) AetherToMavenArtifact(com.itemis.maven.plugins.unleash.util.functions.AetherToMavenArtifact) RollbackOnError(com.itemis.maven.plugins.cdi.annotations.RollbackOnError)

Aggregations

RollbackOnError (com.itemis.maven.plugins.cdi.annotations.RollbackOnError)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 MavenProject (org.apache.maven.project.MavenProject)4 Document (org.w3c.dom.Document)4 RevertCommitsRequest (com.itemis.maven.plugins.unleash.scm.requests.RevertCommitsRequest)3 ScmPomVersionsMergeClient (com.itemis.maven.plugins.unleash.util.scm.ScmPomVersionsMergeClient)3 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)2 IOException (java.io.IOException)2 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)1 ScmException (com.itemis.maven.plugins.unleash.scm.ScmException)1 DeleteTagRequest (com.itemis.maven.plugins.unleash.scm.requests.DeleteTagRequest)1 AetherToMavenArtifact (com.itemis.maven.plugins.unleash.util.functions.AetherToMavenArtifact)1 File (java.io.File)1 Artifact (org.eclipse.aether.artifact.Artifact)1 VersionsEngine (org.eclipse.tycho.versions.engine.VersionsEngine)1