1 package org.codehaus.mojo.webstart;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugins.annotations.Component;
25 import org.apache.maven.plugins.annotations.LifecyclePhase;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.shared.jarsigner.JarSignerUtil;
29 import org.codehaus.mojo.webstart.sign.SignTool;
30
31 import java.io.File;
32
33
34
35
36
37
38
39
40
41
42 @Mojo( name = "unsign", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = false )
43 public class JarUnsignMojo
44 extends AbstractMojo
45 {
46
47
48
49
50
51
52
53
54 @Parameter( property = "maven.jar.unsign.skip", defaultValue = "false" )
55 private boolean skip;
56
57
58
59
60
61
62 @Parameter( property = "tempdir", defaultValue = "${basedir}", required = true )
63 private File tempDirectory;
64
65
66
67
68
69 @Parameter( alias = "jarpath", property = "maven.jar.unsign.jarpath",
70 defaultValue = "${project.build.directory}/${project.build.finalName}.${project.packaging}" )
71 private File jarPath;
72
73
74
75
76 @Parameter( property = "verbose", defaultValue = "false" )
77 private boolean verbose;
78
79
80
81
82
83
84
85
86 @Component
87 private SignTool signTool;
88
89
90
91
92
93
94
95
96 public void execute()
97 throws MojoExecutionException
98 {
99 if ( skip )
100 {
101 getLog().info( "Skipping JAR unsigning for file: " + jarPath.getAbsolutePath() );
102 return;
103 }
104 if ( jarPath.isDirectory() )
105 {
106 for ( File jar : jarPath.listFiles() ) {
107 if ( JarSignerUtil.isZipFile( jar ) ) {
108 signTool.unsign( jar, verbose );
109 }
110 else
111 {
112 getLog().info( "Skipping JAR unsigning for file: " + jar.getAbsolutePath() );
113 }
114 }
115 }
116 else
117 {
118 signTool.unsign( this.jarPath, verbose );
119 }
120 }
121
122
123
124
125
126 public void setJarPath( File jarPath )
127 {
128 this.jarPath = jarPath;
129 }
130
131 public void setVerbose( boolean verbose )
132 {
133 this.verbose = verbose;
134 }
135
136 public void setSignTool( SignTool signTool )
137 {
138 this.signTool = signTool;
139 }
140
141 }