public VersionInfo getVersionOfLibrary ( String name , boolean inEmbeddedDir ) throws IOException { Path startPath ; if ( inEmbeddedDir ) { startPath = Paths . get ( embeddedDirectory , name ) ; } else { Path ardDir = getArduinoDirectory ( ) . orElseThrow ( IOException :: new ) ; startPath = ardDir . resolve ( "libraries" ) . resolve ( name ) ; } Path libProps = startPath . resolve ( LIBRARY_PROPERTIES_NAME ) ; if ( ! Files . exists ( libProps ) ) { return new VersionInfo ( "0.0.0" ) ; } Properties propsSrc = new Properties ( ) ; try ( FileReader reader = new FileReader ( libProps . toFile ( ) ) ) { propsSrc . load ( reader ) ; } return new VersionInfo ( propsSrc . getProperty ( "version" , "0.0.0" ) ) ; }
Get the version of a library either from the packaged version or currently installed depending how it s called .