Skip to content

Commit

Permalink
Merge branch 'issue-115-dx.jar'
Browse files Browse the repository at this point in the history
  • Loading branch information
hugojosefson committed Mar 5, 2011
2 parents 45e3e1e + 73b4003 commit 6317399
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Expand Up @@ -134,7 +134,7 @@ private void assertPathIsDirectory(final File path) {
/**
* Returns the complete path for a tool, based on this SDK.
*
* @param tool which tool, for example <code>adb</code>.
* @param tool which tool, for example <code>adb</code> or <code>dx.jar</code>.
* @return the complete path as a <code>String</code>, including the tool's filename.
*/
public String getPathForTool(String tool) {
Expand All @@ -143,12 +143,15 @@ public String getPathForTool(String tool) {
sdkPath + "/" + PLATFORM_TOOLS_FOLDER_NAME + "/" + tool,
sdkPath + "/" + PLATFORM_TOOLS_FOLDER_NAME + "/" + tool + ".exe",
sdkPath + "/" + PLATFORM_TOOLS_FOLDER_NAME + "/" + tool + ".bat",
sdkPath + "/" + PLATFORM_TOOLS_FOLDER_NAME + "/lib/" + tool,
getPlatform() + "/tools/" + tool,
getPlatform() + "/tools/" + tool + ".exe",
getPlatform() + "/tools/" + tool + ".bat",
getPlatform() + "/tools/lib/" + tool,
sdkPath + "/tools/" + tool,
sdkPath + "/tools/" + tool + ".exe",
sdkPath + "/tools/" + tool + ".bat"
sdkPath + "/tools/" + tool + ".bat",
sdkPath + "/tools/lib/" + tool
};

for (String possiblePath : possiblePaths) {
Expand Down
Expand Up @@ -85,6 +85,8 @@ private void runDex(CommandExecutor executor, File outputFile,
File inputFile) throws MojoExecutionException {
File classesOutputDirectory = new File(project.getBuild().getDirectory(), "android-classes");
List<String> commands = new ArrayList<String>();
commands.add("-jar");
commands.add(getAndroidSdk().getPathForTool("dx.jar"));
if (jvmArguments != null) {
for (String jvmArgument : jvmArguments) {
if (jvmArgument != null) {
Expand All @@ -101,14 +103,26 @@ private void runDex(CommandExecutor executor, File outputFile,
if (coreLibrary) {
commands.add("--core-library");
}
getLog().info(getAndroidSdk().getPathForTool("dx") + " " + commands.toString());
final String javaExecutable = getJavaExecutable().getAbsolutePath();
getLog().info(javaExecutable + " " + commands.toString());
try {
executor.executeCommand(getAndroidSdk().getPathForTool("dx"), commands, project.getBasedir(), false);
executor.executeCommand(javaExecutable, commands, project.getBasedir(), false);
} catch (ExecutionException e) {
throw new MojoExecutionException("", e);
}
}

/**
* Figure out the full path to the current java executable.
*
* @return the full path to the current java executable.
*/
private static File getJavaExecutable() {
final String javaHome = System.getProperty("java.home");
final String slash = File.separator;
return new File(javaHome + slash + "bin" + slash + "java");
}

protected File createApkSourcesFile() throws MojoExecutionException {
final File apksources = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".apksources");
FileUtils.deleteQuietly(apksources);
Expand Down

0 comments on commit 6317399

Please sign in to comment.