From 5fe556e480f0ca6304d9172de2766d15e02d31b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Fri, 22 Nov 2024 13:03:58 +0100 Subject: [PATCH] Refactor bit pom preparer and custom build detection --- .../quarkus/test/plugin/preparer/PreparePomMojo.java | 12 ++++++------ .../quarkus/QuarkusMavenPluginBuildHelper.java | 10 ++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/plugins/test-preparer/src/main/java/io/quarkus/test/plugin/preparer/PreparePomMojo.java b/plugins/test-preparer/src/main/java/io/quarkus/test/plugin/preparer/PreparePomMojo.java index 1bb6848f2..64a07d798 100644 --- a/plugins/test-preparer/src/main/java/io/quarkus/test/plugin/preparer/PreparePomMojo.java +++ b/plugins/test-preparer/src/main/java/io/quarkus/test/plugin/preparer/PreparePomMojo.java @@ -104,13 +104,13 @@ private static void propagateMavenPomProperties(Model newPomModel, MavenProject "POM file property '" + propertyKey + "' is required but could not found"); } newPomModel.getProperties().setProperty(propertyKey, propertyValue); - if (project.getProperties().getProperty(MAVEN_COMPILER_RELEASE) != null) { - newPomModel.getProperties().setProperty(MAVEN_COMPILER_RELEASE, - project.getProperties().getProperty(MAVEN_COMPILER_RELEASE)); - } else { - newPomModel.getProperties().setProperty(MAVEN_COMPILER_RELEASE, Integer.toString(Runtime.version().feature())); - } }); + if (project.getProperties().getProperty(MAVEN_COMPILER_RELEASE) != null) { + newPomModel.getProperties().setProperty(MAVEN_COMPILER_RELEASE, + project.getProperties().getProperty(MAVEN_COMPILER_RELEASE)); + } else { + newPomModel.getProperties().setProperty(MAVEN_COMPILER_RELEASE, Integer.toString(Runtime.version().feature())); + } } private static void addCurrentProjectPlugins(Model newPomModel, Model rawCurrentProjectModel, MavenProject project) { diff --git a/quarkus-test-core/src/main/java/io/quarkus/test/services/quarkus/QuarkusMavenPluginBuildHelper.java b/quarkus-test-core/src/main/java/io/quarkus/test/services/quarkus/QuarkusMavenPluginBuildHelper.java index 83ff10fb3..e6bfebda1 100644 --- a/quarkus-test-core/src/main/java/io/quarkus/test/services/quarkus/QuarkusMavenPluginBuildHelper.java +++ b/quarkus-test-core/src/main/java/io/quarkus/test/services/quarkus/QuarkusMavenPluginBuildHelper.java @@ -285,10 +285,6 @@ Optional buildOrReuseArtifact(Collection additionalArgs) { mavenBuildProjectRoot = prepareMavenProject(appFolder.resolve("mvn-build")); } - final boolean isCustomBuildRequired = TestExecutionProperties.isCustomBuildRequired(resourceBuilder.getContext()); - if (isCustomBuildRequired) { - return buildArtifactWithQuarkusMvnPlugin(mavenBuildProjectRoot, additionalArgs); - } return getArtifact().or(() -> buildArtifactWithQuarkusMvnPlugin(mavenBuildProjectRoot, additionalArgs)); } @@ -394,8 +390,10 @@ private Optional moveToPermanentLocation(Path tempNativeExecutablePath) { } private boolean isCustomBuildRequired() { - return resourceBuilder.requiresCustomBuild() || !forcedDependencies.isEmpty() || !requiredDependencies.isEmpty() - || resourceBuilder.areApplicationPropertiesEnhanced(); + boolean customBuildRequiredImplicitly = resourceBuilder.requiresCustomBuild() || !forcedDependencies.isEmpty() + || !requiredDependencies.isEmpty() || resourceBuilder.areApplicationPropertiesEnhanced(); + boolean customBuildRequiredExplicitly = TestExecutionProperties.isCustomBuildRequired(resourceBuilder.getContext()); + return customBuildRequiredExplicitly || customBuildRequiredImplicitly; } private String[] getBuildCmd(Collection additionalArgs) {