Skip to content

Commit

Permalink
Merge pull request quarkusio#8846 from aloubyansky/8842
Browse files Browse the repository at this point in the history
Bootstrap resolve: if the path specified with '-f' is a directory, append 'pom.xml'
  • Loading branch information
gsmet authored Apr 25, 2020
2 parents 1cafe49 + 0210293 commit 6167fae
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6167fae

Please sign in to comment.