Skip to content

Commit ac2f3cc

Browse files
authored
merge: upgraded maven plugins for building JDK22, etc. (#6)
2 parents 6c7ca8f + e1ad95e commit ac2f3cc

20 files changed

+171
-140
lines changed

.github/workflows/java-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
javaver: [21]
14+
javaver: [21, 22]
1515
os: [ubuntu-latest, windows-latest, macos-latest]
1616
steps:
1717
- uses: actions/checkout@v4

pom.xml

+12-12
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@
6262
<dependency>
6363
<groupId>org.junit.jupiter</groupId>
6464
<artifactId>junit-jupiter-api</artifactId>
65-
<version>5.11.0-M1</version>
65+
<version>5.10.2</version>
6666
<scope>test</scope>
6767
</dependency>
6868
<dependency>
6969
<groupId>org.junit.jupiter</groupId>
7070
<artifactId>junit-jupiter-engine</artifactId>
71-
<version>5.11.0-M1</version>
71+
<version>5.10.2</version>
7272
<scope>test</scope>
7373
</dependency>
7474
<dependency>
7575
<groupId>org.junit.platform</groupId>
7676
<artifactId>junit-platform-launcher</artifactId>
77-
<version>1.11.0-M1</version>
77+
<version>1.10.2</version>
7878
<scope>test</scope>
7979
</dependency>
8080
<dependency>
@@ -90,7 +90,7 @@
9090
<plugin>
9191
<groupId>org.apache.maven.plugins</groupId>
9292
<artifactId>maven-source-plugin</artifactId>
93-
<version>3.3.0</version>
93+
<version>3.3.1</version>
9494
<executions>
9595
<execution>
9696
<id>attach-sources</id>
@@ -103,7 +103,7 @@
103103
<plugin>
104104
<groupId>org.apache.maven.plugins</groupId>
105105
<artifactId>maven-javadoc-plugin</artifactId>
106-
<version>3.4.1</version>
106+
<version>3.6.3</version>
107107
<configuration>
108108
<author>true</author>
109109
<source>21</source>
@@ -131,7 +131,7 @@
131131
<plugin>
132132
<groupId>org.jacoco</groupId>
133133
<artifactId>jacoco-maven-plugin</artifactId>
134-
<version>0.8.10</version>
134+
<version>0.8.12</version>
135135
<executions>
136136
<execution>
137137
<id>default-prepare-agent</id>
@@ -151,7 +151,7 @@
151151
<plugin>
152152
<groupId>org.apache.maven.plugins</groupId>
153153
<artifactId>maven-compiler-plugin</artifactId>
154-
<version>3.10.1</version>
154+
<version>3.13.0</version>
155155
<configuration>
156156
<compilerArgs>
157157
<arg>-g</arg>
@@ -162,7 +162,7 @@
162162
<plugin>
163163
<groupId>org.apache.maven.plugins</groupId>
164164
<artifactId>maven-surefire-plugin</artifactId>
165-
<version>3.0.0-M7</version>
165+
<version>3.2.5</version>
166166
</plugin>
167167
</plugins>
168168
</build>
@@ -175,7 +175,7 @@
175175
<plugin>
176176
<groupId>org.graalvm.buildtools</groupId>
177177
<artifactId>native-maven-plugin</artifactId>
178-
<version>0.9.19</version>
178+
<version>0.10.1</version>
179179
<extensions>true</extensions>
180180
<executions>
181181
<execution>
@@ -189,7 +189,7 @@
189189
<dependency>
190190
<groupId>org.junit.platform</groupId>
191191
<artifactId>junit-platform-launcher</artifactId>
192-
<version>1.9.1</version>
192+
<version>1.10.2</version>
193193
<scope>test</scope>
194194
</dependency>
195195
</dependencies>
@@ -212,7 +212,7 @@
212212
<profile>
213213
<id>trace</id>
214214
<properties>
215-
<argLine>-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image</argLine>
215+
<argLine>-agentlib:native-image-agent=config-output-dir=target/native-trace/</argLine>
216216
</properties>
217217
</profile>
218218
<profile>
@@ -263,7 +263,7 @@
263263
<plugin>
264264
<groupId>org.apache.maven.plugins</groupId>
265265
<artifactId>maven-gpg-plugin</artifactId>
266-
<version>3.1.0</version>
266+
<version>3.2.4</version>
267267
<executions>
268268
<execution>
269269
<id>sign-artifacts</id>

src/main/java/com/github/sttk/cliargs/Cmd.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public <T> T getOptArg(String name) {
9797
* @param name The option name.
9898
* @return The option arguments of the specified option.
9999
*/
100-
public <T extends List> T getOptArgs(String name) {
100+
public <T extends List<?>> T getOptArgs(String name) {
101101
var list = this.opts.get(name);
102102
if (isEmpty(list)) {
103103
@SuppressWarnings("unchecked")

src/main/java/com/github/sttk/cliargs/OptCfg.java

+36-20
Original file line numberDiff line numberDiff line change
@@ -255,71 +255,82 @@ private static class Init<T> {
255255
*
256256
* @param <T> The type of the option argument value.
257257
*/
258+
@SuppressWarnings("unchecked")
258259
@FunctionalInterface
259260
public interface NamedParam<T> {
260261
/**
261262
* Sets a field value of {@link Init} object that has same fields with
262263
* {@link OptCfg} object and is used to initialized it.
263264
*
264-
* @param init {@link Init} object to initialize {@link OptCfg} object.
265+
* @param init An object to initialize {@link OptCfg} object.
265266
*/
266-
void setTo(Init<T> init);
267+
void setTo(Object init);
267268

268269
/**
269270
* Is the static method to set the {@code storeKey} field like a named
270271
* parameter.
271272
*
273+
* @param <T> The type of the option argument value.
274+
*
272275
* @param storeKey The value of the {@code storeKey} field.
273276
* @return The {@link NamedParam} object for {@code storeKey} field.
274277
*/
275-
static NamedParam storeKey(String storeKey) {
276-
return init -> init.storeKey = storeKey;
278+
static <T> NamedParam<T> storeKey(String storeKey) {
279+
return init -> ((Init<T>)init).storeKey = storeKey;
277280
}
278281

279282
/**
280283
* Is the static method to set the {@code names} field like a named
281284
* parameter.
282285
*
286+
* @param <T> The type of the option argument value.
287+
*
283288
* @param names The string array of the {@code names} field.
284289
* @return The {@link NamedParam} object for {@code storeKey} field.
285290
*/
286291
@SuppressWarnings("unchecked")
287-
static NamedParam names(String ...names) {
288-
return init -> init.names = List.of(names);
292+
static <T> NamedParam<T> names(String ...names) {
293+
return init -> ((Init<T>)init).names = List.of(names);
289294
}
290295

291296
/**
292297
* Is the static method to set the {@code names} field like a named
293298
* parameter.
294299
*
300+
* @param <T> The type of the option argument value.
301+
*
295302
* @param list The string list of the {@code names} field.
296303
* @return The {@link NamedParam} object for {@code storeKey} field.
297304
*/
298305
@SuppressWarnings("unchecked")
299-
static NamedParam names(List<String> list) {
300-
return init -> init.names = list;
306+
static <T> NamedParam<T> names(List<String> list) {
307+
return init -> ((Init<T>)init).names = list;
301308
}
302309

303310
/**
304311
* Is the static method to set the {@code hasArg} field like a named
305312
* parameter.
306313
*
314+
* @param <T> The type of the option argument value.
315+
*
307316
* @param hasArg The value of the {@code hasArg} field.
308317
* @return The {@link NamedParam} object for {@code hasArg} field.
309318
*/
310-
static NamedParam hasArg(boolean hasArg) {
311-
return init -> init.hasArg = hasArg;
319+
static <T> NamedParam<T> hasArg(boolean hasArg) {
320+
return init -> ((Init<T>)init).hasArg = hasArg;
312321
}
313322

314323
/**
315324
* Is the static method to set the {@code isArray} field like a named
316325
* parameter.
317326
*
327+
* @param <T> The type of the option argument value.
328+
*
318329
* @param isArray The value of the {@code isArray} field.
319330
* @return The {@link NamedParam} object for {@code isArray} field.
320331
*/
321-
static NamedParam isArray(boolean isArray) {
322-
return init -> init.isArray = isArray;
332+
static <T> NamedParam<T> isArray(boolean isArray) {
333+
return init -> ((Init<T>)init).isArray = isArray;
323334
}
324335

325336
/**
@@ -332,7 +343,7 @@ static NamedParam isArray(boolean isArray) {
332343
* @return The {@link NamedParam} object for {@code type} field.
333344
*/
334345
static <T> NamedParam<T> type(Class<T> type) {
335-
return init -> init.type = type;
346+
return init -> ((Init<T>)init).type = type;
336347
}
337348

338349
/**
@@ -345,8 +356,9 @@ static <T> NamedParam<T> type(Class<T> type) {
345356
* @return The {@link NamedParam} object for {@code defaults} field.
346357
*/
347358
@SafeVarargs
359+
@SuppressWarnings("varargs")
348360
static <T> NamedParam<T> defaults(T ...defaults) {
349-
return init -> init.defaults = List.of(defaults);
361+
return init -> ((Init<T>)init).defaults = List.of(defaults);
350362
}
351363

352364
/**
@@ -359,29 +371,33 @@ static <T> NamedParam<T> defaults(T ...defaults) {
359371
* @return The {@link NamedParam} object for {@code defaults} field.
360372
*/
361373
static <T> NamedParam<T> defaults(List<T> defaults) {
362-
return init -> init.defaults = defaults;
374+
return init -> ((Init<T>)init).defaults = defaults;
363375
}
364376

365377
/**
366378
* Is the static method to set the {@code desc} field like a named
367379
* parameter.
368380
*
381+
* @param <T> The type of the option argument value.
382+
*
369383
* @param desc The value of the {@code desc} field.
370384
* @return The {@link NamedParam} object for {@code defaults} field.
371385
*/
372-
static NamedParam desc(String desc) {
373-
return init -> init.desc = desc;
386+
static <T> NamedParam<T> desc(String desc) {
387+
return init -> ((Init<T>)init).desc = desc;
374388
}
375389

376390
/**
377391
* Is the static method to set the {@code argInHelp} field like a named
378392
* parameter.
379393
*
394+
* @param <T> The type of the option argument value.
395+
*
380396
* @param argInHelp The value of the {@code argInHelp} field.
381397
* @return The {@link NamedParam} object for {@code argInHelp} field.
382398
*/
383-
static NamedParam argInHelp(String argInHelp) {
384-
return init -> init.argInHelp = argInHelp;
399+
static <T> NamedParam<T> argInHelp(String argInHelp) {
400+
return init -> ((Init<T>)init).argInHelp = argInHelp;
385401
}
386402

387403
/**
@@ -394,7 +410,7 @@ static NamedParam argInHelp(String argInHelp) {
394410
* @return The {@link NamedParam} object for {@code converter} field.
395411
*/
396412
static <T> NamedParam<T> converter(Converter<T> converter) {
397-
return init -> init.converter = converter;
413+
return init -> ((Init<T>)init).converter = converter;
398414
}
399415
}
400416
}

src/main/java/module-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
module com.github.sttk.cliargs {
1111
exports com.github.sttk.cliargs;
1212
exports com.github.sttk.cliargs.convert;
13-
requires com.github.sttk.reasonedexception;
13+
requires transitive com.github.sttk.reasonedexception;
1414
}

src/test/java/com/github/sttk/cliargs/CmdTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Map;
1111
import java.util.HashMap;
1212

13+
@SuppressWarnings("missing-explicit-ctor")
1314
public class CmdTest {
1415

1516
@Test

src/test/java/com/github/sttk/cliargs/OptCfgTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.List;
1616
import java.time.OffsetDateTime;
1717

18+
@SuppressWarnings("missing-explicit-ctor")
1819
public class OptCfgTest {
1920

2021
@Test

0 commit comments

Comments
 (0)