| 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 |
|
@author |
| 34 |
|
@since |
| 35 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 63 |
0
|
public void execute()... |
| 64 |
|
throws MojoExecutionException |
| 65 |
|
{ |
| 66 |
0
|
if ( skip ) |
| 67 |
|
{ |
| 68 |
0
|
getLog().info( "check-local-modification execution has been skipped" ); |
| 69 |
0
|
return; |
| 70 |
|
} |
| 71 |
0
|
super.execute(); |
| 72 |
|
|
| 73 |
0
|
StatusScmResult result = null; |
| 74 |
|
|
| 75 |
0
|
try |
| 76 |
|
{ |
| 77 |
0
|
ScmRepository repository = getScmRepository(); |
| 78 |
0
|
result = getScmManager().status( repository, new ScmFileSet( baseDirectory ) ); |
| 79 |
|
} |
| 80 |
|
catch ( ScmException e ) |
| 81 |
|
{ |
| 82 |
0
|
throw new MojoExecutionException( e.getMessage(), e ); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
0
|
if ( !result.isSuccess() ) |
| 86 |
|
{ |
| 87 |
0
|
throw new MojoExecutionException( "Unable to check for local modifications :" + result.getProviderMessage() ); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
0
|
if ( !result.getChangedFiles().isEmpty() ) |
| 91 |
|
{ |
| 92 |
0
|
getLog().error( errorMessage ); |
| 93 |
0
|
throw new MojoExecutionException( errorMessage ); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
} |