From d45f7f6410f02f884fd640cb218c511835c0130b Mon Sep 17 00:00:00 2001 From: Josiah Gaskin Date: Mon, 11 Jul 2011 09:33:14 -0700 Subject: Fix to build dependencies during delayed PostComp This patch adds a boolean flag to ProjectHelper.build() that when set ensures that all projects which are dependencies of the project being built will be built as well. This fixes buggy behavior where a package would not be fully built when its JUnit tests were built/run. Change-Id: Iab19299ea980564345f2a7f30bf61a69d77d96ee --- .../adt/internal/launch/LaunchConfigDelegate.java | 5 +-- .../eclipse/adt/internal/project/ExportHelper.java | 4 +-- .../adt/internal/project/ProjectHelper.java | 38 +++++++++++++++++----- 3 files changed, 35 insertions(+), 12 deletions(-) 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 54b827f..da764a8 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 @@ -139,10 +139,11 @@ public class LaunchConfigDelegate extends LaunchConfigurationDelegate { return; } - // make sure the project is built and PostCompilerBuilder runs. + // make sure the project and its dependencies are built + // and PostCompilerBuilder runs. // This is a synchronous call which returns when the // build is done. - ProjectHelper.build(project, monitor, true); + ProjectHelper.build(project, monitor, true, 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 0312900..f531667 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 @@ -83,8 +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. - // Also enable post compilation - ProjectHelper.build(project, monitor, true); + // Also enable post compilation and dependency building + ProjectHelper.build(project, monitor, true, 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 b1f3eb9..97dd68e 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 @@ -817,23 +817,43 @@ public final class ProjectHelper { /** * 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. + * @param fullBuild Set whether to + * run the packaging (dexing and building apk) steps of the + * post compiler. + * @param buildDeps Set whether to run builders on the dependencies of the project * @throws CoreException */ - public static void build(IProject project, IProgressMonitor monitor, boolean fullBuild) + public static void build(IProject project, IProgressMonitor monitor, + boolean fullBuild, boolean buildDeps) throws CoreException { + // Get list of projects that we depend on + List androidProjectList = new ArrayList(); + if (buildDeps) { + try { + androidProjectList = getAndroidProjectDependencies( + BaseProjectHelper.getJavaProject(project)); + } catch (JavaModelException e) { + AdtPlugin.printErrorToConsole(project, e); + } + // Recursively build dependencies + for (IJavaProject dependency : androidProjectList) { + build(dependency.getProject(), monitor, fullBuild, true); + } + } + // Do an incremental build to pick up all the deltas project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); - // If the preferences indicate not to use post compiler optimization then the - // incremental build will have done everything necessary + + // If the preferences indicate not to use post compiler optimization + // then the incremental build will have done everything necessary if (fullBuild && AdtPrefs.getPrefs().getBuildSkipPostCompileOnFileSave()) { // Create the map to pass to the PostC builder Map args = new TreeMap(); args.put(PostCompilerBuilder.POST_C_REQUESTED, ""); //$NON-NLS-1$ - // Get Post Compiler to do packaging + // Get Post Compiler for this project project.build(IncrementalProjectBuilder.FULL_BUILD, PostCompilerBuilder.ID, args, monitor); } @@ -841,8 +861,10 @@ public final class ProjectHelper { /** * Build the project incrementally. Post compilation step will not occur. + * Projects that this project depends on will not be built. * This is equivalent to calling - * build(project, monitor, false) + * build(project, monitor, false, false) + * * @param project The project to be built. * @param monitor A eclipse runtime progress monitor to be updated by the builders. * @throws CoreException @@ -851,6 +873,6 @@ public final class ProjectHelper { public static void build(IProject project, IProgressMonitor monitor) throws CoreException { // Disable full building by default - build(project, monitor, false); + build(project, monitor, false, false); } } -- cgit v1.1