1 |
|
package org.apache.torque.mojo; |
2 |
|
|
3 |
|
import java.io.File; |
4 |
|
import java.io.IOException; |
5 |
|
|
6 |
|
import org.apache.maven.plugin.MojoExecutionException; |
7 |
|
import org.apache.torque.mojo.morph.FileMorphRequest; |
8 |
|
import org.apache.torque.mojo.morph.MorphRequest; |
9 |
|
import org.apache.torque.mojo.morph.Morpher; |
10 |
|
import org.apache.torque.mojo.morph.VersionTableMorpher; |
11 |
|
import org.codehaus.plexus.util.FileUtils; |
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 10 |
Complexity Density: 0.42 |
|
20 |
|
public class MorphVersionTableMojo extends AbstractMorphSingleMojo { |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
private File newVersionXMLFile; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
private File oldVersionXMLFile; |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
40 |
0
|
protected void beforeExecution() {... |
41 |
0
|
setNewFile(newVersionXMLFile); |
42 |
0
|
setOldFile(oldVersionXMLFile); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
45 |
0
|
@Override... |
46 |
|
protected boolean isMorphNeeded() { |
47 |
|
|
48 |
0
|
if (!getOldFile().exists()) { |
49 |
0
|
getLog().debug("file:" + getOldFile().getAbsolutePath() + " does not exist"); |
50 |
0
|
return false; |
51 |
|
} else { |
52 |
0
|
return true; |
53 |
|
} |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
|
56 |
0
|
@Override... |
57 |
|
protected void executeMojo() throws MojoExecutionException { |
58 |
0
|
getLog().info("------------------------------------------------------------------------"); |
59 |
0
|
getLog().info("Converting version table XML file"); |
60 |
0
|
getLog().info("------------------------------------------------------------------------"); |
61 |
0
|
try { |
62 |
0
|
FileUtils.forceMkdir(new File(FileUtils.getPath(getNewFile().getAbsolutePath()))); |
63 |
0
|
MorphRequest request = new FileMorphRequest(getOldFile(), getNewFile()); |
64 |
0
|
request.setName(getOldFile().getName()); |
65 |
0
|
request.setEncoding(getEncoding()); |
66 |
0
|
Morpher morpher = getMorpher(request, getProject().getArtifactId()); |
67 |
0
|
morpher.executeMorph(); |
68 |
|
} catch (IOException e) { |
69 |
0
|
throw new MojoExecutionException("Unexpected error while attempting to morph " + getOldFile().getAbsolutePath(), e); |
70 |
|
} |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
73 |
0
|
protected Morpher getMorpher(MorphRequest request, String artifactId) {... |
74 |
0
|
VersionTableMorpher morpher = new VersionTableMorpher(request, artifactId); |
75 |
0
|
morpher.setProjectVersion(getProject().getVersion()); |
76 |
0
|
return morpher; |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
@return |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
0
|
public File getNewVersionXMLFile() {... |
83 |
0
|
return newVersionXMLFile; |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
|
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0
|
public void setNewVersionXMLFile(final File newVersionXMLFile) {... |
91 |
0
|
this.newVersionXMLFile = newVersionXMLFile; |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
@return |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
public File getOldVersionXMLFile() {... |
98 |
0
|
return oldVersionXMLFile; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
@param |
103 |
|
|
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
public void setOldVersionXMLFile(final File oldVersionXMLFile) {... |
106 |
0
|
this.oldVersionXMLFile = oldVersionXMLFile; |
107 |
|
} |
108 |
|
} |