diff --git a/tools/anttasks/src/com/android/ant/ApkBuilderTask.java b/tools/anttasks/src/com/android/ant/ApkBuilderTask.java index af87c78b4..3a15368e0 100644 --- a/tools/anttasks/src/com/android/ant/ApkBuilderTask.java +++ b/tools/anttasks/src/com/android/ant/ApkBuilderTask.java @@ -28,6 +28,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Path.PathElement; import java.io.File; import java.io.FileInputStream; @@ -39,6 +40,9 @@ import java.util.Map.Entry; public class ApkBuilderTask extends Task { + // ref id to the object containing all the boot classpaths. + private final static String REF_APK_PATH = "android.apks.path"; + /** * Class to represent nested elements. Since they all have only one attribute ('path'), the * same class can be used for all the nested elements (zip, file, sourcefolder, jarfolder, @@ -152,7 +156,7 @@ public class ApkBuilderTask extends Task { @Override public void execute() throws BuildException { - Project taskProject = getProject(); + Project antProject = getProject(); ApkBuilderImpl apkBuilder = new ApkBuilderImpl(); apkBuilder.setVerbose(mVerbose); @@ -197,13 +201,16 @@ public class ApkBuilderTask extends Task { ApkBuilderImpl.processNativeFolder(offset, f, mNativeLibraries); } + // create the Path item that will contain all the generated APKs + // for reuse by other targets (signing/zipaligning) + Path path = new Path(antProject); // first do a full resource package - createApk(apkBuilder, null /*configName*/, null /*resourceFilter*/); + createApk(apkBuilder, null /*configName*/, null /*resourceFilter*/, path); // now see if we need to create file with filtered resources. // Get the project base directory. - File baseDir = taskProject.getBaseDir(); + File baseDir = antProject.getBaseDir(); ProjectProperties properties = ProjectProperties.load(baseDir.getAbsolutePath(), PropertyType.DEFAULT); @@ -211,9 +218,13 @@ public class ApkBuilderTask extends Task { if (apkConfigs.size() > 0) { Set> entrySet = apkConfigs.entrySet(); for (Entry entry : entrySet) { - createApk(apkBuilder, entry.getKey(), entry.getValue()); + createApk(apkBuilder, entry.getKey(), entry.getValue(), path); } } + + // finally sets the path in the project with a reference + antProject.addReference(REF_APK_PATH, path); + } catch (FileNotFoundException e) { throw new BuildException(e); } catch (IllegalArgumentException e) { @@ -230,10 +241,12 @@ public class ApkBuilderTask extends Task { * package will be generated. * @param resourceFilter the resource configuration filter to pass to aapt (if configName is * non null) + * @param path Ant {@link Path} to which add the generated APKs as {@link PathElement} * @throws FileNotFoundException * @throws ApkCreationException */ - private void createApk(ApkBuilderImpl apkBuilder, String configName, String resourceFilter) + private void createApk(ApkBuilderImpl apkBuilder, String configName, String resourceFilter, + Path path) throws FileNotFoundException, ApkCreationException { // All the files to be included in the archive have already been prep'ed up, except // the resource package. @@ -259,7 +272,7 @@ public class ApkBuilderTask extends Task { } if (mSigned) { - filename = filename + "-debug.apk"; + filename = filename + "-debug-unaligned.apk"; } else { filename = filename + "-unsigned.apk"; } @@ -284,8 +297,13 @@ public class ApkBuilderTask extends Task { } } + // out File File f = new File(mOutFolder, filename); + // add it to the Path object + PathElement element = path.createPathElement(); + element.setLocation(f); + // and generate the apk apkBuilder.createPackage(f.getAbsoluteFile(), mZipArchives, mArchiveFiles, mJavaResources, mResourcesJars, mNativeLibraries); diff --git a/tools/scripts/android_rules.xml b/tools/scripts/android_rules.xml index be532643e..c8880c8d7 100644 --- a/tools/scripts/android_rules.xml +++ b/tools/scripts/android_rules.xml @@ -61,11 +61,16 @@ + + + + + @@ -151,14 +156,14 @@ basename="${ant.project.name}" /> - - + + + signed="${sign.package}" + verbose="true"> @@ -166,20 +171,65 @@ - - - - - - - - - All generated packages need to be signed with jarsigner before they are published. + + + + + + + + + + + + + + + + Debug Package: ${out-debug-package} + + + + + + + + + + + + + + + No key.store and key.alias properties found in build.properties. + Please sign ${out-unsigned-package} manually + and run zipalign from the Android SDK tools. + + + + + + + + + + + + + + + + Release Package: ${out-release-package} diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java index d71491c72..f2b73c09e 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java @@ -85,9 +85,17 @@ public final class ProjectProperties { "# This file must be checked in Version Control Systems, as it is\n" + "# integral to the build system of your project.\n" + "\n" + + "# This file is only used by the Ant script.\n" + + "\n" + "# You can use this to override default values such as\n" + "# 'source-folder' for the location of your java source folder and\n" + "# 'out-folder' for the location of your output folder.\n" + + "\n" + + "# You can also use it define how the release builds are signed by declaring\n" + + "# the following properties:\n" + + "# 'key.store' for the location of your keystore and\n" + + "# 'key.alias' for the name of the key to use.\n" + + "# The password will be asked during the build when you use the 'release' target.\n" + "\n"; private final static Map COMMENT_MAP = new HashMap();