diff options
5 files changed, 68 insertions, 41 deletions
diff --git a/anttasks/src/com/android/ant/NewSetupTask.java b/anttasks/src/com/android/ant/NewSetupTask.java index f6ba986..165ea08 100644 --- a/anttasks/src/com/android/ant/NewSetupTask.java +++ b/anttasks/src/com/android/ant/NewSetupTask.java @@ -465,7 +465,10 @@ public class NewSetupTask extends Task { PathElement element = rootPath.createPathElement(); element.setPath(libRootPath); - // get the res path. Always $PROJECT/res + // get the res path. Always $PROJECT/res as well as the crunch cache. + element = resPath.createPathElement(); + element.setPath(libRootPath + "/" + SdkConstants.FD_OUTPUT + + "/" + SdkConstants.FD_RES); element = resPath.createPathElement(); element.setPath(libRootPath + "/" + SdkConstants.FD_RESOURCES); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java index 3e96a8f..3209ec1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java @@ -227,7 +227,11 @@ public class BuildHelper { // libraries? if (libProjects != null) { for (IProject lib : libProjects) { - IFolder libResFolder = lib.getFolder(SdkConstants.FD_RES); + IFolder libCacheFolder = lib.getFolder(AdtConstants.WS_CRUNCHCACHE); + if (libCacheFolder.exists()) { + osResPaths.add(libCacheFolder.getLocation().toOSString()); + } + IFolder libResFolder = lib.getFolder(AdtConstants.WS_RESOURCES); if (libResFolder.exists()) { osResPaths.add(libResFolder.getLocation().toOSString()); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java index 47215cc..7f75c4f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java @@ -23,10 +23,10 @@ import com.android.ide.eclipse.adt.internal.build.AaptExecException; import com.android.ide.eclipse.adt.internal.build.AaptParser; import com.android.ide.eclipse.adt.internal.build.AaptResultException; import com.android.ide.eclipse.adt.internal.build.BuildHelper; -import com.android.ide.eclipse.adt.internal.build.BuildHelper.ResourceMarker; import com.android.ide.eclipse.adt.internal.build.DexException; import com.android.ide.eclipse.adt.internal.build.Messages; import com.android.ide.eclipse.adt.internal.build.NativeLibInJarException; +import com.android.ide.eclipse.adt.internal.build.BuildHelper.ResourceMarker; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity; import com.android.ide.eclipse.adt.internal.project.ApkInstallManager; @@ -410,7 +410,8 @@ public class PostCompilerBuilder extends BaseBuilder { mConvertToDex = true; } - if (mConvertToDex) { + if (mConvertToDex) { // in this case this means some class files changed and + // we need to update the jar file. IFolder javaOutputFolder = BaseProjectHelper.getJavaOutputFolder(project); writeLibraryPackage(jarIFile, project, javaOutputFolder, @@ -418,6 +419,15 @@ public class PostCompilerBuilder extends BaseBuilder { saveProjectBooleanProperty(PROPERTY_CONVERT_TO_DEX, mConvertToDex = false); } + // also update the crunch cache if needed. + if (mUpdateCrunchCache) { + BuildHelper helper = new BuildHelper(project, + mOutStream, mErrStream, + true /*debugMode*/, + AdtPrefs.getPrefs().getBuildVerbosity() == BuildVerbosity.VERBOSE); + updateCrunchCache(project, helper); + } + return allRefProjects; } @@ -536,27 +546,9 @@ public class PostCompilerBuilder extends BaseBuilder { // Check if we need to update the PNG cache if (mUpdateCrunchCache) { - try { - helper.updateCrunchCache(); - } catch (AaptExecException e) { - BaseProjectHelper.markResource(project, AdtConstants.MARKER_PACKAGING, - e.getMessage(), IMarker.SEVERITY_ERROR); + if (updateCrunchCache(project, helper) == false) { return allRefProjects; - } catch (AaptResultException e) { - // attempt to parse the error output - String[] aaptOutput = e.getOutput(); - boolean parsingError = AaptParser.parseOutput(aaptOutput, project); - // if we couldn't parse the output we display it in the console. - if (parsingError) { - AdtPlugin.printErrorToConsole(project, (Object[]) aaptOutput); - } } - - // crunch has been done. Reset state - mUpdateCrunchCache = false; - - // and store it - saveProjectBooleanProperty(PROPERTY_UPDATE_CRUNCH_CACHE, mUpdateCrunchCache); } // Check if we need to package the resources. @@ -826,6 +818,35 @@ public class PostCompilerBuilder extends BaseBuilder { } } + /** + * Updates the crunch cache if needed and return true if the build must continue. + */ + private boolean updateCrunchCache(IProject project, BuildHelper helper) { + try { + helper.updateCrunchCache(); + } catch (AaptExecException e) { + BaseProjectHelper.markResource(project, AdtConstants.MARKER_PACKAGING, + e.getMessage(), IMarker.SEVERITY_ERROR); + return false; + } catch (AaptResultException e) { + // attempt to parse the error output + String[] aaptOutput = e.getOutput(); + boolean parsingError = AaptParser.parseOutput(aaptOutput, project); + // if we couldn't parse the output we display it in the console. + if (parsingError) { + AdtPlugin.printErrorToConsole(project, (Object[]) aaptOutput); + } + } + + // crunch has been done. Reset state + mUpdateCrunchCache = false; + + // and store it + saveProjectBooleanProperty(PROPERTY_UPDATE_CRUNCH_CACHE, mUpdateCrunchCache); + + return true; + } + private void writeLibraryPackage(IFile jarIFile, IProject project, IFolder javaOutputFolder, List<IJavaProject> referencedJavaProjects) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java index 6d0ed5a..6540038 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java @@ -137,15 +137,17 @@ public class LibraryClasspathContainerInitializer extends ClasspathContainerInit // get the project output IFolder outputFolder = BaseProjectHelper.getAndroidOutputFolder(libProject); - IFile jarIFile = outputFolder.getFile(libProject.getName().toLowerCase() + - AdtConstants.DOT_JAR); + if (outputFolder != null) { // can happen when closing/deleting a library) + IFile jarIFile = outputFolder.getFile(libProject.getName().toLowerCase() + + AdtConstants.DOT_JAR); - IClasspathEntry entry = JavaCore.newLibraryEntry( - jarIFile.getLocation(), - libProject.getLocation(), // source attachment path - null); // default source attachment root path. + IClasspathEntry entry = JavaCore.newLibraryEntry( + jarIFile.getLocation(), + libProject.getLocation(), // source attachment path + null); // default source attachment root path. - entries.add(entry); + entries.add(entry); + } } return new AndroidClasspathContainer( diff --git a/files/ant/build.xml b/files/ant/build.xml index 9387ff2..134a0a3 100644 --- a/files/ant/build.xml +++ b/files/ant/build.xml @@ -748,17 +748,14 @@ <!-- Updates the pre-processed PNG cache --> <target name="-crunch"> - <!-- only crunch if *not* a library project --> - <do-only-if-not-library elseText="Library project: do not optimize PNGs..." > - <exec executable="${aapt}" taskName="crunch"> - <arg value="crunch" /> - <arg value="-v" /> - <arg value="-S" /> - <arg path="${resource.absolute.dir}" /> - <arg value="-C" /> - <arg path="${out.res.absolute.dir}" /> - </exec> - </do-only-if-not-library> + <exec executable="${aapt}" taskName="crunch"> + <arg value="crunch" /> + <arg value="-v" /> + <arg value="-S" /> + <arg path="${resource.absolute.dir}" /> + <arg value="-C" /> + <arg path="${out.res.absolute.dir}" /> + </exec> </target> <!-- Puts the project's resources into the output package file |