private static String getVersionFromPom ( final Path path ) { Path folder = path ; Path file ; while ( true ) { file = folder . resolve ( "pom.xml" ) ; if ( Files . exists ( file ) ) { break ; } folder = folder . getParent ( ) ; if ( folder == null ) { Logger . error ( "pom.xml is missing for \"{}\"" , path ) ; return null ; } } String content ; try { content = new String ( Files . readAllBytes ( file ) , StandardCharsets . UTF_8 ) ; } catch ( IOException ex ) { Logger . error ( ex , "Failed reading \"{}\"" , path ) ; return null ; } Matcher matcher = POM_VERSION . matcher ( content ) ; if ( matcher . find ( ) ) { return matcher . group ( 1 ) ; } else { Logger . error ( "POM \"{}\" does not contain a version" , file ) ; return null ; } }
Gets the version for a folder by searching for a pom . xml in the folder and its folders .