Skip to content

Commit

Permalink
Combine both the local resources and any dependancy resources in a
Browse files Browse the repository at this point in the history
combined directory.
  • Loading branch information
Erik Hjortsberg committed Oct 30, 2009
1 parent 28aefea commit f6e7f85
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
Expand Up @@ -112,6 +112,12 @@ public abstract class AbstractAndroidMojo extends AbstractMojo {
*/
protected File extractedDependenciesJavaResources;

/**
* @parameter expression="${project.build.directory}/generated-sources/combined-resources/res"
* @readonly
*/
protected File combinedRes;

/**
* Specifies which device to connect to, by serial number. Special values "usb" and "emulator" are also valid, for
* selecting the only USB connected device or the only running emulator, respectively.
Expand Down
Expand Up @@ -200,6 +200,31 @@ private void generateR() throws MojoExecutionException {

String generatedSourcesRDirectoryName = project.getBuild().getDirectory() + File.separator + "generated-sources" + File.separator + "r";
new File(generatedSourcesRDirectoryName).mkdirs();

if (!combinedRes.exists()) {
if (!combinedRes.mkdirs()) {
throw new MojoExecutionException("Could not create directory for combined resources at " + combinedRes.getAbsolutePath());
}
}
if (resourceDirectory.exists()) {
try {
getLog().info("Copying local resource files to combined resource directory.");
org.apache.commons.io.FileUtils.copyDirectory(resourceDirectory, combinedRes);
}
catch (IOException e) {
throw new MojoExecutionException("", e);
}
}
if (extractedDependenciesRes.exists()) {
try {
getLog().info("Copying dependency resource files to combined resource directory.");
org.apache.commons.io.FileUtils.copyDirectory(extractedDependenciesRes, combinedRes);
}
catch (IOException e) {
throw new MojoExecutionException("", e);
}
}


CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(this.getLog());
Expand All @@ -211,13 +236,9 @@ private void generateR() throws MojoExecutionException {
commands.add(generatedSourcesRDirectoryName );
commands.add("-M" );
commands.add(androidManifestFile.getAbsolutePath());
if (resourceDirectory.exists()) {
commands.add("-S" );
commands.add(resourceDirectory.getAbsolutePath());
}
if (extractedDependenciesRes.exists()) {
if (combinedRes.exists()) {
commands.add("-S" );
commands.add(extractedDependenciesRes.getAbsolutePath());
commands.add(combinedRes.getAbsolutePath());
}
if (assetsDirectory.exists()) {
commands.add("-A" );
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.apache.maven.plugin.MojoFailureException;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -124,6 +125,30 @@ private void generateIntermediateAp_() throws MojoExecutionException {
CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
executor.setLogger(this.getLog());

if (!combinedRes.exists()) {
if (!combinedRes.mkdirs()) {
throw new MojoExecutionException("Could not create directory for combined resources at " + combinedRes.getAbsolutePath());
}
}
if (resourceDirectory.exists()) {
try {
getLog().info("Copying local resource files to combined resource directory.");
org.apache.commons.io.FileUtils.copyDirectory(resourceDirectory, combinedRes);
}
catch (IOException e) {
throw new MojoExecutionException("", e);
}
}
if (extractedDependenciesRes.exists()) {
try {
getLog().info("Copying dependency resource files to combined resource directory.");
org.apache.commons.io.FileUtils.copyDirectory(extractedDependenciesRes, combinedRes);
}
catch (IOException e) {
throw new MojoExecutionException("", e);
}
}

File androidJar = getAndroidSdk().getAndroidJar();
File outputFile = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".ap_");

Expand All @@ -132,13 +157,9 @@ private void generateIntermediateAp_() throws MojoExecutionException {
commands.add("-f");
commands.add("-M");
commands.add(androidManifestFile.getAbsolutePath());
if (resourceDirectory.exists()) {
commands.add("-S");
commands.add(resourceDirectory.getAbsolutePath());
}
if (extractedDependenciesRes.exists()) {
commands.add("-S");
commands.add(extractedDependenciesRes.getAbsolutePath());
if (combinedRes.exists()) {
commands.add("-S" );
commands.add(combinedRes.getAbsolutePath());
}
if (assetsDirectory.exists()) {
commands.add("-A");
Expand Down

0 comments on commit f6e7f85

Please sign in to comment.