diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f6385bf0..f6533f55 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,21 +11,23 @@ jobs: env: MAVEN_ARGS: --batch-mode --color=always --no-transfer-progress --settings=.github/settings.xml steps: - - run: git config --global user.name "${{ vars.KOKUWA_IO_BOT_NAME }}" - - run: git config --global user.email "${{ vars.KOKUWA_IO_BOT_EMAIL }}" - uses: actions/checkout@v4 with: token: ${{ secrets.GIT_ACTION_TOKEN }} - uses: actions/setup-java@v4 with: distribution: temurin - java-version: 11 + java-version: 17 cache: maven + server-id: sonatype-nexus + server-username: SERVER_USERNAME + server-password: SERVER_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE - run: mvn $MAVEN_ARGS dependency:go-offline - run: mvn $MAVEN_ARGS deploy env: SERVER_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} SERVER_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} - - run: mvn $MAVEN_ARGS site-deploy - env: GIT_ACTION_TOKEN: ${{ secrets.GIT_ACTION_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d30ee2df..052206e2 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -30,12 +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 - - run: mvn $MAVEN_ARGS site - - uses: actions/upload-artifact@v4 - if: always() - with: - path: target/site + - run: mvn $MAVEN_ARGS verify -Dgpg.skip diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7e52f00f..0e5bda9c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.justfile b/.justfile new file mode 100644 index 00000000..65d106d5 --- /dev/null +++ b/.justfile @@ -0,0 +1,48 @@ +# https://just.systems/man/en/ + +_default: + @just --list --unsorted + +set fallback + +MVN := "mvn --batch-mode --color=always --no-transfer-progress -Dmaven.plugin.validation=NONE" + +# Lints java, yaml and markdown files +@lint: + {{MVN}} --quiet tidy:check impsort:check formatter:validate + docker run --rm --read-only --volume $(pwd):/tmp pipelinecomponents/yamllint --config-file /tmp/.yamllint --strict /tmp + docker run --rm --read-only --volume $(pwd):/tmp tmknom/markdownlint --config /tmp/.markdownlint.yaml /tmp + +# Fix java and markdown files +@fix: + {{MVN}} tidy:pom impsort:sort formatter:format + docker run --rm --read-only --user $(id -u):$(id -g) --volume $(pwd):/tmp tmknom/markdownlint --config /tmp/.markdownlint.yaml --fix /tmp + +# Update maven dependencies +@update: + {{MVN}} versions:update-properties + +# Build project without surefire/invoker tests +@build: + {{MVN}} verify -Dmaven.test.skip.exec -Dinvoker.skip + +# Build project +@verify: + {{MVN}} verify + +# Deploy jar to sonatype snapshot repository +@deploy: + {{MVN}} deploy -Pdeploy + +# Run release as dry-run without tests +@release-dryrun: + {{MVN}} release:clean + {{MVN}} release:prepare -DpushChanges=false -DpreparationGoals="clean verify -Dmaven.test.skip -Dinvoker.skip" + {{MVN}} release:perform -DlocalCheckout -Dgoals="clean deploy -Dmaven.test.skip -Dinvoker.skip -DskipNexusStagingDeployMojo" + git fetch --prune --prune-tags # remove local tag + +# Run release and publish to maven central +@release-run: + {{MVN}} release:clean + {{MVN}} release:prepare + {{MVN}} release:perform diff --git a/pom.xml b/pom.xml index 3397b6ce..151b1f23 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,9 @@ 4.0.0 - - io.kokuwa.maven - maven-parent - 0.6.17 - - - + io.kokuwa.maven k3s-maven-plugin - 1.4.1-SNAPSHOT + 2.0.0-SNAPSHOT maven-plugin k3s Maven Plugin @@ -34,7 +28,7 @@ sschnabe Stephan Schnabel https://github.com/sschnabe - stephan@grayc.de + stephan.schnabel@@posteo.de GrayC GmbH https://grayc.de Europe/Berlin @@ -45,7 +39,7 @@ - ${version.org.apache.maven.plugin} + ${version.org.apache.maven.plugin.api} @@ -62,6 +56,16 @@ github https://github.com/kokuwaio/k3s-maven-plugin/actions + + + sonatype-nexus + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + sonatype-nexus + https://oss.sonatype.org/content/repositories/snapshots/ + + @@ -69,13 +73,34 @@ - 11 - 11 + UTF-8 + + 17 + 17 + 3.9.9 + 3.13.0 + 3.1.3 + 3.2.6 + 3.1.3 + 3.8.0 + 3.10.0 + 3.4.2 + 3.15.0 + 3.1.1 + 3.3.1 + 3.3.1 + 3.5.0 + 1.3.0 + 2.17.1 + 1.7.0 + 2.24.1 + 1.12.0 + 5.11.0 1.7.36 2.17.2 @@ -88,11 +113,13 @@ org.apache.maven maven-plugin-api + ${version.org.apache.maven.plugin.api} provided org.apache.maven.plugin-tools maven-plugin-annotations + ${version.org.apache.maven.plugins.plugin} provided @@ -122,30 +149,168 @@ ${version.org.slf4j} test - - org.eclipse.sisu - org.eclipse.sisu.plexus - test - + + + + org.apache.maven.plugins + maven-compiler-plugin + ${version.org.apache.maven.plugins.compiler} + + -Xlint:all,-processing + true + true + true + + + + org.apache.maven.plugins + maven-deploy-plugin + ${version.org.apache.maven.plugins.deploy} + + + org.apache.maven.plugins + maven-gpg-plugin + ${version.org.apache.maven.plugins.gpg} + + + org.apache.maven.plugins + maven-install-plugin + ${version.org.apache.maven.plugins.install} + + + org.apache.maven.plugins + maven-invoker-plugin + ${version.org.apache.maven.plugins.invoker} + + true + + + + org.apache.maven.plugins + maven-jar-plugin + ${version.org.apache.maven.plugins.jar} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${version.org.apache.maven.plugins.javadoc} + + + org.apache.maven.plugins + maven-release-plugin + ${version.org.apache.maven.plugins.release} + + --no-transfer-progress -Dmaven.plugin.validation=NONE --color=ALWAYS + @{prefix} prepare release @{releaseLabel} [no ci] + true + deploy,release + @{project.version} + + + + org.apache.maven.plugins + maven-resources-plugin + ${version.org.apache.maven.plugins.resources} + + + org.apache.maven.plugins + maven-plugin-plugin + ${version.org.apache.maven.plugins.plugin} + + java-annotations + + + + org.apache.maven.plugins + maven-source-plugin + ${version.org.apache.maven.plugins.source} + + + org.apache.maven.plugins + maven-surefire-plugin + ${version.org.apache.maven.plugins.surefire} + + true + + + + org.codehaus.mojo + tidy-maven-plugin + ${version.org.codehaus.mojo.tidy} + + + org.codehaus.mojo + versions-maven-plugin + ${version.org.codehaus.mojo.versions} + + false + + .*-(alpha|beta|rc)-?[0-9]+ + + + + + + org.apache.maven + maven-plugin-api + + + regex + .* + + + + + + org.slf4j + slf4j-api + + + regex + .* + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${version.org.sonatype.plugins.nexus-staging} + + sonatype-nexus + https://oss.sonatype.org/ + true + + + + net.revelc.code.formatter + formatter-maven-plugin + ${version.net.revelc.code.formatter} + + ${project.basedir}/src/main/eclipse/formatter.xml + + + + net.revelc.code + impsort-maven-plugin + ${version.net.revelc.code.impsort} + + java.,javax.,jakarta. + true + true + + + + - - - org.apache.maven.plugins - maven-plugin-plugin - - - - helpmojo - - - - - org.apache.maven.plugins @@ -166,6 +331,220 @@ + + + org.apache.maven.plugins + maven-resources-plugin + + + default-resources + + + + + + org.apache.maven.plugins + maven-install-plugin + + + default-install + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + default-addPluginArtifactMetadata + + + + + + + + + format + + + + + + org.codehaus.mojo + tidy-maven-plugin + + + validate + + pom + + + + + + + + net.revelc.code + impsort-maven-plugin + + + validate + + sort + + + + + + net.revelc.code.formatter + formatter-maven-plugin + + + validate + + format + + + + + + + + + + check + + + !check.skip + + + + + + + + org.codehaus.mojo + tidy-maven-plugin + + + validate + + check + + + + + + + + net.revelc.code + impsort-maven-plugin + + + validate + + check + + + + + + net.revelc.code.formatter + formatter-maven-plugin + + + validate + + validate + + + + + + + + + + deploy + + + env.CI + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + + helpmojo + + + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + jar + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + + sign + + + + + + + + + + release + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + true + + + + + + diff --git a/src/it/pod-with-local-image-from-docker/pom.xml b/src/it/pod-with-local-image-from-docker/pom.xml index 5d0ff946..19281c07 100644 --- a/src/it/pod-with-local-image-from-docker/pom.xml +++ b/src/it/pod-with-local-image-from-docker/pom.xml @@ -43,7 +43,7 @@ com.google.cloud.tools jib-maven-plugin - 3.2.1 + 3.4.2 package @@ -51,9 +51,6 @@ dockerBuild - - gcr.io/distroless/java:${maven.compiler.target}-nonroot - ${project.artifactId} diff --git a/src/it/pod-with-local-image-from-tar/pom.xml b/src/it/pod-with-local-image-from-tar/pom.xml index ba8d510a..7d553495 100644 --- a/src/it/pod-with-local-image-from-tar/pom.xml +++ b/src/it/pod-with-local-image-from-tar/pom.xml @@ -42,7 +42,7 @@ com.google.cloud.tools jib-maven-plugin - 3.2.1 + 3.4.2 package @@ -50,9 +50,6 @@ buildTar - - gcr.io/distroless/java:${maven.compiler.target}-nonroot - ${project.artifactId} diff --git a/src/main/eclipse/formatter.xml b/src/main/eclipse/formatter.xml new file mode 100644 index 00000000..b0c23b12 --- /dev/null +++ b/src/main/eclipse/formatter.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java b/src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java index 6f2b9ee4..e871c0a1 100644 --- a/src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java +++ b/src/main/java/io/kokuwa/maven/k3s/mojo/ApplyMojo.java @@ -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; @@ -18,14 +17,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import io.kokuwa.maven.k3s.util.Await; +import io.kokuwa.maven.k3s.util.Task; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import io.kokuwa.maven.k3s.util.Await; -import io.kokuwa.maven.k3s.util.Task; - /** * Mojo for kubectl apply. * @@ -230,11 +228,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) { diff --git a/src/main/java/io/kokuwa/maven/k3s/mojo/ImageMojo.java b/src/main/java/io/kokuwa/maven/k3s/mojo/ImageMojo.java index cc4cb071..ce770ac1 100644 --- a/src/main/java/io/kokuwa/maven/k3s/mojo/ImageMojo.java +++ b/src/main/java/io/kokuwa/maven/k3s/mojo/ImageMojo.java @@ -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; @@ -19,13 +18,12 @@ import java.util.stream.Stream; import java.util.zip.Adler32; +import io.kokuwa.maven.k3s.util.Docker.ContainerImage; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import io.kokuwa.maven.k3s.util.Docker.ContainerImage; - /** * Import images into k3s containerd. * @@ -228,8 +226,8 @@ private boolean docker(Map> 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); @@ -275,11 +273,11 @@ public void setCtrImages(List ctrImages) { } public void setDockerImages(List dockerImages) { - this.dockerImages = dockerImages.stream().collect(Collectors.toSet()); + this.dockerImages = Set.copyOf(dockerImages); } public void setTarFiles(List 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) { diff --git a/src/main/java/io/kokuwa/maven/k3s/mojo/K3sMojo.java b/src/main/java/io/kokuwa/maven/k3s/mojo/K3sMojo.java index e838f51a..f545832b 100644 --- a/src/main/java/io/kokuwa/maven/k3s/mojo/K3sMojo.java +++ b/src/main/java/io/kokuwa/maven/k3s/mojo/K3sMojo.java @@ -3,15 +3,14 @@ import java.io.File; import java.nio.file.Path; +import io.kokuwa.maven.k3s.util.Docker; +import io.kokuwa.maven.k3s.util.Marker; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Parameter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.kokuwa.maven.k3s.util.Docker; -import io.kokuwa.maven.k3s.util.Marker; - /** * Base class for all mojos of this plugin. * diff --git a/src/main/java/io/kokuwa/maven/k3s/mojo/RunMojo.java b/src/main/java/io/kokuwa/maven/k3s/mojo/RunMojo.java index f2791bd8..a4920e6e 100644 --- a/src/main/java/io/kokuwa/maven/k3s/mojo/RunMojo.java +++ b/src/main/java/io/kokuwa/maven/k3s/mojo/RunMojo.java @@ -10,13 +10,12 @@ import java.util.List; import java.util.stream.Collectors; +import io.kokuwa.maven.k3s.util.Await; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import io.kokuwa.maven.k3s.util.Await; - /** * Mojo for start k3s container. * @@ -226,7 +225,7 @@ public class RunMojo extends K3sMojo { public void execute() throws MojoExecutionException { // check dns - + if (dnsResolverCheck) { try { var address = InetAddress.getByName(dnsResolverDomain).getHostAddress(); diff --git a/src/main/java/io/kokuwa/maven/k3s/util/Docker.java b/src/main/java/io/kokuwa/maven/k3s/util/Docker.java index f1c03ad8..7fbcf399 100644 --- a/src/main/java/io/kokuwa/maven/k3s/util/Docker.java +++ b/src/main/java/io/kokuwa/maven/k3s/util/Docker.java @@ -10,14 +10,13 @@ import java.util.Optional; import java.util.function.Function; -import org.apache.maven.plugin.MojoExecutionException; -import org.slf4j.Logger; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.maven.plugin.MojoExecutionException; +import org.slf4j.Logger; /** * Wrapper for docker commands. diff --git a/src/test/java/io/kokuwa/maven/k3s/LifecycleTest.java b/src/test/java/io/kokuwa/maven/k3s/LifecycleTest.java index 49926c4c..62f13059 100644 --- a/src/test/java/io/kokuwa/maven/k3s/LifecycleTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/LifecycleTest.java @@ -5,14 +5,13 @@ import java.io.File; import java.util.List; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - import io.kokuwa.maven.k3s.mojo.ApplyMojo; import io.kokuwa.maven.k3s.mojo.ImageMojo; import io.kokuwa.maven.k3s.mojo.RemoveMojo; import io.kokuwa.maven.k3s.mojo.RunMojo; import io.kokuwa.maven.k3s.test.AbstractTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; /** * Test fof all mojos to simulate test lifecycle. diff --git a/src/test/java/io/kokuwa/maven/k3s/mojo/ApplyMojoTest.java b/src/test/java/io/kokuwa/maven/k3s/mojo/ApplyMojoTest.java index 2b430c0b..70e2ec5b 100644 --- a/src/test/java/io/kokuwa/maven/k3s/mojo/ApplyMojoTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/mojo/ApplyMojoTest.java @@ -4,12 +4,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import io.kokuwa.maven.k3s.test.AbstractTest; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.kokuwa.maven.k3s.test.AbstractTest; - /** * Test for {@link ApplyMojo}. * diff --git a/src/test/java/io/kokuwa/maven/k3s/mojo/ImageMojoTest.java b/src/test/java/io/kokuwa/maven/k3s/mojo/ImageMojoTest.java index 1064f517..9d29ff8f 100644 --- a/src/test/java/io/kokuwa/maven/k3s/mojo/ImageMojoTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/mojo/ImageMojoTest.java @@ -8,16 +8,15 @@ 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; +import io.kokuwa.maven.k3s.test.AbstractTest; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.kokuwa.maven.k3s.test.AbstractTest; - /** * Test for {@link ImageMojo}. * @@ -107,14 +106,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); @@ -124,7 +123,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); } diff --git a/src/test/java/io/kokuwa/maven/k3s/mojo/RemoveMojoTest.java b/src/test/java/io/kokuwa/maven/k3s/mojo/RemoveMojoTest.java index 044b9c45..da9e19d5 100644 --- a/src/test/java/io/kokuwa/maven/k3s/mojo/RemoveMojoTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/mojo/RemoveMojoTest.java @@ -4,12 +4,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import io.kokuwa.maven.k3s.test.AbstractTest; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.kokuwa.maven.k3s.test.AbstractTest; - /** * Test for {@link RemoveMojo}. * diff --git a/src/test/java/io/kokuwa/maven/k3s/mojo/RestartMojoTest.java b/src/test/java/io/kokuwa/maven/k3s/mojo/RestartMojoTest.java index 48a666b9..1dfc7383 100644 --- a/src/test/java/io/kokuwa/maven/k3s/mojo/RestartMojoTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/mojo/RestartMojoTest.java @@ -7,12 +7,11 @@ import java.util.List; +import io.kokuwa.maven.k3s.test.AbstractTest; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.kokuwa.maven.k3s.test.AbstractTest; - /** * Test for {@link RestartMojo}. * diff --git a/src/test/java/io/kokuwa/maven/k3s/mojo/RunMojoTest.java b/src/test/java/io/kokuwa/maven/k3s/mojo/RunMojoTest.java index 73de461a..6fc4e170 100644 --- a/src/test/java/io/kokuwa/maven/k3s/mojo/RunMojoTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/mojo/RunMojoTest.java @@ -11,15 +11,14 @@ import java.io.File; import java.util.List; -import org.apache.maven.plugin.MojoExecutionException; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; - import io.kokuwa.maven.k3s.test.AbstractTest; import io.kokuwa.maven.k3s.test.LoggerCapturer; import io.kokuwa.maven.k3s.util.Await; import io.kokuwa.maven.k3s.util.Task; +import org.apache.maven.plugin.MojoExecutionException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; /** * Test for {@link RunMojo}. diff --git a/src/test/java/io/kokuwa/maven/k3s/test/AbstractTest.java b/src/test/java/io/kokuwa/maven/k3s/test/AbstractTest.java index 226e477a..46f14015 100644 --- a/src/test/java/io/kokuwa/maven/k3s/test/AbstractTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/test/AbstractTest.java @@ -10,6 +10,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import io.kokuwa.maven.k3s.util.Docker; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -19,8 +20,6 @@ import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.extension.ExtendWith; -import io.kokuwa.maven.k3s.util.Docker; - /** * Base class for all test cases. * diff --git a/src/test/java/io/kokuwa/maven/k3s/test/MojoExtension.java b/src/test/java/io/kokuwa/maven/k3s/test/MojoExtension.java index c3f22779..f19f6c53 100644 --- a/src/test/java/io/kokuwa/maven/k3s/test/MojoExtension.java +++ b/src/test/java/io/kokuwa/maven/k3s/test/MojoExtension.java @@ -9,6 +9,8 @@ import java.util.Set; import java.util.stream.Stream; +import io.kokuwa.maven.k3s.mojo.K3sMojo; +import io.kokuwa.maven.k3s.util.Docker; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.junit.jupiter.api.extension.BeforeAllCallback; @@ -20,9 +22,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.kokuwa.maven.k3s.mojo.K3sMojo; -import io.kokuwa.maven.k3s.util.Docker; - /** * JUnit extension to provide prepared mojos as test parameter. * @@ -42,7 +41,7 @@ public void beforeAll(ExtensionContext context) throws Exception { try (var inputStream = K3sMojo.class.getResourceAsStream("/META-INF/maven/plugin.xml");) { assertNotNull(inputStream, "Plugin descriptor for not found, run 'mvn plugin:descriptor'."); new PluginDescriptorBuilder() - .build(new StringReader( new String(inputStream.readAllBytes()) + .build(new StringReader(new String(inputStream.readAllBytes()) .replaceAll("\\$\\{project.build.directory}", "target") .replaceAll("\\$\\{project.basedir}", "."))) .getMojos().forEach(mojos::add); diff --git a/src/test/java/io/kokuwa/maven/k3s/util/DockerTest.java b/src/test/java/io/kokuwa/maven/k3s/util/DockerTest.java index 195ef3d2..9ce42b6a 100644 --- a/src/test/java/io/kokuwa/maven/k3s/util/DockerTest.java +++ b/src/test/java/io/kokuwa/maven/k3s/util/DockerTest.java @@ -6,20 +6,19 @@ 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; import java.util.function.BiConsumer; +import io.kokuwa.maven.k3s.test.AbstractTest; +import io.kokuwa.maven.k3s.util.Docker.Container; import org.apache.maven.plugin.MojoExecutionException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.slf4j.Logger; -import io.kokuwa.maven.k3s.test.AbstractTest; -import io.kokuwa.maven.k3s.util.Docker.Container; - /** * Test for {@link Docker}. * @@ -112,10 +111,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);