@@ -244,7 +244,7 @@ private LocalProject resolveCurrentProject() throws AppModelResolverException {
244244        try  {
245245            return  LocalProject .loadWorkspace (this );
246246        } catch  (BootstrapException  e ) {
247-             throw  new  AppModelResolverException ("Failed to load current project at "  + getCurrentProjectPomOrNull ());
247+             throw  new  AppModelResolverException ("Failed to load current project at "  + getCurrentProjectPomOrNull (),  e );
248248        }
249249    }
250250
@@ -635,11 +635,7 @@ private Path resolveCurrentPom() {
635635        if  (alternatePomName  != null ) {
636636            alternatePom  = Paths .get (alternatePomName );
637637            if  (alternatePom .isAbsolute ()) {
638-                 Path  pom  = alternatePom ;
639-                 if  (Files .isDirectory (pom )) {
640-                     pom  = pom .resolve ("pom.xml" );
641-                 }
642-                 return  Files .exists (pom ) ? pom  : null ;
638+                 return  pomXmlOrNull (alternatePom );
643639            }
644640        }
645641
@@ -684,26 +680,25 @@ private Path resolveCurrentPom() {
684680
685681        // we are not in the context of a Maven build 
686682        if  (alternatePom  != null  && alternatePom .isAbsolute ()) {
687-             return  alternatePom ;
683+             return  pomXmlOrNull ( alternatePom ) ;
688684        }
689685
690686        // trying the current dir as the basedir 
691687        final  Path  basedir  = Paths .get ("" ).normalize ().toAbsolutePath ();
692688        if  (alternatePom  != null ) {
693-             Path  pom  = basedir .resolve (alternatePom );
694-             if  (Files .exists (pom )) {
695-                 if  (Files .isDirectory (pom )) {
696-                     pom  = pom .resolve ("pom.xml" );
697-                     return  Files .exists (pom ) ? pom  : null ;
698-                 }
699-                 return  pom ;
700-             }
701-             return  null ;
689+             return  pomXmlOrNull (basedir .resolve (alternatePom ));
702690        }
703691        final  Path  pom  = basedir .resolve ("pom.xml" );
704692        return  Files .exists (pom ) ? pom  : null ;
705693    }
706694
695+     private  static  Path  pomXmlOrNull (Path  path ) {
696+         if  (Files .isDirectory (path )) {
697+             path  = path .resolve ("pom.xml" );
698+         }
699+         return  Files .exists (path ) ? path  : null ;
700+     }
701+ 
707702    public  Path  getCurrentProjectBaseDir () {
708703        if  (currentProject  != null ) {
709704            return  currentProject .getDir ();
0 commit comments