/** * Recursively flags anything that looks like an Android tools executable, as executable. * * @param toolsDir The top level Android SDK tools directory. */ private static final void setPermissions(FilePath toolsDir) throws IOException, InterruptedException { for (FilePath dir : toolsDir.listDirectories()) { setPermissions(dir); } for (FilePath f : toolsDir.list(new ToolFileFilter())) { f.chmod(0755); } }
/** * Downloads and extracts the basic Android SDK on a given Node, if it hasn't already been done. * * @param node Node to install the SDK on. * @return Path where the SDK is installed, regardless of whether it was installed right now. * @throws SdkUnavailableException If the Android SDK is not available on this platform. */ private static FilePath installBasicSdk(final BuildListener listener, Node node) throws SdkUnavailableException, IOException, InterruptedException { // Locate where the SDK should be installed to on this node final FilePath installDir = Utils.getSdkInstallDirectory(node); // Get the OS-specific download URL for the SDK AndroidInstaller installer = AndroidInstaller.fromNode(node); final URL downloadUrl = installer.getUrl(SDK_VERSION); // Download the SDK, if required boolean wasNowInstalled = installDir.act( new FileCallable<Boolean>() { public Boolean invoke(File f, VirtualChannel channel) throws InterruptedException, IOException { String msg = Messages.DOWNLOADING_SDK_FROM(downloadUrl); return installDir.installIfNecessaryFrom(downloadUrl, listener, msg); } private static final long serialVersionUID = 1L; }); if (wasNowInstalled) { // If the SDK was required, pull files up from the intermediate directory installDir.listDirectories().get(0).moveAllChildrenTo(installDir); // Java's ZipEntry doesn't preserve the executable bit... if (installer == AndroidInstaller.MAC_OS_X) { setPermissions(installDir.child("tools")); } // Success! log(listener.getLogger(), Messages.BASE_SDK_INSTALLED()); } return installDir; }