diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2011-06-07 18:05:42 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2011-06-09 17:21:10 -0700 |
commit | a1aa60efc6ed4f86846804936c0d947994b3d3fb (patch) | |
tree | 3c6d7936ecb6a30bb04aa4bc27dfaad82189f535 /eclipse | |
parent | 5982b49c26b056379f6f61516993583407fd7052 (diff) | |
download | sdk-a1aa60efc6ed4f86846804936c0d947994b3d3fb.zip sdk-a1aa60efc6ed4f86846804936c0d947994b3d3fb.tar.gz sdk-a1aa60efc6ed4f86846804936c0d947994b3d3fb.tar.bz2 |
Disable PostComp in ADT except on Export or Debug
This patch adds a check in PostCompilerBuilder so if a flag is
not explicitly set (as is done by ExportHelper and Launch) then
it will skip and not do packaging. This should speed up the incremental
build on file save at the cost of slightly longer builds when pushing
to the debugger.
Change-Id: I2993f91a9b53e767e77da82de61b2699dd1127a4
Diffstat (limited to 'eclipse')
9 files changed, 92 insertions, 24 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java index 10ec15f..cdf48ad 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/MultiApkExportAction.java @@ -26,9 +26,9 @@ import com.android.ide.eclipse.adt.io.IFolderWrapper; import com.android.sdklib.SdkConstants; import com.android.sdklib.internal.export.ApkData; import com.android.sdklib.internal.export.MultiApkExportHelper; -import com.android.sdklib.internal.export.ProjectConfig; import com.android.sdklib.internal.export.MultiApkExportHelper.ExportException; import com.android.sdklib.internal.export.MultiApkExportHelper.Target; +import com.android.sdklib.internal.export.ProjectConfig; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.internal.project.ProjectProperties.PropertyType; @@ -38,7 +38,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -214,7 +213,7 @@ public class MultiApkExportAction implements IObjectActionDelegate { } // build the project, mainly for the java compilation. The rest is handled below. - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); + ProjectHelper.build(project, monitor); // store the resolved project in the map. resolvedProjects.put(projectConfig, projectState); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java index dffa8a6..d1768c4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java @@ -118,6 +118,10 @@ public class Messages extends NLS { public static String Start_Full_Pre_Compiler; + public static String Skip_Post_Compiler; + + public static String Start_Full_Post_Compiler; + public static String Start_Inc_Apk_Build; public static String Start_Inc_Pre_Compiler; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties index e586483..aabe2a4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties @@ -1,5 +1,7 @@ Start_Full_Apk_Build=Starting full Package build. Start_Full_Pre_Compiler=Starting full Pre Compiler. +Skip_Post_Compiler=Skipping over Post Compiler. +Start_Full_Post_Compiler=Starting full Post Compiler. Start_Inc_Apk_Build=Starting incremental Package build: Checking resource changes. Start_Inc_Pre_Compiler=Starting incremental Pre Compiler: Checking resource changes. Xml_Error=Error in an XML file: aborting build. 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 71c38f8..2325293 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 @@ -16,17 +16,17 @@ package com.android.ide.eclipse.adt.internal.build.builders; -import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidPrintStream; 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; @@ -72,6 +72,11 @@ public class PostCompilerBuilder extends BaseBuilder { private static final String PROPERTY_PACKAGE_RESOURCES = "packageResources"; //$NON-NLS-1$ private static final String PROPERTY_BUILD_APK = "buildApk"; //$NON-NLS-1$ + /** Flag to pass to PostCompiler builder that sets if it runs or not. + * Set this flag whenever calling build if PostCompiler is to run + */ + public final static String POST_C_REQUESTED = "RunPostCompiler"; //$NON-NLS-1$ + /** * Dex conversion flag. This is set to true if one of the changed/added/removed * file is a .class file. Upon visiting all the delta resource, if this @@ -250,7 +255,9 @@ public class PostCompilerBuilder extends BaseBuilder { // First thing we do is go through the resource delta to not // lose it if we have to abort the build for any reason. PostCompilerDeltaVisitor dv = null; - if (kind == FULL_BUILD) { + if (args.containsKey(POST_C_REQUESTED)) { + // Skip over flag setting + } else if (kind == FULL_BUILD) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, Messages.Start_Full_Apk_Build); @@ -341,6 +348,17 @@ public class PostCompilerBuilder extends BaseBuilder { return allRefProjects; } + // Check to see if we're going to launch or export. If not, we can skip + // The packaging and dexing process. + if (!args.containsKey(POST_C_REQUESTED)) { + AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, + Messages.Skip_Post_Compiler); + return allRefProjects; + } else { + AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, + Messages.Start_Full_Post_Compiler); + } + // first thing we do is check that the SDK directory has been setup. String osSdkFolder = AdtPlugin.getOsSdkFolder(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchConfigDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchConfigDelegate.java index 6364dcd..54b827f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchConfigDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchConfigDelegate.java @@ -17,8 +17,8 @@ package com.android.ide.eclipse.adt.internal.launch; import com.android.ddmlib.AndroidDebugBridge; -import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.launch.AndroidLaunchConfiguration.TargetMode; import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper; import com.android.ide.eclipse.adt.internal.project.ProjectHelper; @@ -28,7 +28,6 @@ import com.android.sdklib.xml.ManifestData.Activity; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -140,9 +139,10 @@ public class LaunchConfigDelegate extends LaunchConfigurationDelegate { return; } - // make sure the project is built. This is a synchronous call which returns when the + // make sure the project is built and PostCompilerBuilder runs. + // This is a synchronous call which returns when the // build is done. - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); + ProjectHelper.build(project, monitor, true); // check if the project has errors, and abort in this case. if (ProjectHelper.hasError(project, true)) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java index 3d0e088..0312900 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java @@ -16,8 +16,8 @@ package com.android.ide.eclipse.adt.internal.project; -import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidPrintStream; import com.android.ide.eclipse.adt.internal.build.BuildHelper; import com.android.ide.eclipse.adt.internal.build.DexException; @@ -37,7 +37,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -84,7 +83,8 @@ public final class ExportHelper { // the export, takes the output of the precompiler & Java builders so it's // important to call build in case the auto-build option of the workspace is disabled. - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); + // Also enable post compilation + ProjectHelper.build(project, monitor, true); // if either key or certificate is null, ensure the other is null. if (key == null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java index 22af8b0..9fce874 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java @@ -16,8 +16,9 @@ package com.android.ide.eclipse.adt.internal.project; -import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder; import com.android.sdklib.SdkConstants; import com.android.sdklib.xml.ManifestData; import com.android.util.Pair; @@ -33,6 +34,7 @@ import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; @@ -45,6 +47,8 @@ import org.eclipse.jdt.launching.JavaRuntime; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; /** * Utility class to manipulate Project parameters/properties. @@ -808,4 +812,42 @@ public final class ProjectHelper { } return (IFile) r; } + + /** + * Build project incrementally. If fullBuild is not set, then the packaging steps in + * the post compiler are skipped. (Though resource deltas are still processed). + * @param project The project to be built. + * @param monitor A eclipse runtime progress monitor to be updated by the builders. + * @param fullBuild Set whether to run the packaging (dexing and building apk) steps of + * the post compiler. + * @throws CoreException + */ + public static void build(IProject project, IProgressMonitor monitor, boolean fullBuild) + throws CoreException { + // Do an incremental build to pick up all the deltas + project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); + if (fullBuild) { + // Create the map to pass to the PostC builder + Map<String, String> args = new TreeMap<String, String>(); + args.put(PostCompilerBuilder.POST_C_REQUESTED, ""); //$NON-NLS-1$ + // Get Post Compiler to do packaging + project.build(IncrementalProjectBuilder.FULL_BUILD, + PostCompilerBuilder.ID, args, monitor); + } + } + + /** + * Build the project incrementally. Post compilation step will not occur. + * This is equivalent to calling + * <code>build(project, monitor, false)</code> + * @param project The project to be built. + * @param monitor A eclipse runtime progress monitor to be updated by the builders. + * @throws CoreException + * @see #build(IProject, IProgressMonitor, boolean) + */ + public static void build(IProject project, IProgressMonitor monitor) + throws CoreException { + // Disable full building by default + build(project, monitor, false); + } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java index d3bdbfd..616fabb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactoring/core/FixImportsJob.java @@ -1,3 +1,4 @@ +<<<<<<< HEAD /* * Copyright (C) 2010 The Android Open Source Project * @@ -16,11 +17,12 @@ package com.android.ide.eclipse.adt.internal.refactoring.core; +import com.android.ide.eclipse.adt.internal.project.ProjectHelper; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -80,7 +82,7 @@ public class FixImportsJob extends WorkspaceJob { if (javaProject == null || !javaProject.isOpen()) { return Status.CANCEL_STATUS; } - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); + ProjectHelper.build(project, monitor); IMarker[] markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); for (int i = 0; i < markers.length; i++) { IMarker marker = markers[i]; @@ -141,5 +143,4 @@ public class FixImportsJob extends WorkspaceJob { } return Status.OK_STATUS; } - -} +}
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java index 3326c6f..f7978fb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java @@ -21,8 +21,8 @@ import com.android.ide.eclipse.adt.internal.editors.IconFactory; import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper; import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper; -import com.android.ide.eclipse.adt.internal.project.ProjectHelper; import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper.NonLibraryProjectOnlyFilter; +import com.android.ide.eclipse.adt.internal.project.ProjectHelper; import com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.ExportWizardPage; import com.android.sdklib.xml.ManifestData; @@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import java.io.File; +import java.io.IOException; /** * First Export Wizard Page. Display warning/errors. @@ -176,12 +177,13 @@ final class ProjectCheckPage extends ExportWizardPage { AdtConstants.DOT_ANDROID_PACKAGE; File f = new File(apkFilePath); - if (f.isFile() == false) { + try { + f.createNewFile(); + } catch (IOException e) { addError(mErrorComposite, - String.format("%1$s/%2$s/%1$s%3$s does not exists!", - project.getName(), - outputIFolder.getName(), - AdtConstants.DOT_ANDROID_PACKAGE)); + String.format("Could not open %1$s/%2$s/%1$s%3$s for writing!", + project.getName(), outputIFolder.getName(), + AdtConstants.DOT_ANDROID_PACKAGE)); } } else { addError(mErrorComposite, |