diff options
author | Xavier Ducrohet <xav@android.com> | 2012-03-07 10:36:30 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2012-03-07 15:11:19 -0800 |
commit | bcf44e9429811b3e1f97d21ea92816957bce2601 (patch) | |
tree | 9b6a7502b6901b193b4fedd99ca6e541bd6cd4f3 /sdkmanager/libs/sdklib | |
parent | ec60a783e8adca69f43e4a313f207fa919a7c06f (diff) | |
download | sdk-bcf44e9429811b3e1f97d21ea92816957bce2601.zip sdk-bcf44e9429811b3e1f97d21ea92816957bce2601.tar.gz sdk-bcf44e9429811b3e1f97d21ea92816957bce2601.tar.bz2 |
Figure out DX input path based on actual classpath.
This synchronizes the previous work on figuring out the actual
classpath for the library container and reuse this to figure out
what goes into dex.
Also use the classpath to figure out the java resources that should
be packaged in the apk. Additionally, only add java resources by
reading the output folder instead of the source folders as this
ensure that exclusion patterns are respected.
Change-Id: Iac742f4bdefab370ec3cf7d955736e84d58ead9c
Diffstat (limited to 'sdkmanager/libs/sdklib')
-rw-r--r-- | sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java index 5c95b81..3c749c4 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java @@ -586,12 +586,25 @@ public final class ApkBuilder implements IArchiveBuilder { throw new SealedApkException("APK is already sealed"); } + addSourceFolder(this, sourceFolder); + } + + /** + * Adds the resources from a source folder to a given {@link IArchiveBuilder} + * @param sourceFolder the source folder. + * @throws ApkCreationException if an error occurred + * @throws SealedApkException if the APK is already sealed. + * @throws DuplicateFileException if a file conflicts with another already added to the APK + * at the same location inside the APK archive. + */ + public static void addSourceFolder(IArchiveBuilder builder, File sourceFolder) + throws ApkCreationException, DuplicateFileException { if (sourceFolder.isDirectory()) { try { // file is a directory, process its content. File[] files = sourceFolder.listFiles(); for (File file : files) { - processFileForResource(file, null); + processFileForResource(builder, file, null); } } catch (DuplicateFileException e) { throw e; @@ -799,9 +812,11 @@ public final class ApkBuilder implements IArchiveBuilder { * @throws IOException * @throws DuplicateFileException if a file conflicts with another already added * to the APK at the same location inside the APK archive. + * @throws SealedApkException if the APK is already sealed. + * @throws ApkCreationException if an error occurred */ - private void processFileForResource(File file, String path) - throws IOException, DuplicateFileException { + private static void processFileForResource(IArchiveBuilder builder, File file, String path) + throws IOException, DuplicateFileException, ApkCreationException, SealedApkException { if (file.isDirectory()) { // a directory? we check it if (checkFolderForPackaging(file.getName())) { @@ -815,7 +830,7 @@ public final class ApkBuilder implements IArchiveBuilder { // and process its content. File[] files = file.listFiles(); for (File contentFile : files) { - processFileForResource(contentFile, path); + processFileForResource(builder, contentFile, path); } } } else { @@ -829,7 +844,7 @@ public final class ApkBuilder implements IArchiveBuilder { } // and add it to the apk - doAddFile(file, path); + builder.addFile(file, path); } } } |