From 0210293f62054095ce1aa90d65a40b199f8a91e2 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Sat, 25 Apr 2020 14:16:58 +0200 Subject: [PATCH] Bootstrap resolve: if the path specified with '-f' is a directory then append 'pom.xml' instead of returning its original value as a pom.xml path --- .../resolver/maven/BootstrapMavenContext.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java index 0a155df846d78..e3ced3095f485 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java @@ -244,7 +244,7 @@ private LocalProject resolveCurrentProject() throws AppModelResolverException { try { return LocalProject.loadWorkspace(this); } catch (BootstrapException e) { - throw new AppModelResolverException("Failed to load current project at " + getCurrentProjectPomOrNull()); + throw new AppModelResolverException("Failed to load current project at " + getCurrentProjectPomOrNull(), e); } } @@ -635,11 +635,7 @@ private Path resolveCurrentPom() { if (alternatePomName != null) { alternatePom = Paths.get(alternatePomName); if (alternatePom.isAbsolute()) { - Path pom = alternatePom; - if (Files.isDirectory(pom)) { - pom = pom.resolve("pom.xml"); - } - return Files.exists(pom) ? pom : null; + return pomXmlOrNull(alternatePom); } } @@ -684,26 +680,25 @@ private Path resolveCurrentPom() { // we are not in the context of a Maven build if (alternatePom != null && alternatePom.isAbsolute()) { - return alternatePom; + return pomXmlOrNull(alternatePom); } // trying the current dir as the basedir final Path basedir = Paths.get("").normalize().toAbsolutePath(); if (alternatePom != null) { - Path pom = basedir.resolve(alternatePom); - if (Files.exists(pom)) { - if (Files.isDirectory(pom)) { - pom = pom.resolve("pom.xml"); - return Files.exists(pom) ? pom : null; - } - return pom; - } - return null; + return pomXmlOrNull(basedir.resolve(alternatePom)); } final Path pom = basedir.resolve("pom.xml"); return Files.exists(pom) ? pom : null; } + private static Path pomXmlOrNull(Path path) { + if (Files.isDirectory(path)) { + path = path.resolve("pom.xml"); + } + return Files.exists(path) ? path : null; + } + public Path getCurrentProjectBaseDir() { if (currentProject != null) { return currentProject.getDir();