aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-09-28 18:26:54 -0700
committerXavier Ducrohet <xav@android.com>2011-09-28 19:38:23 -0700
commit78c89f931135c11c45f26590ea5ae29577bced85 (patch)
tree88e1a35589b46206e7e677756ba6006bbb116058 /eclipse
parent09aefc28c531b6e56010f3054d54568864fd200a (diff)
downloadsdk-78c89f931135c11c45f26590ea5ae29577bced85.zip
sdk-78c89f931135c11c45f26590ea5ae29577bced85.tar.gz
sdk-78c89f931135c11c45f26590ea5ae29577bced85.tar.bz2
Also process and cache the png files in libraries.
The png in the libraries were not processed by the crunch step. Because aapt never processes png files anymore (relying on the crunch step to do it), the png files in libraries were never processed. While this is less a problem for standard png files, this completely breaks 9-patches that must be processed to actually behaves as 9-patch. Change-Id: I0a1fe14ea34f6d36a368b456494410945afc3c44
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PostCompilerBuilder.java63
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java16
3 files changed, 56 insertions, 29 deletions
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(