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
30
31
32
33
34
35 @Mojo(name = "nar-gnu-make", requiresProject = true, defaultPhase = LifecyclePhase.COMPILE)
36 public class NarGnuMakeMojo extends AbstractGnuMojo {
37
38
39
40 @Parameter(defaultValue = "")
41 private String gnuMakeArgs;
42
43
44
45
46 @Parameter(defaultValue = "")
47 private String gnuMakeEnv;
48
49
50
51
52
53 @Parameter(property = "nar.gnu.make.skip")
54 private boolean gnuMakeSkip;
55
56
57
58
59 @Parameter
60 private boolean gnuMakeInstallSkip;
61
62 @Override
63 public final void narExecute() throws MojoExecutionException, MojoFailureException {
64 if (!useGnu() || gnuMakeSkip) {
65 return;
66 }
67
68 final File srcDir = getGnuAOLSourceDirectory();
69 if (srcDir.exists()) {
70 String[] args = null;
71 String[] env = null;
72
73 if (this.gnuMakeArgs != null) {
74 args = this.gnuMakeArgs.split(" ");
75 }
76 if (this.gnuMakeEnv != null) {
77 env = this.gnuMakeEnv.split(",");
78 }
79
80 getLog().info("Running GNU make");
81 int result = NarUtil.runCommand("make", args, srcDir, env, getLog());
82 if (result != 0) {
83 throw new MojoExecutionException("'make' errorcode: " + result);
84 }
85
86 if (!this.gnuMakeInstallSkip) {
87 getLog().info("Running make install");
88 if (args != null) {
89 this.gnuMakeArgs = this.gnuMakeArgs + " install";
90 args = this.gnuMakeArgs.split(" ");
91 } else {
92 args = new String[] {
93 "install"
94 };
95 }
96 result = NarUtil.runCommand("make", args, srcDir, null, getLog());
97 if (result != 0) {
98 throw new MojoExecutionException("'make install' errorcode: " + result);
99 }
100 }
101 }
102 }
103 }