From 6a2c6521ba327b2a3bb47bd23e1b4758cca293a5 Mon Sep 17 00:00:00 2001 From: Said BOUDJELDA Date: Thu, 5 Oct 2023 23:33:51 +0200 Subject: [PATCH] some code cleanups --- .../io/quarkus/maven/AbstractDeploymentMojo.java | 10 +++------- .../java/io/quarkus/maven/AbstractImageMojo.java | 6 ++---- .../src/main/java/io/quarkus/maven/Deployer.java | 14 +++++++------- .../src/main/java/io/quarkus/maven/UpdateMojo.java | 7 ------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/AbstractDeploymentMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/AbstractDeploymentMojo.java index 2979e1d1544bf..66e2e09224469 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/AbstractDeploymentMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/AbstractDeploymentMojo.java @@ -15,8 +15,6 @@ public class AbstractDeploymentMojo extends BuildMojo { - Optional deployer = Optional.empty(); - @Parameter(property = "quarkus.deployment.dry-run") boolean dryRun; @@ -34,9 +32,7 @@ protected void doExecute() throws MojoExecutionException { getLog().info("Deployment configuration:"); systemProperties.entrySet().stream() .filter(e -> e.getKey().contains("quarkus.deployment")) - .forEach(e -> { - getLog().info(" - " + e.getKey() + ": " + e.getValue()); - }); + .forEach(e -> getLog().info(" - " + e.getKey() + ": " + e.getValue())); } else { super.doExecute(); } @@ -58,13 +54,13 @@ protected List forcedDependencies(LaunchMode mode) { List dependencies = new ArrayList<>(); MavenProject project = mavenProject(); Deployer deployer = getDeployer(); - deployer.getExtensionArtifact(project).ifPresent(d -> dependencies.add(d)); + deployer.getExtensionArtifact(project).ifPresent(dependencies::add); if (this.imageBuild || this.imageBuilder != null) { Set projectBuilders = ImageBuilder.getProjectBuilder(project).stream().map(ImageBuilder::valueOf) .collect(Collectors.toSet()); Optional imageBuilder = ImageBuilder.getBuilder(this.imageBuilder, projectBuilders); imageBuilder.filter(b -> !projectBuilders.contains(b)).flatMap(b -> b.getExtensionArtifact(project)) - .ifPresent(d -> dependencies.add(d)); + .ifPresent(dependencies::add); } return dependencies; } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/AbstractImageMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/AbstractImageMojo.java index 702501d0cf67e..e4521b288d030 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/AbstractImageMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/AbstractImageMojo.java @@ -36,9 +36,7 @@ protected void doExecute() throws MojoExecutionException { getLog().info("Container image configuration:"); systemProperties.entrySet().stream() .filter(e -> e.getKey().contains("quarkus.container-image")) - .forEach(e -> { - getLog().info(" - " + e.getKey() + ": " + e.getValue()); - }); + .forEach(e -> getLog().info(" - " + e.getKey() + ": " + e.getValue())); } else { super.doExecute(); } @@ -47,7 +45,7 @@ protected void doExecute() throws MojoExecutionException { @Override protected List forcedDependencies(LaunchMode mode) { List dependencies = new ArrayList<>(); - getBuilder().getExtensionArtifact(mavenProject()).ifPresent(d -> dependencies.add(d)); + getBuilder().getExtensionArtifact(mavenProject()).ifPresent(dependencies::add); return dependencies; } } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/Deployer.java b/devtools/maven/src/main/java/io/quarkus/maven/Deployer.java index 6cfd1d8073298..9999fb9a40595 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/Deployer.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/Deployer.java @@ -61,21 +61,21 @@ public Optional getExtensionArtifact(MavenProject project) { /** * Get the deployer by name or the first one found in the project. * - * @project the project to search for deployer extensions + * @param project the project to search for deployer extensions * @return the {@link Optional} builder matching the name, project. */ public static Optional getDeployer(MavenProject project) { return DeploymentUtil.getEnabledDeployer() - .or(() -> getProjecDeployer(project).stream().findFirst()).map(Deployer::valueOf); + .or(() -> getProjectDeployer(project).stream().findFirst()).map(Deployer::valueOf); } /** - * Get teh deployer extensions found in the project. + * Get the deployer extensions found in the project. * - * @param the project to search for extensions - * @return A set with the discovered extenions. + * @param project The project to search for extensions + * @return A set with the discovered extensions. */ - public static Set getProjecDeployer(MavenProject project) { + public static Set getProjectDeployer(MavenProject project) { return project.getDependencies().stream() .filter(d -> QUARKUS_GROUP_ID.equals(d.getGroupId())) .map(d -> strip(d.getArtifactId())) @@ -83,7 +83,7 @@ public static Set getProjecDeployer(MavenProject project) { .collect(Collectors.toSet()); } - private static final String strip(String s) { + private static String strip(String s) { return s.replaceAll("^" + Pattern.quote(QUARKUS_PREFIX), ""); } } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/UpdateMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/UpdateMojo.java index 4bc790ec24f7f..e5245a161c76d 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/UpdateMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/UpdateMojo.java @@ -1,7 +1,5 @@ package io.quarkus.maven; -import static org.twdata.maven.mojoexecutor.MojoExecutor.*; - import java.util.List; import org.apache.maven.execution.MavenSession; @@ -35,11 +33,6 @@ public class UpdateMojo extends QuarkusProjectStateMojoBase { @Parameter(property = "perModule") boolean perModule; - /** - * If true, instead of checking and recommending the latest available Quarkus platform version, - * recommendations to properly align the current project configuration will be logged (if any) - */ - /** * Version of the target platform (e.g: 2.0.0.Final) * You may instead use streamId to target the latest version of a specific platform stream.