Methods Summary |
---|
private void | createPackage(java.lang.String configName, java.lang.String resourceFilter)Creates a resource package.
Project taskProject = getProject();
if (configName == null || resourceFilter == null) {
System.out.println("Creating full resource package...");
} else {
System.out.println(String.format(
"Creating resource package for config '%1$s' (%2$s)...",
configName, resourceFilter));
}
// create a task for the default apk.
ExecTask task = new ExecTask();
task.setExecutable(mExecutable);
task.setFailonerror(true);
// aapt command. Only "package" is supported at this time really.
task.createArg().setValue(mCommand);
// filters if needed
if (configName != null && resourceFilter != null) {
task.createArg().setValue("-c");
task.createArg().setValue(resourceFilter);
}
// force flag
task.createArg().setValue("-f");
// manifest location
task.createArg().setValue("-M");
task.createArg().setValue(mManifest);
// resources location. This may not exists, and aapt doesn't like it, so we check first.
File res = new File(mResources);
if (res.isDirectory()) {
task.createArg().setValue("-S");
task.createArg().setValue(mResources);
}
// assets location. This may not exists, and aapt doesn't like it, so we check first.
File assets = new File(mAssets);
if (assets.isDirectory()) {
task.createArg().setValue("-A");
task.createArg().setValue(mAssets);
}
// android.jar
task.createArg().setValue("-I");
task.createArg().setValue(mAndroidJar);
// out file. This is based on the outFolder, baseName, and the configName (if applicable)
String filename;
if (configName != null && resourceFilter != null) {
filename = mBaseName + "-" + configName + ".ap_";
} else {
filename = mBaseName + ".ap_";
}
File file = new File(mOutFolder, filename);
task.createArg().setValue("-F");
task.createArg().setValue(file.getAbsolutePath());
// final setup of the task
task.setProject(taskProject);
task.setOwningTarget(getOwningTarget());
// execute it.
task.execute();
|
public void | execute()
Project taskProject = getProject();
// first do a full resource package
createPackage(null /*configName*/, null /*resourceFilter*/);
// now see if we need to create file with filtered resources.
// Get the project base directory.
File baseDir = taskProject.getBaseDir();
ProjectProperties properties = ProjectProperties.load(baseDir.getAbsolutePath(),
PropertyType.DEFAULT);
Map<String, String> apkConfigs = ApkConfigurationHelper.getConfigs(properties);
if (apkConfigs.size() > 0) {
Set<Entry<String, String>> entrySet = apkConfigs.entrySet();
for (Entry<String, String> entry : entrySet) {
createPackage(entry.getKey(), entry.getValue());
}
}
|
public void | setAndroidjar(org.apache.tools.ant.types.Path androidJar)Sets the value of the "androidjar" attribute.
mAndroidJar = androidJar.toString();
|
public void | setAssets(org.apache.tools.ant.types.Path assets)Sets the value of the "assets" attribute.
mAssets = assets.toString();
|
public void | setBasename(java.lang.String baseName)Sets the value of the "basename" attribute.
mBaseName = baseName;
|
public void | setCommand(java.lang.String command)Sets the value of the "command" attribute.
mCommand = command;
|
public void | setExecutable(java.lang.String executable)Sets the value of the "executable" attribute.
mExecutable = executable;
|
public void | setManifest(org.apache.tools.ant.types.Path manifest)Sets the value of the "manifest" attribute.
mManifest = manifest.toString();
|
public void | setOutfolder(org.apache.tools.ant.types.Path outFolder)Sets the value of the "outfolder" attribute.
mOutFolder = outFolder.toString();
|
public void | setResources(org.apache.tools.ant.types.Path resources)Sets the value of the "resources" attribute.
mResources = resources.toString();
|