aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-09-29 11:31:10 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-29 11:31:10 -0700
commit969387ab34fd270081a23f6c4234bcf09b88f5e8 (patch)
treef1dace1c3e117733931baef96afa5315752cb246 /eclipse
parentb962ff06d6a3d31553c145eea00c9a93abfe4f16 (diff)
parent78c89f931135c11c45f26590ea5ae29577bced85 (diff)
downloadsdk-969387ab34fd270081a23f6c4234bcf09b88f5e8.zip
sdk-969387ab34fd270081a23f6c4234bcf09b88f5e8.tar.gz
sdk-969387ab34fd270081a23f6c4234bcf09b88f5e8.tar.bz2
Merge "Also process and cache the png files in libraries."
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(