1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.jmod;
20
21 import javax.inject.Inject;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.util.List;
26
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugin.MojoFailureException;
29 import org.apache.maven.plugins.annotations.LifecyclePhase;
30 import org.apache.maven.plugins.annotations.Mojo;
31 import org.apache.maven.plugins.annotations.Parameter;
32 import org.apache.maven.plugins.annotations.ResolutionScope;
33 import org.apache.maven.shared.utils.cli.Commandline;
34 import org.apache.maven.toolchain.ToolchainManager;
35
36
37
38
39
40
41
42
43
44 @Mojo(name = "hash", requiresDependencyResolution = ResolutionScope.COMPILE, defaultPhase = LifecyclePhase.PACKAGE)
45 public class JModHashMojo extends AbstractJModMojo {
46
47
48
49
50 @Parameter
51 private List<String> classPath;
52
53
54
55
56 @Parameter
57 private List<String> cmds;
58
59
60
61
62 @Parameter
63 private File config;
64
65 @Parameter
66 private boolean dryRun;
67
68 @Parameter
69 private List<String> excludes;
70
71 @Parameter
72 private String mainClass;
73
74 @Parameter
75 private List<File> libs;
76
77 @Parameter
78 private String moduleVersion;
79
80
81
82
83
84 @Parameter(required = true)
85 private File modulePath;
86
87 @Inject
88 public JModHashMojo(ToolchainManager toolchainManager) {
89 super(toolchainManager);
90 }
91
92 public void execute() throws MojoExecutionException, MojoFailureException {
93
94 String jModExecutable;
95 try {
96 jModExecutable = getJModExecutable();
97 } catch (IOException e) {
98 throw new MojoFailureException("Unable to find jmod command: " + e.getMessage(), e);
99 }
100
101 Commandline cmd = createJModHashCommandLine();
102 cmd.setExecutable(jModExecutable);
103
104
105
106 }
107
108 private Commandline createJModHashCommandLine() {
109 Commandline cmd = new Commandline();
110
111 cmd.createArg().setValue("hash");
112
113 if (dryRun) {
114 cmd.createArg().setValue("--dry-run");
115 }
116
117 return cmd;
118 }
119 }