| 1 |
|
package org.apache.torque.mojo; |
| 2 |
|
|
| 3 |
|
import java.io.File; |
| 4 |
|
import java.util.Iterator; |
| 5 |
|
import java.util.Map; |
| 6 |
|
|
| 7 |
|
import org.apache.commons.configuration.ConfigurationException; |
| 8 |
|
import org.apache.commons.configuration.FileConfiguration; |
| 9 |
|
import org.apache.commons.configuration.PropertiesConfiguration; |
| 10 |
|
import org.apache.maven.plugin.MojoExecutionException; |
| 11 |
|
import org.apache.texen.ant.TexenTask; |
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 18 |
Complexity Density: 0.56 |
|
| 16 |
|
public abstract class TexenTaskMojo extends AntTaskMojo { |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
private String outputDir; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
private String templatePath; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
private boolean useClasspath; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
private Map<?, ?> userContextProperties; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private String contextPropertiesPath; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
@param |
| 57 |
|
|
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
0
|
public void setOutputDir(String outputDir) {... |
| 60 |
0
|
this.outputDir = outputDir; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
@return |
| 67 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 68 |
0
|
public String getOutputDir() {... |
| 69 |
0
|
return this.outputDir; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@param |
| 76 |
|
|
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0
|
public void setTemplatePath(String templatePath) {... |
| 79 |
0
|
this.templatePath = templatePath; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
@return |
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0
|
public String getTemplatePath() {... |
| 88 |
0
|
return this.templatePath; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
@param |
| 95 |
|
|
| 96 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 97 |
0
|
public void setUseClasspath(boolean useClasspath) {... |
| 98 |
0
|
this.useClasspath = useClasspath; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
@return |
| 105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
0
|
public boolean getUseClasspath() {... |
| 107 |
0
|
return this.useClasspath; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
@param |
| 114 |
|
|
| 115 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 116 |
0
|
public void setContextPropertiesPath(String contextPropertiesPath) {... |
| 117 |
0
|
this.contextPropertiesPath = contextPropertiesPath; |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
@return |
| 124 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 125 |
0
|
public String getContextPropertiesPath() {... |
| 126 |
0
|
return this.contextPropertiesPath; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
@param |
| 134 |
|
|
| 135 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
0
|
public void setUserContextProperties(Map<?, ?> userContextProperties) {... |
| 137 |
0
|
this.userContextProperties = userContextProperties; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
@return |
| 144 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 145 |
0
|
public Map<?, ?> getUserContextProperties() {... |
| 146 |
0
|
return userContextProperties; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@return |
| 153 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
0
|
protected TexenTask getGeneratorTask() {... |
| 155 |
0
|
return (TexenTask) getAntTask(); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
@throws |
| 162 |
|
|
| 163 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 164 |
0
|
protected void generateContextProperties() throws MojoExecutionException {... |
| 165 |
0
|
try { |
| 166 |
0
|
FileConfiguration configuration = getMojoContextProperties(); |
| 167 |
0
|
if (userContextProperties != null) { |
| 168 |
0
|
for (Iterator<?> contextPropertyIt = userContextProperties.entrySet().iterator(); contextPropertyIt.hasNext();) { |
| 169 |
0
|
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) contextPropertyIt.next(); |
| 170 |
0
|
configuration.addProperty(entry.getKey().toString(), entry.getValue().toString()); |
| 171 |
|
} |
| 172 |
|
} |
| 173 |
0
|
configuration.save(contextPropertiesPath); |
| 174 |
|
} catch (ConfigurationException e) { |
| 175 |
0
|
getLog().error("Error writing temporary context properties: " + e.getMessage()); |
| 176 |
0
|
throw new MojoExecutionException(e.getMessage()); |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 183 |
0
|
protected void configureTask() throws MojoExecutionException {... |
| 184 |
0
|
super.configureTask(); |
| 185 |
0
|
TexenTask task = getGeneratorTask(); |
| 186 |
0
|
task.setContextProperties(contextPropertiesPath); |
| 187 |
0
|
task.setUseClasspath(useClasspath); |
| 188 |
0
|
try { |
| 189 |
0
|
task.setTemplatePath(templatePath); |
| 190 |
|
} catch (Exception e) { |
| 191 |
0
|
throw new MojoExecutionException("Error setting template path", e); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
0
|
File outputDirectory = new File(outputDir); |
| 195 |
0
|
outputDirectory.mkdirs(); |
| 196 |
0
|
getGeneratorTask().setOutputDirectory(outputDirectory); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
@throws |
| 204 |
|
|
| 205 |
|
|
| 206 |
|
@see |
| 207 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 208 |
0
|
public void executeMojo() throws MojoExecutionException {... |
| 209 |
0
|
generateContextProperties(); |
| 210 |
0
|
super.executeMojo(); |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
@return |
| 218 |
|
|
| 219 |
|
protected abstract PropertiesConfiguration getMojoContextProperties(); |
| 220 |
|
} |