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.io.File;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.LifecyclePhase;
27 import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
30
31
32
33
34
35
36 @Mojo(name = "nar-validate", defaultPhase = LifecyclePhase.VALIDATE)
37 public class NarValidateMojo extends AbstractCompileMojo {
38
39
40
41 @Parameter(defaultValue = "${basedir}/src/gnu", required = true)
42 private File gnuSourceDirectory;
43
44 @Override
45 protected ScopeFilter
46 return null;
47 }
48
49 @Override
50 public final void narExecute() throws MojoExecutionException, MojoFailureException {
51
52 if (this.skip) {
53 getLog().info(getClass().getName() + " skipped");
54 return;
55 }
56
57
58 final AOL aol = getAOL();
59 getLog().info("Using AOL: " + aol);
60
61
62 final Linker linker = getLinker();
63 getLog().debug("Using linker version: " + linker.getVersion(this));
64
65
66 int noOfCompilers = 0;
67 if (this.onlySpecifiedCompilers) {
68 if (getCpp() != null && getCpp().getName() != null) {
69 noOfCompilers++;
70
71 if (getCpp().getIncludes(Compiler.MAIN).isEmpty()) {
72 throw new MojoExecutionException("No includes defined for compiler " + getCpp().getName());
73 }
74 }
75
76 if (getC() != null && getC().getName() != null) {
77 noOfCompilers++;
78
79 if (getC().getIncludes(Compiler.MAIN).isEmpty()) {
80 throw new MojoExecutionException("No includes defined for compiler " + getC().getName());
81 }
82 }
83
84 if (getFortran() != null && getFortran().getName() != null) {
85 noOfCompilers++;
86
87 if (getFortran().getIncludes(Compiler.MAIN).isEmpty()) {
88 throw new MojoExecutionException("No includes defined for compiler " + getFortran().getName());
89 }
90 }
91
92
93
94
95 if (noOfCompilers == 0 && (this.gnuSourceDirectory == null || !this.gnuSourceDirectory.exists())) {
96 throw new MojoExecutionException("No compilers defined for linker " + linker.getName() + ", and no"
97 + " <gnuSourceDirectory> is defined. Either define a compiler or a linker.");
98 }
99 }
100 }
101 }