Navigation Menu

Skip to content

Commit

Permalink
[FIXED JENKINS-18015] Handle SDK detection with new 'build-tools' com…
Browse files Browse the repository at this point in the history
…ponent.
  • Loading branch information
orrc committed Jun 2, 2013
1 parent cb492a4 commit 0f997f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
9 changes: 3 additions & 6 deletions src/main/java/hudson/plugins/android_emulator/sdk/Tool.java
Expand Up @@ -19,7 +19,7 @@ public enum Tool {
};

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

public final String executable;
Expand Down Expand Up @@ -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);
Expand All @@ -65,6 +61,7 @@ private static String[] getAllExecutableVariants(final Tool[] tools) {
return executables;
}

@Override
public String toString() {
return executable;
}
Expand Down
28 changes: 11 additions & 17 deletions src/main/java/hudson/plugins/android_emulator/util/Utils.java
Expand Up @@ -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++).*");
Expand Down Expand Up @@ -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);
Expand All @@ -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());
}

Expand Down

0 comments on commit 0f997f4

Please sign in to comment.