~ubuntu-branches/ubuntu/trusty/build-helper-maven-plugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/main/java/org/codehaus/mojo/buildhelper/RemoveLocalArtifactMojo.java

  • Committer: Package Import Robot
  • Author(s): tony mancill, Emmanuel Bourg, tony mancill
  • Date: 2013-06-01 20:19:34 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130601201934-hzv7zmdcgazfyupp
Tags: 1.7-1
[ Emmanuel Bourg ]
* Team upload.
* New upstream release
* Set the compiler source/target to 1.5
* Updated Standards-Version to 3.9.4 (no changes)
* debian/copyright:
  - Updated the Format URI to 1.0
  - Removed the duplicate Copyright fields

[ tony mancill ]
* debian/control:
  - Add libmaven-invoker-plugin-java to build-depends-indep.
  - Wrap long lines.
  - Update Vcs-Git URL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
import org.apache.maven.artifact.repository.ArtifactRepository;
32
32
import org.apache.maven.plugin.AbstractMojo;
33
 
import org.apache.maven.plugin.MojoExecutionException;
34
33
import org.apache.maven.plugin.MojoFailureException;
35
34
import org.apache.maven.project.MavenProject;
36
35
import org.codehaus.plexus.util.FileUtils;
42
41
 * @goal remove-project-artifact
43
42
 * @phase package
44
43
 * @author <a href="dantran@gmail.com">Dan T. Tran</a>
45
 
 * @version $Id: RemoveLocalArtifactMojo.java 11881 2010-02-12 08:00:57Z dennisl $
 
44
 * @version $Id: RemoveLocalArtifactMojo.java 14202 2011-06-21 20:50:25Z rfscholte $
46
45
 * @since 1.1
47
46
 */
48
47
public class RemoveLocalArtifactMojo
60
59
    private boolean removeAll;
61
60
 
62
61
    /**
 
62
     * Indicates whether the build will continue even if there are removal errors.
 
63
     *
 
64
     * @parameter default-value="true" expression="${buildhelper.removeCritical}"
 
65
     * @since 1.6
 
66
     *
 
67
     */
 
68
    private boolean failOnError;
 
69
 
 
70
    /**
63
71
     * @parameter expression="${project}"
64
72
     * @required
65
73
     * @readonly
76
84
    private ArtifactRepository localRepository;
77
85
 
78
86
    public void execute()
79
 
        throws MojoExecutionException, MojoFailureException
 
87
        throws MojoFailureException
80
88
    {
81
89
        File localArtifactFile =
82
90
            new File( localRepository.getBasedir(), localRepository.pathOf( project.getArtifact() ) );
91
99
        try
92
100
        {
93
101
            FileUtils.deleteDirectory( localArtifactDirectory );
 
102
 
 
103
            if( getLog().isInfoEnabled() )
 
104
            {
 
105
                getLog().info( localArtifactDirectory.getAbsolutePath() + " removed." );
 
106
            }
94
107
        }
95
108
        catch ( IOException e )
96
109
        {
97
 
            throw new MojoFailureException( "Cannot delete " + localArtifactDirectory );
 
110
            final String failureMessage = "Cannot delete " + localArtifactDirectory;
 
111
            if ( failOnError )
 
112
            {
 
113
                throw new MojoFailureException( failureMessage );
 
114
            }
 
115
            else
 
116
            {
 
117
                getLog().warn( failureMessage );
 
118
            }
98
119
        }
99
 
 
100
 
        this.getLog().info( localArtifactDirectory.getAbsolutePath() + " removed." );
101
 
 
102
120
    }
103
121
}