Skip to content

Commit b123d01

Browse files
authored
Update to Java 17 (#53)
1 parent c7b9b3b commit b123d01

File tree

19 files changed

+143
-134
lines changed

19 files changed

+143
-134
lines changed

juseppe-cli/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</dependency>
4646

4747
<dependency>
48-
<groupId>com.jayway.restassured</groupId>
48+
<groupId>io.rest-assured</groupId>
4949
<artifactId>rest-assured</artifactId>
5050
<scope>test</scope>
5151
</dependency>

juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/JuseppeCli.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public static void main(String[] args) {
3131
Runnable parse = builder.build().parse(args);
3232
parse.run();
3333

34-
if (parse instanceof JuseppeCommand) {
35-
System.exit(((JuseppeCommand) parse).getExitCode());
34+
if (parse instanceof JuseppeCommand command) {
35+
System.exit(command.getExitCode());
3636
}
3737
}
3838

juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/EnvCommand.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import io.airlift.airline.Command;
44
import ru.lanwen.jenkins.juseppe.props.JuseppeEnvVars.JuseppeEnvEnum;
55

6-
import static java.lang.String.format;
76
import static java.util.stream.Collectors.joining;
87
import static java.util.stream.Stream.of;
98

@@ -16,7 +15,7 @@ public class EnvCommand implements Runnable {
1615
@Override
1716
public void run() {
1817
System.out.println(of(JuseppeEnvEnum.values())
19-
.map(env -> format("\t%s (%s) %n\t\t- %s%n\t\tresolved: %s%n",
18+
.map(env -> "\t%s (%s) %n\t\t- %s%n\t\tresolved: %s%n".formatted(
2019
env.name(), env.mapping(), env.description(), env.resolved()))
2120
.collect(joining("\n"))
2221
);

juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/cli/PrintCertCommand.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99
import java.nio.file.Files;
10-
import java.nio.file.Paths;
10+
import java.nio.file.Path;
1111

1212
import static java.nio.charset.StandardCharsets.UTF_8;
1313

@@ -23,7 +23,7 @@ public class PrintCertCommand implements Runnable {
2323
@Override
2424
public void run() {
2525
try {
26-
Files.readAllLines(Paths.get(Props.populated().getCertPath()), UTF_8).forEach(System.out::println);
26+
Files.readAllLines(Path.of(Props.populated().getCertPath()), UTF_8).forEach(System.out::println);
2727
} catch (IOException e) {
2828
LOG.error("Can't read certificate {}", Props.populated().getCertPath(), e);
2929
}

juseppe-cli/src/main/java/ru/lanwen/jenkins/juseppe/files/WatchFiles.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.nio.file.FileVisitResult;
88
import java.nio.file.Files;
99
import java.nio.file.Path;
10-
import java.nio.file.Paths;
1110
import java.nio.file.SimpleFileVisitor;
1211
import java.nio.file.WatchEvent;
1312
import java.nio.file.WatchKey;
@@ -19,7 +18,6 @@
1918
import ru.lanwen.jenkins.juseppe.gen.UpdateSiteGen;
2019
import ru.lanwen.jenkins.juseppe.props.Props;
2120

22-
import static java.lang.String.format;
2321
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
2422
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
2523
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
@@ -45,9 +43,9 @@ private WatchFiles() {
4543

4644
public WatchFiles configureFor(Props props) throws IOException {
4745
this.props = props;
48-
path = Paths.get(props.getPluginsDir());
46+
path = Path.of(props.getPluginsDir());
4947
this.keys = new HashMap<>();
50-
setName(format("file-watcher-%s", path.getFileName()));
48+
setName("file-watcher-%s".formatted(path.getFileName()));
5149

5250
watcher = this.path.getFileSystem().newWatchService();
5351
walkAndRegisterDirectories(path);

juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeCommandTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.junit.ClassRule;
55
import org.junit.Test;
66

7-
import static com.jayway.restassured.RestAssured.given;
7+
import static io.restassured.RestAssured.given;
88

99
/**
1010
* @author lanwen (Merkushev Kirill)
@@ -21,7 +21,7 @@ public void shouldFetchUpdateCenter() throws Exception {
2121
.log().all()
2222
.expect()
2323
.log().status()
24-
.get("update-center.json").then().assertThat().statusCode(200);
24+
.when().get("update-center.json").then().assertThat().statusCode(200);
2525
}
2626

2727
@Test(timeout = 10000)
@@ -31,7 +31,7 @@ public void shouldFetchHpi() throws Exception {
3131
.log().all()
3232
.expect()
3333
.log().status()
34-
.get("clang-scanbuild-plugin.hpi").then().assertThat().statusCode(200);
34+
.when().get("clang-scanbuild-plugin.hpi").then().assertThat().statusCode(200);
3535
}
3636

3737
@Test(timeout = 10000)
@@ -41,6 +41,6 @@ public void shouldFetchJpi() throws Exception {
4141
.log().all()
4242
.expect()
4343
.log().status()
44-
.get("sample-pipeline-dsl-ext-plugin-0.1.0.jpi").then().assertThat().statusCode(200);
44+
.when().get("sample-pipeline-dsl-ext-plugin-0.1.0.jpi").then().assertThat().statusCode(200);
4545
}
4646
}

juseppe-cli/src/test/java/ru/lanwen/jenkins/juseppe/cli/ServeRule.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.concurrent.CompletableFuture;
1212

1313
import static com.google.common.io.Resources.getResource;
14-
import static java.lang.String.format;
1514

1615
/**
1716
* @author lanwen (Merkushev Kirill)
@@ -45,7 +44,7 @@ protected void after() {
4544
}
4645

4746
public URI uri() {
48-
return URI.create(format("http://localhost:%s", port));
47+
return URI.create("http://localhost:%s".formatted(port));
4948
}
5049

5150
private Integer findRandomOpenPortOnAllLocalInterfaces() throws IOException {
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
-----BEGIN CERTIFICATE-----
2-
MIIDDjCCAfYCCQCxvzbj/rKRGTANBgkqhkiG9w0BAQsFADBJMQswCQYDVQQGEwJF
3-
TjEWMBQGA1UECAwNVXBkYXRlLUNlbnRlcjEQMA4GA1UEBwwHSnVzZXBw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RLV0Bt5SB2SGMhfo9iSuG5AepJj34
21+
VNoKu7vJ5eNLpQLj8+a5WrPl/MV6pxiBbUGwzMKhWzaeaWbXXmSsGbLSiQKBgDKF
22+
HDkgi9KpZiov6JAB5MnE23KgQ5Y7WL6xrbRA7Nrcm+GsqnC2Wz9o2VE06baGwVgv
23+
xhtyTIpayJG7UWpa+KdLlk3V1+qWaQYZuTuBAnrGkatO+MPIAlgNZZpBraboixaD
24+
x+oRQYLfmrFrMBcP8IeXFs5LYCyNlY4xiKeTW/DBAoGAUFt40V1zJslr/K/d8J6Z
25+
sPZPixpJIQMHVnFio7cx7bNIi6zqLk1501LKGtdUiKQ2020QpiMltkFCDcZfuOuo
26+
dECVfd6v4R0ylXseMzQeGOXpfG/Tgpk42XreykPPz/q47nJRnHfuCB6hKbt56JJW
27+
ZryGBu5iFCJPyASvqd0sJvQ=
28+
-----END PRIVATE KEY-----

juseppe-core/pom.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
<artifactId>guava</artifactId>
7878
<scope>test</scope>
7979
</dependency>
80+
81+
<!-- https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api -->
82+
<dependency>
83+
<groupId>jakarta.validation</groupId>
84+
<artifactId>jakarta.validation-api</artifactId>
85+
<version>3.1.0</version>
86+
</dependency>
8087
</dependencies>
8188

8289
<build>
@@ -86,16 +93,20 @@
8693
<plugin>
8794
<groupId>org.jsonschema2pojo</groupId>
8895
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
89-
<version>0.4.7</version>
96+
<version>1.2.2</version>
9097
<configuration>
9198
<sourceDirectory>${project.basedir}/src/main/resources/jsonschema</sourceDirectory>
9299
<outputDirectory>${project.build.directory}/generated-sources/java-gen</outputDirectory>
93100
<targetPackage>ru.lanwen.jenkins.juseppe.beans</targetPackage>
94101
<annotationStyle>gson</annotationStyle>
95102
<includeToString>false</includeToString>
96103
<includeHashcodeAndEquals>false</includeHashcodeAndEquals>
104+
<includeJsr303Annotations>true</includeJsr303Annotations>
105+
<includeJsr305Annotations>false</includeJsr305Annotations>
106+
<useJakartaValidation>true</useJakartaValidation>
97107
<sourceType>jsonschema</sourceType>
98108
<generateBuilders>true</generateBuilders>
109+
<includeGeneratedAnnotation>false</includeGeneratedAnnotation>
99110
</configuration>
100111
<executions>
101112
<execution>

juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/SavableSite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public Path save() {
3434
try {
3535
return Files.write(whereToSave, Collections.singleton(view.content()));
3636
} catch (IOException e) {
37-
throw new RuntimeException(String.format("Can't save json to file %s", whereToSave.toAbsolutePath()), e);
37+
throw new RuntimeException("Can't save json to file %s".formatted(whereToSave.toAbsolutePath()), e);
3838
}
3939
}
4040
}

juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/Signer.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ public Signature sign(UpdateSite site) throws GeneralSecurityException, IOExcept
102102
X509Certificate signer = certs.get(0); // the first one is the signer, and the rest is the chain to a root CA.
103103

104104
Object o = new PEMParser(new FileReader(privateKey)).readObject();
105-
isInstanceOf(PEMKeyPair.class, o, "File %s is not rsa private key!", privateKey);
106-
PrivateKeyInfo key = ((PEMKeyPair) o).getPrivateKeyInfo();
105+
PrivateKeyInfo key;
106+
if(o instanceof PEMKeyPair keyPair) {
107+
key = keyPair.getPrivateKeyInfo();
108+
} else if(o instanceof PrivateKeyInfo) {
109+
key = (PrivateKeyInfo) o;
110+
} else {
111+
throw new IllegalArgumentException(String.format("File %s is not rsa private key!", privateKey));
112+
}
107113

108114
SignatureGenerator signatureGenerator = new SignatureGenerator(signer, key);
109115

juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/UpdateSiteGen.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
import ru.lanwen.jenkins.juseppe.props.Props;
1010

1111
import java.io.IOException;
12-
import java.nio.file.Paths;
12+
import java.nio.file.Path;
1313
import java.security.GeneralSecurityException;
1414
import java.util.ArrayList;
1515
import java.util.Collections;
1616
import java.util.List;
1717
import java.util.function.Consumer;
1818
import java.util.stream.Stream;
1919

20-
import static java.lang.String.format;
2120
import static java.util.Collections.singletonList;
2221
import static java.util.stream.Collectors.toList;
2322
import static ru.lanwen.jenkins.juseppe.props.Props.populated;
@@ -54,11 +53,11 @@ public UpdateSiteGen withDefaults() {
5453
site -> site.withUpdateCenterVersion(Props.UPDATE_CENTER_VERSION)
5554
.withId(props.getUcId())
5655
).register(
57-
site -> Collections.singleton(new PathPluginSource(Paths.get(props.getPluginsDir()), props.getRecursiveWatch()))
56+
site -> Collections.singleton(new PathPluginSource(Path.of(props.getPluginsDir()), props.getRecursiveWatch()))
5857
.forEach(source -> site.getPlugins().addAll(source.plugins()))
5958
).register(
6059
site -> site.getPlugins()
61-
.forEach(plugin -> plugin.setUrl(format("%s/%s", props.getBaseurl(), plugin.getUrl())))
60+
.forEach(plugin -> plugin.setUrl("%s/%s".formatted(props.getBaseurl(), plugin.getUrl())))
6261
).register(
6362
site -> {
6463
try {
@@ -86,7 +85,7 @@ public SavableSitesCollection toSave() {
8685
new JsonpUpdateSite(filled, props.getUcJsonName()),
8786
new ReleaseHistoryUpdateSite(filled, props.getReleaseHistoryJsonName())
8887
)
89-
.map(view -> new SavableSite(Paths.get(props.getSaveto()), view))
88+
.map(view -> new SavableSite(Path.of(props.getSaveto()), view))
9089
.collect(toList());
9190

9291
return new SavableSitesCollection(files);

juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSource.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import ru.lanwen.jenkins.juseppe.beans.Plugin;
1717
import ru.lanwen.jenkins.juseppe.gen.HPI;
1818

19-
import static java.lang.String.format;
20-
2119
/**
2220
* @author lanwen (Merkushev Kirill)
2321
*/
@@ -50,7 +48,7 @@ public List<Plugin> plugins() {
5048
}
5149
}).filter(Objects::nonNull).collect(Collectors.toList());
5250
} catch (IOException e) {
53-
throw new RuntimeException(format("Can't read path %s", pluginsDir.toAbsolutePath()), e);
51+
throw new RuntimeException("Can't read path %s".formatted(pluginsDir.toAbsolutePath()), e);
5452
}
5553
}
5654
}

juseppe-core/src/main/java/ru/lanwen/jenkins/juseppe/gen/view/JsonpUpdateSite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public JsonpUpdateSite(UpdateSite site, String name) {
2525
@Override
2626
public String content() {
2727
String json = UpdateSiteSerializer.serializer().toJson(site);
28-
return String.format("updateCenter.post(%n%s%n);", json);
28+
return "updateCenter.post(%n%s%n);".formatted(json);
2929
}
3030

3131
@Override

juseppe-core/src/test/java/ru/lanwen/jenkins/juseppe/gen/source/PathPluginSourceTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.junit.Test;
44
import ru.lanwen.jenkins.juseppe.beans.Plugin;
55

6-
import java.nio.file.Paths;
6+
import java.nio.file.Path;
77
import java.util.List;
88

99
import static com.google.common.io.Resources.getResource;
@@ -21,7 +21,7 @@ public class PathPluginSourceTest {
2121
@Test
2222
public void shouldFindAllPlugins() throws Exception {
2323
boolean recursiveWatch = false;
24-
List<Plugin> plugins = new PathPluginSource(Paths.get(getResource(PLUGINS_DIR_CLASSPATH).getFile()),
24+
List<Plugin> plugins = new PathPluginSource(Path.of(getResource(PLUGINS_DIR_CLASSPATH).getFile()),
2525
recursiveWatch)
2626
.plugins();
2727

@@ -33,7 +33,7 @@ public void shouldFindAllPlugins() throws Exception {
3333
@Test
3434
public void shouldFindAllPluginsRecursively() throws Exception {
3535
boolean recursiveWatch = true;
36-
List<Plugin> plugins = new PathPluginSource(Paths.get(getResource(PLUGINS_DIR_CLASSPATH).getFile()),
36+
List<Plugin> plugins = new PathPluginSource(Path.of(getResource(PLUGINS_DIR_CLASSPATH).getFile()),
3737
recursiveWatch)
3838
.plugins();
3939

0 commit comments

Comments
 (0)