diff options
author | Xavier Ducrohet <xav@android.com> | 2012-03-28 16:40:34 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2012-03-28 18:02:20 -0700 |
commit | 94bab8acc98af8708c2e0e73b3a6dbd43880cadc (patch) | |
tree | da01ddc6dca37059f6a55e137244011b60ee94fb /eclipse | |
parent | 601d6fe6fc000c61a050bf9ee0a4ae4dd1ed0516 (diff) | |
download | sdk-94bab8acc98af8708c2e0e73b3a6dbd43880cadc.zip sdk-94bab8acc98af8708c2e0e73b3a6dbd43880cadc.tar.gz sdk-94bab8acc98af8708c2e0e73b3a6dbd43880cadc.tar.bz2 |
Fix export of release app to recompile libs in release mode.
Change-Id: I972257dc08675230cbcd996f355d1817293d9935
Diffstat (limited to 'eclipse')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java | 76 |
1 files changed, 49 insertions, 27 deletions
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 10edeae..a733708 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 @@ -21,6 +21,8 @@ import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder; import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; +import com.android.ide.eclipse.adt.internal.sdk.ProjectState; +import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.sdklib.SdkConstants; import com.android.sdklib.xml.ManifestData; import com.android.util.Pair; @@ -866,23 +868,38 @@ public final class ProjectHelper { @SuppressWarnings("unchecked") public static void compileInReleaseMode(IProject project, IProgressMonitor monitor) throws CoreException { - // Get list of projects that we depend on - List<IJavaProject> androidProjectList = new ArrayList<IJavaProject>(); - try { - androidProjectList = getAndroidProjectDependencies( - BaseProjectHelper.getJavaProject(project)); + compileInReleaseMode(project, true /*includeDependencies*/, monitor); + } - } catch (JavaModelException e) { - AdtPlugin.printErrorToConsole(project, e); - } + /** + * Does a full release build of the application, including the libraries. Do not build the + * package. + * + * @param project The project to be built. + * @param monitor A eclipse runtime progress monitor to be updated by the builders. + * @throws CoreException + */ + @SuppressWarnings("unchecked") + private static void compileInReleaseMode(IProject project, boolean includeDependencies, + IProgressMonitor monitor) + throws CoreException { - // Recursively build dependencies - for (IJavaProject dependency : androidProjectList) { - IProject libProject = dependency.getProject(); - compileInReleaseMode(libProject, monitor); + if (includeDependencies) { + ProjectState projectState = Sdk.getProjectState(project); + + // this gives us all the library projects, direct and indirect dependencies, + // so no need to run this method recursively. + List<IProject> libraries = projectState.getFullLibraryProjects(); - // force refresh of the dependency. - libProject.refreshLocal(IResource.DEPTH_INFINITE, monitor); + // build dependencies in reverse order to prevent libraries being rebuilt + // due to refresh of other libraries (they would be compiled in the wrong mode). + for (int i = libraries.size() - 1 ; i >= 0 ; i--) { + IProject lib = libraries.get(i); + compileInReleaseMode(lib, false /*includeDependencies*/, monitor); + + // force refresh of the dependency. + lib.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } } // do a full build on all the builders to guarantee that the builders are called. @@ -902,8 +919,13 @@ public final class ProjectHelper { project.build(IncrementalProjectBuilder.FULL_BUILD, PreCompilerBuilder.ID, newArgs, monitor); } else if (PostCompilerBuilder.ID.equals(name)) { - // skip... + if (includeDependencies == false) { + // this is a library, we need to build it! + project.build(IncrementalProjectBuilder.FULL_BUILD, name, + command.getArguments(), monitor); + } } else { + project.build(IncrementalProjectBuilder.FULL_BUILD, name, command.getArguments(), monitor); } @@ -921,18 +943,18 @@ public final class ProjectHelper { public static void buildWithDeps(IProject project, int kind, IProgressMonitor monitor) throws CoreException { // Get list of projects that we depend on - List<IJavaProject> androidProjectList = new ArrayList<IJavaProject>(); - try { - androidProjectList = getAndroidProjectDependencies( - BaseProjectHelper.getJavaProject(project)); - - } catch (JavaModelException e) { - AdtPlugin.printErrorToConsole(project, e); - } - - // Recursively build dependencies - for (IJavaProject dependency : androidProjectList) { - buildWithDeps(dependency.getProject(), kind, monitor); + ProjectState projectState = Sdk.getProjectState(project); + + // this gives us all the library projects, direct and indirect dependencies, + // so no need to run this method recursively. + List<IProject> libraries = projectState.getFullLibraryProjects(); + + // build dependencies in reverse order to prevent libraries being rebuilt + // due to refresh of other libraries (they would be compiled in the wrong mode). + for (int i = libraries.size() - 1 ; i >= 0 ; i--) { + IProject lib = libraries.get(i); + lib.build(kind, monitor); + lib.refreshLocal(IResource.DEPTH_INFINITE, monitor); } project.build(kind, monitor); |