Skip to content
Permalink
Browse files

[FIXED JENKINS-18015] Handle SDK detection with new 'build-tools' com…

…ponent.
  • Loading branch information...
orrc committed Jun 2, 2013
1 parent cb492a4 commit 0f997f47b5acc9bae0740e4d8c80e2fdfbb345fc
@@ -19,7 +19,7 @@
};

public static Tool[] REQUIRED = new Tool[] {
AAPT, ADB, ANDROID, EMULATOR, MKSDCARD
AAPT, ADB, ANDROID, EMULATOR
};

public final String executable;
@@ -47,15 +47,11 @@ public String getExecutable(boolean isUnix) {
return executable + windowsExtension;
}

public static String[] getAllRequiredExecutableVariants() {
return getAllExecutableVariants(REQUIRED);
}

public static String[] getAllExecutableVariants() {
return getAllExecutableVariants(values());
}

private static String[] getAllExecutableVariants(final Tool[] tools) {
public static String[] getAllExecutableVariants(final Tool[] tools) {
String[] executables = new String[tools.length * 2];
for (int i = 0, n = tools.length; i < n; i++) {
executables[i*2] = tools[i].getExecutable(true);
@@ -65,6 +61,7 @@ public String getExecutable(boolean isUnix) {
return executables;
}

@Override
public String toString() {
return executable;
}
@@ -45,6 +45,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.NameFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;

public class Utils {

private static final Pattern REVISION = Pattern.compile("(\\d++).*");
@@ -223,9 +228,7 @@ public static ValidationResult validateAndroidHome(File sdkRoot, boolean fromWeb
return ValidationResult.error(Messages.INVALID_DIRECTORY());
}

// We'll be using items from the tools and platforms directories.
// Ignore that "platform-tools" may also be required for newer SDKs,
// as we'll check for the presence of the individual tools in a moment
// Ensure that this at least looks like an SDK directory
final String[] sdkDirectories = { "tools", "platforms" };
for (String dirName : sdkDirectories) {
File dir = new File(sdkRoot, dirName);
@@ -234,27 +237,18 @@ public static ValidationResult validateAndroidHome(File sdkRoot, boolean fromWeb
}
}

// Search the possible tool directories to ensure the tools exist
// Search the various tool directories to ensure the basic tools exist
int toolsFound = 0;
int expectedToolCount = Tool.REQUIRED.length;
if (!new File(sdkRoot, "platform-tools").exists()) {
// aapt doesn't exist in "tools" until SDK Tools r9
expectedToolCount--;
}
final String[] toolDirectories = { "tools", "platform-tools" };
final String[] toolDirectories = { "tools", "platform-tools", "build-tools" };
for (String dir : toolDirectories) {
File toolsDir = new File(sdkRoot, dir);
if (!toolsDir.isDirectory()) {
continue;
}
for (String executable : Tool.getAllRequiredExecutableVariants()) {
File toolPath = new File(toolsDir, executable);
if (toolPath.exists() && toolPath.isFile()) {
toolsFound++;
}
}
IOFileFilter filter = new NameFileFilter(Tool.getAllExecutableVariants(Tool.REQUIRED));
toolsFound += FileUtils.listFiles(toolsDir, filter, TrueFileFilter.INSTANCE).size();
}
if (toolsFound < expectedToolCount) {
if (toolsFound < Tool.REQUIRED.length) {
return ValidationResult.errorWithMarkup(Messages.REQUIRED_SDK_TOOLS_NOT_FOUND());
}

0 comments on commit 0f997f4

Please sign in to comment.
You can’t perform that action at this time.