1 |
|
package org.apache.maven.scm.plugin; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.io.IOException; |
20 |
|
|
21 |
|
import org.apache.maven.plugin.MojoExecutionException; |
22 |
|
import org.apache.maven.scm.ScmException; |
23 |
|
import org.apache.maven.scm.ScmFileSet; |
24 |
|
import org.apache.maven.scm.command.export.ExportScmResult; |
25 |
|
import org.apache.maven.scm.repository.ScmRepository; |
26 |
|
import org.codehaus.plexus.util.FileUtils; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@author |
32 |
|
@version |
33 |
|
|
34 |
|
|
35 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 10 |
Complexity Density: 0.53 |
|
36 |
|
public class ExportMojo |
37 |
|
extends AbstractScmMojo |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private String scmVersionType; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
private String scmVersion; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
private File exportDirectory; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
private boolean skipExportIfExists = false; |
67 |
|
|
68 |
|
|
69 |
|
@inheritDoc |
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
70 |
0
|
public void execute()... |
71 |
|
throws MojoExecutionException |
72 |
|
{ |
73 |
0
|
super.execute(); |
74 |
|
|
75 |
0
|
if ( this.skipExportIfExists && this.exportDirectory.isDirectory() ) |
76 |
|
{ |
77 |
0
|
return; |
78 |
|
} |
79 |
|
|
80 |
0
|
export(); |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0
|
protected File getExportDirectory()... |
84 |
|
{ |
85 |
0
|
return this.exportDirectory; |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0
|
public void setExportDirectory( File exportDirectory )... |
89 |
|
{ |
90 |
0
|
this.exportDirectory = exportDirectory; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
93 |
0
|
protected void export()... |
94 |
|
throws MojoExecutionException |
95 |
|
{ |
96 |
0
|
try |
97 |
|
{ |
98 |
0
|
ScmRepository repository = getScmRepository(); |
99 |
|
|
100 |
0
|
try |
101 |
|
{ |
102 |
0
|
if ( this.exportDirectory.exists() ) |
103 |
|
{ |
104 |
0
|
this.getLog().info( "Removing " + this.exportDirectory ); |
105 |
|
|
106 |
0
|
FileUtils.deleteDirectory( this.exportDirectory ); |
107 |
|
} |
108 |
|
} |
109 |
|
catch ( IOException e ) |
110 |
|
{ |
111 |
0
|
throw new MojoExecutionException( "Cannot remove " + getExportDirectory() ); |
112 |
|
} |
113 |
|
|
114 |
0
|
if ( !this.exportDirectory.mkdirs() ) |
115 |
|
{ |
116 |
0
|
throw new MojoExecutionException( "Cannot create " + this.exportDirectory ); |
117 |
|
} |
118 |
|
|
119 |
0
|
ExportScmResult result = getScmManager().export( repository, |
120 |
|
new ScmFileSet( this.exportDirectory.getAbsoluteFile() ), |
121 |
|
getScmVersion( scmVersionType, scmVersion ) ); |
122 |
|
|
123 |
0
|
checkResult( result ); |
124 |
|
|
125 |
0
|
handleExcludesIncludesAfterCheckoutAndExport( this.exportDirectory ); |
126 |
|
} |
127 |
|
catch ( ScmException e ) |
128 |
|
{ |
129 |
0
|
throw new MojoExecutionException( "Cannot run export command : ", e ); |
130 |
|
} |
131 |
|
} |
132 |
|
} |