Skip to content

Commit

Permalink
Migrate to java 17, fix #294
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Sep 16, 2024
1 parent baafc94 commit abe4594
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17
cache: maven
- run: mvn $MAVEN_ARGS dependency:go-offline
- run: mvn $MAVEN_ARGS deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17
cache: maven
- run: mvn $MAVEN_ARGS dependency:go-offline
- run: mvn $MAVEN_ARGS verify
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17
cache: maven
server-id: sonatype-nexus
server-username: SERVER_USERNAME
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<!-- ============================== Build ================================ -->
<!-- ===================================================================== -->

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<!-- ===================================================================== -->
<!-- ============================= Versions ============================== -->
Expand Down
5 changes: 1 addition & 4 deletions src/it/pod-with-local-image-from-docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.2.1</version>
<version>3.4.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
<configuration>
<from>
<image>gcr.io/distroless/java:${maven.compiler.target}-nonroot</image>
</from>
<to>
<image>${project.artifactId}</image>
</to>
Expand Down
5 changes: 1 addition & 4 deletions src/it/pod-with-local-image-from-tar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.2.1</version>
<version>3.4.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>buildTar</goal>
</goals>
<configuration>
<from>
<image>gcr.io/distroless/java:${maven.compiler.target}-nonroot</image>
</from>
<to>
<image>${project.artifactId}</image>
</to>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -230,11 +229,11 @@ public void setManifests(File manifests) {
}

public void setPath(String path) {
this.path = Paths.get(path);
this.path = Path.of(path);
}

public void setSubdir(String subdir) {
this.subdir = subdir == null ? null : Paths.get(subdir);
this.subdir = subdir == null ? null : Path.of(subdir);
}

public void setTimeout(int timeout) {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/io/kokuwa/maven/k3s/mojo/ImageMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -228,8 +227,8 @@ private boolean docker(Map<String, Map<String, ?>> existingImages, String image)

// move from docker to ctr

var filename = Paths.get(image.hashCode() + ".tar");
var source = Paths.get(System.getProperty("java.io.tmpdir")).resolve(filename);
var filename = Path.of(image.hashCode() + ".tar");
var source = Path.of(System.getProperty("java.io.tmpdir")).resolve(filename);
var destination = "/tmp/" + filename;
try {
getDocker().saveImage(image, source);
Expand Down Expand Up @@ -275,11 +274,11 @@ public void setCtrImages(List<String> ctrImages) {
}

public void setDockerImages(List<String> dockerImages) {
this.dockerImages = dockerImages.stream().collect(Collectors.toSet());
this.dockerImages = Set.copyOf(dockerImages);
}

public void setTarFiles(List<String> tarFiles) {
this.tarFiles = tarFiles.stream().map(Paths::get).map(Path::toAbsolutePath).collect(Collectors.toSet());
this.tarFiles = tarFiles.stream().map(Path::of).map(Path::toAbsolutePath).collect(Collectors.toSet());
}

public void setDockerPullAlways(boolean dockerPullAlways) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/io/kokuwa/maven/k3s/mojo/ImageMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.List;

Expand Down Expand Up @@ -107,14 +107,14 @@ void dockerImages(RunMojo runMojo, ImageMojo imageMojo) throws MojoExecutionExce
@Test
void tarFiles(RunMojo runMojo, ImageMojo imageMojo) throws MojoExecutionException, IOException {

var tarFile = Paths.get("target/test-classes/tarFile.tar");
var tarFile = Path.of("target/test-classes/tarFile.tar");
imageMojo.setTarFiles(List.of(tarFile.toString()));
assertDoesNotThrow(runMojo::execute);

// import image

assertCtrImage(helloWorld(), false);
Files.copy(Paths.get("src/test/resources/hello-world.tar"), tarFile, StandardCopyOption.REPLACE_EXISTING);
Files.copy(Path.of("src/test/resources/hello-world.tar"), tarFile, StandardCopyOption.REPLACE_EXISTING);
assertDoesNotThrow(imageMojo::execute);
assertCtrImage(helloWorld(), true);

Expand All @@ -124,7 +124,7 @@ void tarFiles(RunMojo runMojo, ImageMojo imageMojo) throws MojoExecutionExceptio

// reimport because file changed

Files.copy(Paths.get("src/test/resources/hello-world.tar.old"), tarFile, StandardCopyOption.REPLACE_EXISTING);
Files.copy(Path.of("src/test/resources/hello-world.tar.old"), tarFile, StandardCopyOption.REPLACE_EXISTING);
assertDoesNotThrow(imageMojo::execute);
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/io/kokuwa/maven/k3s/util/DockerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -112,10 +112,10 @@ void copy() throws MojoExecutionException, IOException {

// define test data

var containerDir = Paths.get("/k3s-data");
var sourceDir = Paths.get("target", "docker-copy", "source");
var containerDir = Path.of("/k3s-data");
var sourceDir = Path.of("target", "docker-copy", "source");
var sourceFile = sourceDir.resolve("test.txt");
var returnDir = Paths.get("target", "docker-copy", "return");
var returnDir = Path.of("target", "docker-copy", "return");
var returnFile = sourceDir.resolve("test.txt");
Files.createDirectories(sourceDir);
Files.createDirectories(returnDir);
Expand Down

0 comments on commit abe4594

Please sign in to comment.