Skip to content

Commit

Permalink
some code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bmscomp authored and gsmet committed Oct 16, 2023
1 parent 291e0f2 commit 6a2c652
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

public class AbstractDeploymentMojo extends BuildMojo {

Optional<String> deployer = Optional.empty();

@Parameter(property = "quarkus.deployment.dry-run")
boolean dryRun;

Expand All @@ -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();
}
Expand All @@ -58,13 +54,13 @@ protected List<Dependency> forcedDependencies(LaunchMode mode) {
List<Dependency> 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<ImageBuilder> projectBuilders = ImageBuilder.getProjectBuilder(project).stream().map(ImageBuilder::valueOf)
.collect(Collectors.toSet());
Optional<ImageBuilder> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -47,7 +45,7 @@ protected void doExecute() throws MojoExecutionException {
@Override
protected List<Dependency> forcedDependencies(LaunchMode mode) {
List<Dependency> dependencies = new ArrayList<>();
getBuilder().getExtensionArtifact(mavenProject()).ifPresent(d -> dependencies.add(d));
getBuilder().getExtensionArtifact(mavenProject()).ifPresent(dependencies::add);
return dependencies;
}
}
14 changes: 7 additions & 7 deletions devtools/maven/src/main/java/io/quarkus/maven/Deployer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,29 @@ public Optional<ArtifactDependency> 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<Deployer> 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<String> getProjecDeployer(MavenProject project) {
public static Set<String> getProjectDeployer(MavenProject project) {
return project.getDependencies().stream()
.filter(d -> QUARKUS_GROUP_ID.equals(d.getGroupId()))
.map(d -> strip(d.getArtifactId()))
.filter(n -> Arrays.stream(Deployer.values()).anyMatch(e -> e.equals(n)))
.collect(Collectors.toSet());
}

private static final String strip(String s) {
private static String strip(String s) {
return s.replaceAll("^" + Pattern.quote(QUARKUS_PREFIX), "");
}
}
7 changes: 0 additions & 7 deletions devtools/maven/src/main/java/io/quarkus/maven/UpdateMojo.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6a2c652

Please sign in to comment.