| 1 |
|
package org.codehaus.mojo.exec; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
import java.io.File; |
| 17 |
|
import java.util.List; |
| 18 |
|
|
| 19 |
|
import org.apache.maven.plugin.AbstractMojo; |
| 20 |
|
import org.apache.maven.plugin.MojoExecutionException; |
| 21 |
|
import org.apache.maven.project.MavenProject; |
| 22 |
|
import org.codehaus.plexus.util.cli.CommandLineUtils; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
@author |
| 29 |
|
@author |
| 30 |
|
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 13 |
Complexity Density: 0.46 |
|
| 31 |
|
public abstract class AbstractExecMojo extends AbstractMojo { |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
protected MavenProject project; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
private File sourceRoot; |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private File testSourceRoot; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
private String commandlineArgs; |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
protected String classpathScope; |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
@since |
| 69 |
|
|
| 70 |
|
private boolean skip; |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
@param |
| 77 |
|
|
| 78 |
|
@param |
| 79 |
|
|
| 80 |
|
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
| 81 |
0
|
protected void collectProjectArtifactsAndClasspath(List artifacts, List theClasspathFiles) {... |
| 82 |
|
|
| 83 |
0
|
if ("compile".equals(classpathScope)) { |
| 84 |
0
|
artifacts.addAll(project.getCompileArtifacts()); |
| 85 |
0
|
theClasspathFiles.add(new File(project.getBuild().getOutputDirectory())); |
| 86 |
0
|
} else if ("test".equals(classpathScope)) { |
| 87 |
0
|
artifacts.addAll(project.getTestArtifacts()); |
| 88 |
0
|
theClasspathFiles.add(new File(project.getBuild().getTestOutputDirectory())); |
| 89 |
0
|
theClasspathFiles.add(new File(project.getBuild().getOutputDirectory())); |
| 90 |
0
|
} else if ("runtime".equals(classpathScope)) { |
| 91 |
0
|
artifacts.addAll(project.getRuntimeArtifacts()); |
| 92 |
0
|
theClasspathFiles.add(new File(project.getBuild().getOutputDirectory())); |
| 93 |
0
|
} else if ("system".equals(classpathScope)) { |
| 94 |
0
|
artifacts.addAll(project.getSystemArtifacts()); |
| 95 |
|
} else { |
| 96 |
0
|
throw new IllegalStateException("Invalid classpath scope: " + classpathScope); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
0
|
getLog().debug("Collected project artifacts " + artifacts); |
| 100 |
0
|
getLog().debug("Collected project classpath " + theClasspathFiles); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
@return |
| 109 |
|
@throws |
| 110 |
|
|
| 111 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 112 |
0
|
protected String[] parseCommandlineArgs() throws MojoExecutionException {... |
| 113 |
0
|
if (commandlineArgs == null) { |
| 114 |
0
|
return null; |
| 115 |
|
} else { |
| 116 |
0
|
try { |
| 117 |
0
|
return CommandLineUtils.translateCommandline(commandlineArgs); |
| 118 |
|
} catch (Exception e) { |
| 119 |
0
|
throw new MojoExecutionException(e.getMessage()); |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@return |
| 126 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
0
|
protected boolean hasCommandlineArgs() {... |
| 128 |
0
|
return (commandlineArgs != null); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 134 |
0
|
protected void registerSourceRoots() {... |
| 135 |
0
|
if (sourceRoot != null) { |
| 136 |
0
|
getLog().info("Registering compile source root " + sourceRoot); |
| 137 |
0
|
project.addCompileSourceRoot(sourceRoot.toString()); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
0
|
if (testSourceRoot != null) { |
| 141 |
0
|
getLog().info("Registering compile test source root " + testSourceRoot); |
| 142 |
0
|
project.addTestCompileSourceRoot(testSourceRoot.toString()); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
@return |
| 150 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 151 |
0
|
protected boolean isSkip() {... |
| 152 |
0
|
return skip; |
| 153 |
|
} |
| 154 |
|
} |