public boolean isInstalled ( ) throws ManagedSdkVerificationException , ManagedSdkVersionMismatchException { if ( getSdkHome ( ) == null ) { return false ; } if ( ! Files . isDirectory ( getSdkHome ( ) ) ) { return false ; } if ( ! Files . isRegularFile ( getGcloudPath ( ) ) ) { return false ; } // Verify the versions match up for fixed version installs if ( version != Version . LATEST ) { try { String versionFileContents = new String ( Files . readAllBytes ( getSdkHome ( ) . resolve ( "VERSION" ) ) , StandardCharsets . UTF_8 ) . trim ( ) ; if ( ! versionFileContents . equals ( version . getVersion ( ) ) ) { throw new ManagedSdkVersionMismatchException ( "Installed sdk version: " + versionFileContents + " does not match expected version: " + version . getVersion ( ) + "." ) ; } } catch ( IOException ex ) { throw new ManagedSdkVerificationException ( ex ) ; } } return true ; }
Simple check to verify Cloud SDK installed by verifying the existence of gcloud .