Methods Summary |
---|
private void | createApk(com.android.apkbuilder.ApkBuilder apkBuilder, java.lang.String configName, java.lang.String resourceFilter)Creates an application package.
// All the files to be included in the archive have already been prep'ed up, except
// the resource package.
// figure out its name.
String filename;
if (configName != null && resourceFilter != null) {
filename = mBaseName + "-" + configName + ".ap_";
} else {
filename = mBaseName + ".ap_";
}
// now we add it to the list of zip archive (it's just a zip file).
// it's used as a zip archive input
FileInputStream resoucePackageZipFile = new FileInputStream(new File(mOutFolder, filename));
mZipArchives.add(resoucePackageZipFile);
// prepare the filename to generate. Same thing as the resource file.
if (configName != null && resourceFilter != null) {
filename = mBaseName + "-" + configName;
} else {
filename = mBaseName;
}
if (mSigned) {
filename = filename + "-debug.apk";
} else {
filename = filename + "-unsigned.apk";
}
if (configName == null || resourceFilter == null) {
if (mSigned) {
System.out.println(String.format(
"Creating %s and signing it with a debug key...", filename));
} else {
System.out.println(String.format(
"Creating %s for release...", filename));
}
} else {
if (mSigned) {
System.out.println(String.format(
"Creating %1$s (with %2$s) and signing it with a debug key...",
filename, resourceFilter));
} else {
System.out.println(String.format(
"Creating %1$s (with %2$s) for release...",
filename, resourceFilter));
}
}
File f = new File(mOutFolder, filename);
// and generate the apk
apkBuilder.createPackage(f.getAbsoluteFile(), mZipArchives,
mArchiveFiles, mJavaResources, mResourcesJars, mNativeLibraries);
// we are done. We need to remove the resource package from the list of zip archives
// in case we have another apk to generate.
mZipArchives.remove(resoucePackageZipFile);
|
public java.lang.Object | createFile()Returns an object representing a nested file element.
Value file = new Value();
mFileList.add(file);
return file;
|
public java.lang.Object | createJarfolder()Returns an object representing a nested jarfolder element.
Value file = new Value();
mJarList.add(file);
return file;
|
public java.lang.Object | createNativefolder()Returns an object representing a nested nativefolder element.
Value file = new Value();
mNativeList.add(file);
return file;
|
public java.lang.Object | createSourcefolder()Returns an object representing a nested sourcefolder element.
Value file = new Value();
mSourceList.add(file);
return file;
|
public java.lang.Object | createZip()Returns an object representing a nested zip element.
Value zip = new Value();
mZipList.add(zip);
return zip;
|
public void | execute()
Project taskProject = getProject();
ApkBuilder apkBuilder = new ApkBuilder();
apkBuilder.setVerbose(mVerbose);
apkBuilder.setSignedPackage(mSigned);
try {
// setup the list of everything that needs to go in the archive.
// go through the list of zip files to add. This will not include
// the resource package, which is handled separaly for each apk to create.
for (Value v : mZipList) {
FileInputStream input = new FileInputStream(v.mPath);
mZipArchives.add(input);
}
// now go through the list of file to directly add the to the list.
for (Value v : mFileList) {
mArchiveFiles.add(ApkBuilder.getInputFile(v.mPath));
}
// now go through the list of file to directly add the to the list.
for (Value v : mSourceList) {
ApkBuilder.processSourceFolderForResource(v.mPath, mJavaResources);
}
// now go through the list of jar folders.
for (Value v : mJarList) {
ApkBuilder.processJarFolder(v.mPath, mResourcesJars);
}
// now the native lib folder.
for (Value v : mNativeList) {
String parameter = v.mPath;
File f = new File(parameter);
// compute the offset to get the relative path
int offset = parameter.length();
if (parameter.endsWith(File.separator) == false) {
offset++;
}
ApkBuilder.processNativeFolder(offset, f, mNativeLibraries);
}
// first do a full resource package
createApk(apkBuilder, 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) {
createApk(apkBuilder, entry.getKey(), entry.getValue());
}
}
} catch (FileNotFoundException e) {
throw new BuildException(e);
} catch (IllegalArgumentException e) {
throw new BuildException(e);
}
|
public void | setBasename(java.lang.String baseName)Sets the value of the "basename" attribute.
mBaseName = baseName;
|
public void | setOutfolder(org.apache.tools.ant.types.Path outFolder)Sets the value of the "outfolder" attribute.
mOutFolder = outFolder.toString();
|
public void | setSigned(boolean signed)Sets the value of the "signed" attribute.
mSigned = signed;
|
public void | setVerbose(boolean verbose)Sets the value of the "verbose" attribute.
mVerbose = verbose;
|