1 |
|
package org.apache.maven.scm.plugin; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
import org.apache.maven.plugin.MojoExecutionException; |
23 |
|
import org.apache.maven.project.MavenProject; |
24 |
|
import org.apache.maven.scm.ScmException; |
25 |
|
import org.apache.maven.scm.command.update.UpdateScmResult; |
26 |
|
import org.apache.maven.scm.command.update.UpdateScmResultWithRevision; |
27 |
|
import org.apache.maven.scm.repository.ScmRepository; |
28 |
|
|
29 |
|
import java.io.IOException; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@author |
35 |
|
@version |
36 |
|
|
37 |
|
|
38 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.38 |
|
39 |
|
public class UpdateMojo |
40 |
|
extends AbstractScmMojo |
41 |
|
{ |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private String scmVersionType; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private String scmVersion; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
private String revisionKey; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
private MavenProject project; |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
private boolean runChangelog = false; |
78 |
|
|
79 |
|
@inheritDoc |
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
80 |
0
|
public void execute()... |
81 |
|
throws MojoExecutionException |
82 |
|
{ |
83 |
0
|
super.execute(); |
84 |
|
|
85 |
0
|
try |
86 |
|
{ |
87 |
0
|
ScmRepository repository = getScmRepository(); |
88 |
|
|
89 |
0
|
UpdateScmResult result = getScmManager().update( repository, getFileSet(), |
90 |
|
getScmVersion( scmVersionType, scmVersion ), |
91 |
|
runChangelog ); |
92 |
|
|
93 |
0
|
checkResult( result ); |
94 |
|
|
95 |
0
|
if ( result instanceof UpdateScmResultWithRevision ) |
96 |
|
{ |
97 |
0
|
String revision = ( (UpdateScmResultWithRevision) result ).getRevision(); |
98 |
|
|
99 |
0
|
getLog().info( "Storing revision in '" + revisionKey + "' project property." ); |
100 |
|
|
101 |
0
|
if ( project.getProperties() != null ) |
102 |
|
{ |
103 |
0
|
project.getProperties().put( revisionKey, revision ); |
104 |
|
} |
105 |
|
|
106 |
0
|
getLog().info( "Project at revision " + revision ); |
107 |
|
} |
108 |
|
} |
109 |
|
catch ( IOException e ) |
110 |
|
{ |
111 |
0
|
throw new MojoExecutionException( "Cannot run update command : ", e ); |
112 |
|
} |
113 |
|
catch ( ScmException e ) |
114 |
|
{ |
115 |
0
|
throw new MojoExecutionException( "Cannot run update command : ", e ); |
116 |
|
} |
117 |
|
} |
118 |
|
} |