aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosiah Gaskin <josiahgaskin@google.com>2014-01-29 15:33:59 -0800
committerJosiah Gaskin <josiahgaskin@google.com>2014-01-29 16:17:24 -0800
commit12b441aa553fcf823c4e2746fe6a6bc8a89fd603 (patch)
treebca78bddd66fed46f460fefca343d732e649fcd6
parentff634e3a810918595a326ca1fbaf8b8a6aaa6e26 (diff)
downloadsdk-12b441aa553fcf823c4e2746fe6a6bc8a89fd603.zip
sdk-12b441aa553fcf823c4e2746fe6a6bc8a89fd603.tar.gz
sdk-12b441aa553fcf823c4e2746fe6a6bc8a89fd603.tar.bz2
Fix Dependency Project Creation
GridLayout and AppCompat are included in the SDK as dependency libraries rather than just .jar files because they include resources. Thus, when they are added as a dependency to a project they need to be added as library projects to the Eclipse workspace. There is code that automates this process, but it had a bug where it would not insert the correct target for the library project that it created. This change fixes that behavior and enables the automatic library project creation in the NewActivityWizard. Change-Id: I18aea5b7b6b93f7ca71e98385bf00b647ea99d51
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java18
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java6
3 files changed, 37 insertions, 8 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
index 98e43ab..37559e9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
@@ -93,6 +93,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
private static final String ANDROID_SUPPORT_V4_JAR = "android-support-v4.jar"; //$NON-NLS-1$
private static final String ANDROID_SUPPORT_V13_JAR = "android-support-v13.jar";//$NON-NLS-1$
private static final String APPCOMPAT_V7_JAR = "android-support-v7-appcompat.jar";//$NON-NLS-1$
+ private static final String APP_COMPAT_LIB_NAME = "appcompat_v7"; //$NON-NLS-1$
private ISelection mSelection;
/**
@@ -310,6 +311,18 @@ public class AddSupportJarAction implements IObjectActionDelegate {
final IJavaProject javaProject = JavaCore.create(project);
if (javaProject != null) {
+ // Don't add in the library if it already exists
+ ProjectState state = Sdk.getProjectState(project);
+ ProjectPropertiesWorkingCopy copy = state.getProperties().makeWorkingCopy();
+ for (String property : copy.keySet()) {
+ if (property.startsWith(ProjectProperties.PROPERTY_LIB_REF)) {
+ String libraryReference = copy.getProperty(property);
+ if (libraryReference != null && libraryReference.contains(APP_COMPAT_LIB_NAME)) {
+ return true;
+ }
+ }
+ }
+
File supportPath = getSupportPackageDir();
if (!supportPath.isDirectory()) {
File path = installSupport(7);
@@ -331,7 +344,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
// Create workspace copy of the project and add library dependency
IProject libraryProject = createLibraryProject(libraryPath, project,
- "appcompat_v7", waitForFinish); // $NON-NLS-1$
+ APP_COMPAT_LIB_NAME, waitForFinish);
if (libraryProject != null) {
return addLibraryDependency(libraryProject, project, waitForFinish);
}
@@ -460,7 +473,8 @@ public class AddSupportJarAction implements IObjectActionDelegate {
ProjectState state = Sdk.getProjectState(project);
String target = state.getProperties().getProperty(ProjectProperties.PROPERTY_TARGET);
if (target != null && target.length() > 0) {
- ProjectProperties properties = ProjectProperties.load(libraryPath.getPath(),
+ ProjectProperties properties = ProjectProperties.load(
+ destDir.toLocalFile(EFS.NONE, new NullProgressMonitor()).getPath(),
PropertyType.PROJECT);
ProjectPropertiesWorkingCopy copy = properties.makeWorkingCopy();
copy.setProperty(ProjectProperties.PROPERTY_TARGET, target);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
index 535aa1e..d1ecebf 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
@@ -20,18 +20,25 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectW
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_API_LEVEL;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_PACKAGE_NAME;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_TARGET_API;
+import static org.eclipse.core.resources.IResource.DEPTH_INFINITE;
import com.android.annotations.NonNull;
+import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ui.IWorkbench;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Set;
@@ -132,6 +139,20 @@ public class NewActivityWizard extends TemplateWizard {
}
@Override
+ public boolean performFinish(IProgressMonitor monitor) throws InvocationTargetException {
+ boolean success = super.performFinish(monitor);
+
+ if (success) {
+ List<Runnable> finalizingTasks = getFinalizingActions();
+ for (Runnable r : finalizingTasks) {
+ r.run();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
@NonNull
protected IProject getProject() {
return mActivityValues.project;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
index 6331720..56bc955 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
@@ -359,16 +359,10 @@ public class NewProjectWizard extends TemplateWizard {
AdtPlugin.log(e, null);
}
- // Run finalizing actions
- // Display.getDefault().asyncExec(new Runnable() {
- // @Override
- // public void run() {
List<Runnable> finalizingTasks = getFinalizingActions();
for (Runnable r : finalizingTasks) {
r.run();
}
- // }
- // });
return true;
} catch (Exception ioe) {