1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar;
21
22 import java.util.Collections;
23 import java.util.List;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugins.annotations.Parameter;
27 import org.apache.tools.ant.Project;
28
29
30
31
32 public abstract class AbstractCompileMojo extends AbstractDependencyMojo {
33
34
35
36
37 @Parameter
38 private Cpp cpp;
39
40
41
42
43 @Parameter
44 private C c;
45
46
47
48
49 @Parameter
50 private Fortran fortran;
51
52
53
54
55 @Parameter
56 private Resource resource;
57
58
59
60
61 @Parameter
62 private IDL idl;
63
64
65
66
67 @Parameter
68 private Message message;
69
70
71
72
73
74
75
76 @Parameter(defaultValue = "false")
77 protected boolean onlySpecifiedCompilers;
78
79
80
81
82
83 @Parameter
84 protected int commandLogLevel = Project.MSG_VERBOSE;
85
86
87
88
89 @Parameter
90 private int maxCores = 0;
91
92
93
94
95 @Parameter(defaultValue = "true", required = true)
96 private boolean failOnError;
97
98
99
100
101 @Parameter(defaultValue = "dynamic", required = true)
102 private String runtime;
103
104
105
106
107
108
109 @Parameter(defaultValue = "false", required = true)
110 private boolean libtool;
111
112
113
114
115 @Parameter
116 private List tests;
117
118
119
120
121 @Parameter
122 private Java java;
123
124
125
126
127
128 @Parameter
129 protected boolean decorateLinkerOptions;
130
131 private List
132
133 private Project antProject;
134
135 protected final boolean failOnError(final AOL aol) throws MojoExecutionException {
136 return getNarInfo().getProperty(aol, "failOnError", this.failOnError);
137 }
138
139 protected final Project getAntProject() {
140 if (this.antProject == null) {
141
142 this.antProject = new Project();
143 this.antProject.setName("NARProject");
144 this.antProject.addBuildListener(new NarLogger(getLog()));
145 }
146 return this.antProject;
147 }
148
149 protected final C getC() {
150 if (this.c == null && !this.onlySpecifiedCompilers) {
151 setC(new C());
152 }
153 return this.c;
154 }
155
156 protected final Cpp getCpp() {
157 if (this.cpp == null && !this.onlySpecifiedCompilers) {
158 setCpp(new Cpp());
159 }
160 return this.cpp;
161 }
162
163 protected final List
164 return this.dependencyLibOrder;
165 }
166
167 protected final Fortran getFortran() {
168 if (this.fortran == null && !this.onlySpecifiedCompilers) {
169 setFortran(new Fortran());
170 }
171 return this.fortran;
172 }
173
174 protected final IDL getIdl() {
175 if (this.idl == null && !this.onlySpecifiedCompilers) {
176 setIdl(new IDL());
177 }
178 return this.idl;
179 }
180
181 protected final Java getJava() {
182 if (this.java == null) {
183 this.java = new Java();
184 }
185 this.java.setAbstractCompileMojo(this);
186 return this.java;
187 }
188
189 protected final int getMaxCores(final AOL aol) throws MojoExecutionException {
190 return getNarInfo().getProperty(aol, "maxCores", this.maxCores);
191 }
192
193 protected final Message getMessage() {
194 if (this.message == null && !this.onlySpecifiedCompilers) {
195 setMessage(new Message());
196 }
197 return this.message;
198 }
199
200 protected final String getOutput(final AOL aol, final String type) throws MojoExecutionException {
201 return getNarInfo().getOutput(aol, getOutput(!Library.EXECUTABLE.equals(type)));
202 }
203
204 protected final Resource getResource() {
205 if (this.resource == null && !this.onlySpecifiedCompilers) {
206 setResource(new Resource());
207 }
208 return this.resource;
209 }
210
211 protected final String getRuntime(final AOL aol) throws MojoExecutionException {
212 return getNarInfo().getProperty(aol, "runtime", this.runtime);
213 }
214
215 protected final List getTests() {
216 if (this.tests == null) {
217 this.tests = Collections.emptyList();
218 }
219 return this.tests;
220 }
221
222 public void setC(final C c) {
223 this.c = c;
224 c.setAbstractCompileMojo(this);
225 }
226
227 public void setCpp(final Cpp cpp) {
228 this.cpp = cpp;
229 cpp.setAbstractCompileMojo(this);
230 }
231
232 public final void setDependencyLibOrder(final List
233 this.dependencyLibOrder = order;
234 }
235
236 public void setFortran(final Fortran fortran) {
237 this.fortran = fortran;
238 fortran.setAbstractCompileMojo(this);
239 }
240
241 public void setIdl(final IDL idl) {
242 this.idl = idl;
243 idl.setAbstractCompileMojo(this);
244 }
245
246 public void setMessage(final Message message) {
247 this.message = message;
248 message.setAbstractCompileMojo(this);
249 }
250
251 public void setResource(final Resource resource) {
252 this.resource = resource;
253 resource.setAbstractCompileMojo(this);
254 }
255
256 protected final boolean useLibtool(final AOL aol) throws MojoExecutionException {
257 return getNarInfo().getProperty(aol, "libtool", this.libtool);
258 }
259
260 }