Skip to content

Commit c332551

Browse files
committed
Support more signjar arguments
1 parent e1fdfb6 commit c332551

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ jarSigner {
9292
}
9393
```
9494

95+
There are more properties expose that match up with the [Ant SignJar Task](https://ant.apache.org/manual/Tasks/signjar.html).
96+
97+
| argument | property | environment |
98+
|---------------|---------------|---------------------|
99+
| verbose | verbose | SIGN_VERBOSE |
100+
| tsaurl | tsaUrl | SIGN_TSA_URL |
101+
| storetype | storeType | SIGN_STORE_TYPE |
102+
| providerclass | providerClass | SIGN_PROVIDER_CLASS |
103+
| providerarg | providerArg | SIGN_PROVIDER_ARG |
104+
95105
### Conclusion
96106

97107
I'm sure there are improvements that could be made, but it works good enough for

src/main/java/net/minecraftforge/gradlejarsigner/GradleJarSignerExtension.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public class GradleJarSignerExtension {
1919
private String keyPass;
2020
private String keyStoreData;
2121
private File keyStoreFile;
22+
private Boolean verbose;
23+
private Boolean preserveLastModified;
24+
private String tsaUrl;
25+
private String storeType;
26+
private String providerClass;
27+
private String providerArg;
2228

2329
public GradleJarSignerExtension(Project project) {
2430
this.project = project;
@@ -49,6 +55,12 @@ public void autoDetect(String prefix) {
4955
set(prefix, "SIGN_KEY_PASSWORD", this::setKeyPass);
5056
set(prefix, "SIGN_KEYSTORE_PASSWORD", this::setStorePass);
5157
set(prefix, "SIGN_KEYSTORE_DATA", this::setKeyStoreData);
58+
set(prefix, "SIGN_VERBOSE", v -> this.setVerbose(Boolean.parseBoolean(v)));
59+
set(prefix, "SIGN_PRESERVE_LAST_MODIFIED", v -> this.setPreserveLastModified(Boolean.parseBoolean(v)));
60+
set(prefix, "SIGN_TSA_URL", this::setTsaUrl);
61+
set(prefix, "SIGN_STORE_TYPE", this::setStoreType);
62+
set(prefix, "SIGN_PROVIDER_CLASS", this::setProviderClass);
63+
set(prefix, "SIGN_PROVIDER_ARG", this::setProviderArg);
5264
}
5365

5466
public void setAlias(String value) {
@@ -77,6 +89,30 @@ public void setKeyStoreFile(File value) {
7789
this.keyStoreFile = value;
7890
}
7991

92+
public void setVerbose(boolean value) {
93+
this.verbose = value;
94+
}
95+
96+
public void setPreserveLastModified(boolean value) {
97+
this.preserveLastModified = value;
98+
}
99+
100+
public void setTsaUrl(String value) {
101+
this.tsaUrl = value;
102+
}
103+
104+
public void setStoreType(String value) {
105+
this.storeType = value;
106+
}
107+
108+
public void setProviderClass(String value) {
109+
this.providerClass = value;
110+
}
111+
112+
public void setProviderArg(String value) {
113+
this.providerArg = value;
114+
}
115+
80116
// Package private because I intentionally don't want getters for key info.
81117
void fill(SignTask task) {
82118
if (this.alias != null)
@@ -89,6 +125,18 @@ void fill(SignTask task) {
89125
task.setKeyStoreData(this.keyStoreData);
90126
if (this.keyStoreFile != null)
91127
task.setKeyStoreFile(this.keyStoreFile);
128+
if (this.verbose != null)
129+
task.setVerbose(this.verbose);
130+
if (this.preserveLastModified != null)
131+
task.setPreserveLastModified(this.preserveLastModified);
132+
if (this.tsaUrl != null)
133+
task.setTsaUrl(this.tsaUrl);
134+
if (this.storeType != null)
135+
task.setStoreType(this.storeType);
136+
if (this.providerClass != null)
137+
task.setProviderClass(this.providerClass);
138+
if (this.providerArg != null)
139+
task.setProviderArg(this.providerArg);
92140
}
93141

94142
private void set(String prefix, String key, Consumer<String> prop) {

src/main/java/net/minecraftforge/gradlejarsigner/SignTask.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public class SignTask implements PatternFilterable {
5252
private final Property<String> keyPass;
5353
private final Property<String> keyStoreData;
5454
private final Property<File> keyStoreFile;
55+
private final Property<Boolean> verbose;
56+
private final Property<Boolean> preserveLastModified;
57+
private final Property<String> tsaUrl;
58+
private final Property<String> storeType;
59+
private final Property<String> providerClass;
60+
private final Property<String> providerArg;
5561
private final PatternSet patternSet = new PatternSet();
5662

5763
@SuppressWarnings("serial")
@@ -69,6 +75,12 @@ public class SignTask implements PatternFilterable {
6975
this.keyPass = objs.property(String.class);
7076
this.keyStoreData = objs.property(String.class);
7177
this.keyStoreFile = objs.property(File.class);
78+
this.verbose = objs.property(Boolean.class);
79+
this.preserveLastModified = objs.property(Boolean.class);
80+
this.tsaUrl = objs.property(String.class);
81+
this.storeType = objs.property(String.class);
82+
this.providerClass = objs.property(String.class);
83+
this.providerArg = objs.property(String.class);
7284

7385
this.parent.configure(new Closure<Object>(parent) {
7486
@SuppressWarnings("unused")
@@ -92,6 +104,12 @@ private Object addProperties() {
92104
in.property("signJar.storePass", this.storePass).optional(true);
93105
in.property("signJar.keyPass", this.keyPass).optional(true);
94106
in.property("signJar.keyStoreData", this.keyStoreData).optional(true);
107+
in.property("signJar.verbose", this.verbose).optional(true);
108+
in.property("signJar.preserveLastModified", this.preserveLastModified).optional(true);
109+
in.property("signJar.tsaUrl", this.tsaUrl).optional(true);
110+
in.property("signJar.storeType", this.storeType).optional(true);
111+
in.property("signJar.providerClass", this.providerClass).optional(true);
112+
in.property("signJar.providerArg", this.providerArg).optional(true);
95113
if (this.keyStoreFile.isPresent())
96114
in.file(this.keyStoreFile);
97115
return null;
@@ -173,6 +191,18 @@ private <T extends Task> void sign(T task) throws IOException {
173191
map.put("keyStore", keyStore.getAbsolutePath());
174192
if (this.keyPass.isPresent())
175193
map.put("keypass", this.keyPass.get());
194+
if (this.verbose.isPresent() && this.verbose.get())
195+
map.put("verbose", Boolean.TRUE.toString());
196+
if (this.preserveLastModified.isPresent() && this.preserveLastModified.get())
197+
map.put("preservelastmodified", Boolean.TRUE.toString());
198+
if (this.tsaUrl.isPresent())
199+
map.put("tsaurl", this.tsaUrl.get());
200+
if (this.storeType.isPresent())
201+
map.put("storetype", this.storeType.get());
202+
if (this.providerClass.isPresent())
203+
map.put("providerclass", this.providerClass.get());
204+
if (this.providerArg.isPresent())
205+
map.put("providerarg", this.providerArg.get());
176206

177207
try {
178208
this.parent.getProject().getAnt().invokeMethod("signjar", map);
@@ -278,6 +308,30 @@ public void setKeyPass(String value) {
278308
this.keyPass.set(value);
279309
}
280310

311+
public void setVerbose(boolean value) {
312+
this.verbose.set(value);
313+
}
314+
315+
public void setPreserveLastModified(boolean value) {
316+
this.preserveLastModified.set(value);
317+
}
318+
319+
public void setTsaUrl(String value) {
320+
this.tsaUrl.set(value);
321+
}
322+
323+
public void setStoreType(String value) {
324+
this.storeType.set(value);
325+
}
326+
327+
public void setProviderClass(String value) {
328+
this.providerClass.set(value);
329+
}
330+
331+
public void setProviderArg(String value) {
332+
this.providerArg.set(value);
333+
}
334+
281335
/**
282336
* A base64 encode string containing the keystore data.
283337
* This will be written to a temporary file and then deleted after the task is run.

0 commit comments

Comments
 (0)