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