1 package org.apache.maven.scm.plugin;
2
3 import java.io.File;
4
5 import org.apache.maven.plugin.MojoExecutionException;
6 import org.apache.maven.scm.ScmException;
7 import org.apache.maven.scm.ScmFileSet;
8 import org.apache.maven.scm.command.status.StatusScmResult;
9 import org.apache.maven.scm.repository.ScmRepository;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class CheckLocalModificationsMojo
37 extends AbstractScmMojo
38 {
39
40
41
42
43
44
45
46 private String errorMessage;
47
48
49
50
51
52
53 private boolean skip;
54
55
56
57
58
59
60
61 private File baseDirectory;
62
63 public void execute()
64 throws MojoExecutionException
65 {
66 if ( skip )
67 {
68 getLog().info( "check-local-modification execution has been skipped" );
69 return;
70 }
71 super.execute();
72
73 StatusScmResult result = null;
74
75 try
76 {
77 ScmRepository repository = getScmRepository();
78 result = getScmManager().status( repository, new ScmFileSet( baseDirectory ) );
79 }
80 catch ( ScmException e )
81 {
82 throw new MojoExecutionException( e.getMessage(), e );
83 }
84
85 if ( !result.isSuccess() )
86 {
87 throw new MojoExecutionException( "Unable to check for local modifications :" + result.getProviderMessage() );
88 }
89
90 if ( !result.getChangedFiles().isEmpty() )
91 {
92 getLog().error( errorMessage );
93 throw new MojoExecutionException( errorMessage );
94 }
95
96 }
97
98 }