diff --git a/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java index 05132a8b7734..cc9ff3bd7a6c 100644 --- a/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java +++ b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java @@ -48,11 +48,14 @@ public class JavaProjectDataService implements ProjectDataService> toImport, @NotNull Project project, boolean synchronous) { + if (!ExternalSystemApiUtil.isNewProjectConstruction()) { + return; + } if (toImport.size() != 1) { throw new IllegalArgumentException(String.format("Expected to get a single project but got %d: %s", toImport.size(), toImport)); } JavaProjectData projectData = toImport.iterator().next().getData(); - + // JDK. JavaSdkVersion version = projectData.getJdkVersion(); JavaSdk javaSdk = JavaSdk.getInstance(); diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java index 0c9b06c34182..74095e68c8d1 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java @@ -24,6 +24,7 @@ import com.intellij.openapi.externalSystem.model.Key; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.AtomicNotNullLazyValue; @@ -355,4 +356,21 @@ public class ExternalSystemApiUtil { public static String normalizePath(@Nullable String s) { return StringUtil.isEmpty(s) ? null : s; } + + /** + * We can divide all 'import from external system' use-cases into at least as below: + *
+   * 
+   * 
+ * This method allows to differentiate between them (e.g. we don't want to change language level when new module is imported to + * an existing project). + * + * @return true if new project is being imported; false if new module is being imported + */ + public static boolean isNewProjectConstruction() { + return ProjectManager.getInstance().getOpenProjects().length == 0; + } } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java index 32084132f17f..e7825a111748 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java @@ -236,10 +236,8 @@ public class ExternalSystemFacadeImpl public void applyProgressManager(@NotNull RemoteExternalSystemProgressNotificationManager progressManager) throws RemoteException { ExternalSystemTaskNotificationListener listener = new SwallowingNotificationListener(progressManager); myNotificationListener.set(listener); - List services = new ArrayList(myRemotes.values()); - for (RemoteExternalSystemService service : services) { - service.setNotificationListener(listener); - } + myProjectResolver.setNotificationListener(listener); + myBuildManager.setNotificationListener(listener); } /** diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java new file mode 100644 index 000000000000..3cd313df770d --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.externalSystem.service; + +import com.intellij.openapi.externalSystem.ExternalSystemManager; +import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; +import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.startup.StartupActivity; +import com.intellij.openapi.startup.StartupManager; +import com.intellij.util.SystemProperties; + +/** + * @author Denis Zhdanov + * @since 5/2/13 9:23 PM + */ +public class ExternalSystemStartupActivity implements StartupActivity { + + @Override + public void runActivity(final Project project) { + Runnable task = new Runnable() { + @SuppressWarnings("unchecked") + @Override + public void run() { + if (SystemProperties.getBooleanProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, false)) { + System.setProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, Boolean.toString(false)); + } + else { + for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) { + ExternalSystemUtil.refreshProjects(project, manager.getSystemId()); + } + } + } + }; + + if (project.isInitialized()) { + task.run(); + } + else { + StartupManager.getInstance(project).registerPostStartupActivity(task); + } + } +} diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ExternalProjectRefreshCallback.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ExternalProjectRefreshCallback.java new file mode 100644 index 000000000000..760d1c190e75 --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ExternalProjectRefreshCallback.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.externalSystem.service.project; + +import com.intellij.openapi.externalSystem.model.DataNode; +import com.intellij.openapi.externalSystem.model.project.ProjectData; +import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; +import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId; +import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** +* @author Denis Zhdanov +* @since 5/2/13 10:37 PM +*/ +public interface ExternalProjectRefreshCallback { + + /** + * Is expected to be called when + * {@link ExternalSystemProjectResolver#resolveProjectInfo(ExternalSystemTaskId, String, boolean, ExternalSystemExecutionSettings)} + * returns without exception. + * + * @param externalProject target external project (if available) + */ + void onSuccess(@Nullable DataNode externalProject); + + void onFailure(@NotNull String errorMessage, @Nullable String errorDetails); +} diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java index 00429f7790ac..cd9177dad6b7 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java @@ -15,10 +15,9 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; import com.intellij.openapi.externalSystem.util.Order; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.*; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; @@ -87,28 +86,16 @@ public class ContentRootDataService implements ProjectDataService data : datas) { ContentRootData contentRoot = data.getData(); - ContentEntry contentEntry = model.addContentEntry(toVfsUrl(contentRoot.getRootPath())); + ContentEntry contentEntry = findOrCreateContentRoot(model, contentRoot.getRootPath()); LOG.info(String.format("Importing content root '%s' for module '%s'", contentRoot.getRootPath(), module.getName())); for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE)) { - contentEntry.addSourceFolder(toVfsUrl(path), false); - LOG.info(String.format( - "Importing source root '%s' for content root '%s' of module '%s'", - path, contentRoot.getRootPath(), module.getName() - )); + createSourceRootIfAbsent(contentEntry, path, module.getName()); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST)) { - contentEntry.addSourceFolder(toVfsUrl(path), true); - LOG.info(String.format( - "Importing test root '%s' for content root '%s' of module '%s'", - path, contentRoot.getRootPath(), module.getName() - )); + createTestRootIfAbsent(contentEntry, path, module.getName()); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) { - contentEntry.addExcludeFolder(toVfsUrl(path)); - LOG.info(String.format( - "Importing excluded root '%s' for content root '%s' of module '%s'", - path, contentRoot.getRootPath(), module.getName() - )); + createExcludedRootIfAbsent(contentEntry, path, module.getName()); } } } @@ -119,6 +106,91 @@ public class ContentRootDataService implements ProjectDataService> toRemove, @NotNull Project project, boolean synchronous) { if (toRemove.isEmpty()) { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java index 673e82e97707..4b246a481f80 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java @@ -138,7 +138,6 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< } for (DataNode dependencyNode : nodesToImport) { - ProjectStructureHelper helper = ServiceManager.getService(module.getProject(), ProjectStructureHelper.class); ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel(); try { @@ -149,7 +148,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService< assert false; continue; } - LibraryOrderEntry orderEntry = helper.findIdeLibraryDependency(dependencyData.getName(), moduleRootModel); + LibraryOrderEntry orderEntry = myProjectStructureHelper.findIdeLibraryDependency(dependencyData.getName(), moduleRootModel); if (orderEntry == null) { // We need to get the most up-to-date Library object due to our project model restrictions. orderEntry = moduleRootModel.addLibraryEntry(library); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java index 0b899901d639..3ba386be2e93 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java @@ -44,6 +44,9 @@ public class ProjectDataServiceImpl implements ProjectDataService { @Override public void importData(@NotNull Collection> toImport, @NotNull Project project, boolean synchronous) { + if (!ExternalSystemApiUtil.isNewProjectConstruction()) { + return; + } if (toImport.size() != 1) { throw new IllegalArgumentException(String.format("Expected to get a single project but got %d: %s", toImport.size(), toImport)); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java index 789f066570c0..310fb9584346 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java @@ -6,9 +6,9 @@ import com.intellij.openapi.externalSystem.model.DataNode; import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.LibraryData; -import com.intellij.openapi.externalSystem.model.project.ModuleData; import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.externalSystem.model.task.ExternalSystemResolveProjectTask; +import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback; import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager; import com.intellij.openapi.externalSystem.service.settings.AbstractImportFromExternalSystemControl; import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; @@ -130,7 +130,7 @@ public abstract class AbstractExternalProjectImportBuilder projects = ContainerUtilRt.newArrayList(settings.getLinkedProjectsSettings()); + Set projects = ContainerUtilRt.newHashSet(settings.getLinkedProjectsSettings()); projects.add(myControl.getProjectSettings()); settings.setLinkedProjectsSettings(projects); onProjectInit(project); @@ -142,8 +142,7 @@ public abstract class AbstractExternalProjectImportBuilder> modules = ExternalSystemApiUtil.findAll(externalProjectNode, ProjectKeys.MODULE); - myProjectDataManager.importData(ProjectKeys.MODULE, modules, project, true); + myProjectDataManager.importData(externalProjectNode.getKey(), Collections.singleton(externalProjectNode), project, true); } }); } @@ -210,23 +209,25 @@ public abstract class AbstractExternalProjectImportBuilder errorReason = new Ref(); - final Ref errorDetails = new Ref(); + final Ref error = new Ref(); + ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() { + @Override + public void onSuccess(@Nullable DataNode externalProject) { + myExternalProjectNode = externalProject; + } + + @Override + public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) { + if (!StringUtil.isEmpty(errorDetails)) { + LOG.warn(errorDetails); + } + error.set(new ConfigurationException(ExternalSystemBundle.message("error.resolve.with.reason", errorMessage), + ExternalSystemBundle.message("error.resolve.generic"))); + } + }; try { final Project project = getProject(wizardContext); - myExternalProjectNode = ExternalSystemUtil.refreshProject(project, myExternalSystemId, projectFile.getAbsolutePath(), errorReason, - errorDetails, false, true); + ExternalSystemUtil.refreshProject( + project, + myExternalSystemId, + projectFile.getAbsolutePath(), + callback, + false, + true + ); } catch (IllegalArgumentException e) { throw new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)); } if (myExternalProjectNode == null) { - final String details = errorDetails.get(); - if (!StringUtil.isEmpty(details)) { - LOG.warn(details); + ConfigurationException exception = error.get(); + if (exception != null) { + throw exception; } - String errorMessage; - String reason = errorReason.get(); - if (reason == null) { - errorMessage = ExternalSystemBundle.message("error.resolve.generic.without.reason", externalSystemName, projectFile.getPath()); - } - else { - errorMessage = ExternalSystemBundle.message("error.resolve.with.reason", reason); - } - throw new ConfigurationException(errorMessage, ExternalSystemBundle.message("error.resolve.generic")); } else { applyProjectSettings(wizardContext); @@ -302,6 +314,9 @@ public abstract class AbstractExternalProjectImportBuilder T getToolWindowElement(@NotNull Class clazz, @Nullable DataContext context, @@ -177,43 +151,58 @@ public class ExternalSystemUtil { } } - public static void refreshProject(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) { - refreshProject(project, externalSystemId, new Ref()); - } + /** + * Asks to refresh all external projects of the target external system linked to the given ide project. + *

+ * 'Refresh' here means 'obtain the most up-to-date version and apply it to the ide'. + * + * @param project target ide project + * @param externalSystemId target external system which projects should be refreshed + */ + public static void refreshProjects(@NotNull final Project project, @NotNull ProjectSystemId externalSystemId) { + ExternalSystemManager manager = ExternalSystemApiUtil.getManager(externalSystemId); + if (manager == null) { + return; + } + AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project); + Collection projectsSettings = settings.getLinkedProjectsSettings(); + if (projectsSettings.isEmpty()) { + return; + } - public static void refreshProject(@NotNull Project project, - @NotNull ProjectSystemId externalSystemId, - @NotNull final Consumer errorCallback) - { - final Ref errorMessageHolder = new Ref() { + final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class); + final Set externalModuleNames = ContainerUtilRt.newHashSet(); + ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() { @Override - public void set(@Nullable String value) { - if (value != null) { - errorCallback.consume(value); + public void onSuccess(@Nullable DataNode externalProject) { + if (externalProject == null) { + return; } + Collection> moduleNodes = ExternalSystemApiUtil.findAll(externalProject, ProjectKeys.MODULE); + for (DataNode node : moduleNodes) { + externalModuleNames.add(node.getData().getName()); + } + projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, false); + } + + @Override + public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) { } }; - refreshProject(project, externalSystemId, errorMessageHolder); - } - - public static void refreshProject(@NotNull Project project, - @NotNull ProjectSystemId externalSystemId, - @NotNull final Ref errorMessageHolder) - { - ExternalSystemSettingsManager settingsManager = ServiceManager.getService(ExternalSystemSettingsManager.class); - AbstractExternalSystemSettings settings = settingsManager.getSettings(project, externalSystemId); - for (Object path : settings.getLinkedProjectsSettings()) { - Ref errorDetailsHolder = new Ref() { - @Override - public void set(@Nullable String error) { - if (!StringUtil.isEmpty(error)) { - assert error != null; - LOG.warn(error); - } - } - }; - refreshProject(project, externalSystemId, path.toString(), errorMessageHolder, errorDetailsHolder, true, false); + for (ExternalProjectSettings setting : projectsSettings) { + refreshProject(project, externalSystemId, setting.getExternalProjectPath(), callback, true, false); } + PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class); + List orphanIdeModules = ContainerUtilRt.newArrayList(); + String externalSystemIdAsString = externalSystemId.toString(); + for (Module module : platformFacade.getModules(project)) { + String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); + if (externalSystemIdAsString.equals(s) && !externalModuleNames.contains(module.getName())) { + orphanIdeModules.add(module); + } + } + + // TODO den offer to remove orphan modules here } @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @@ -231,21 +220,17 @@ public class ExternalSystemUtil { * * @param project target intellij project to use * @param externalProjectPath path of the target gradle project's file - * @param errorMessageHolder holder for the error message that describes a problem occurred during the refresh (if any) - * @param errorDetailsHolder holder for the error details of the problem occurred during the refresh (if any) + * @param callback callback to be notified on refresh result * @param resolveLibraries flag that identifies whether gradle libraries should be resolved during the refresh * @return the most up-to-date gradle project (if any) */ - @Nullable - public static DataNode refreshProject(@NotNull final Project project, - @NotNull final ProjectSystemId externalSystemId, - @NotNull final String externalProjectPath, - @NotNull final Ref errorMessageHolder, - @NotNull final Ref errorDetailsHolder, - final boolean resolveLibraries, - final boolean modal) + public static void refreshProject(@NotNull final Project project, + @NotNull final ProjectSystemId externalSystemId, + @NotNull final String externalProjectPath, + @NotNull final ExternalProjectRefreshCallback callback, + final boolean resolveLibraries, + final boolean modal) { - final Ref> externalProject = new Ref>(); final TaskUnderProgress refreshProjectStructureTask = new TaskUnderProgress() { @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"}) @Override @@ -253,22 +238,20 @@ public class ExternalSystemUtil { ExternalSystemResolveProjectTask task = new ExternalSystemResolveProjectTask(externalSystemId, project, externalProjectPath, resolveLibraries); task.execute(indicator); - externalProject.set(task.getExternalProject()); final Throwable error = task.getError(); if (error == null) { + DataNode externalProject = task.getExternalProject(); + callback.onSuccess(externalProject); return; } - final String message = buildErrorMessage(error); + String message = buildErrorMessage(error); if (StringUtil.isEmpty(message)) { - errorMessageHolder.set(String.format( + message = String.format( "Can't resolve %s project at '%s'. Reason: %s", ExternalSystemApiUtil.toReadableName(externalSystemId), externalProjectPath, message - )); + ); } - else { - errorMessageHolder.set(message); - } - errorDetailsHolder.set(extractDetails(error)); + callback.onFailure(message, extractDetails(error)); } }; @@ -310,12 +293,9 @@ public class ExternalSystemUtil { } } }); - return externalProject.get(); } private interface TaskUnderProgress { void execute(@NotNull ProgressIndicator indicator); } - - } diff --git a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml index b726ef82b4ed..bb8b5f0dcff1 100644 --- a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml +++ b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml @@ -1,6 +1,8 @@ + + - diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java index 755634c1b952..454917ca3c56 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/action/GradleRefreshProjectAction.java @@ -68,7 +68,7 @@ public class GradleRefreshProjectAction extends AbstractGradleLinkedProjectActio // return; //} - myErrorMessage.set(null); - ExternalSystemUtil.refreshProject(project, GradleConstants.SYSTEM_ID, myErrorMessage); + //myErrorMessage.set(null); + //ExternalSystemUtil.refreshProject(project, GradleConstants.SYSTEM_ID, myErrorMessage); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java index d58b1cdb3e23..375e04659ef2 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java @@ -46,7 +46,6 @@ import java.util.List; public class GradleProjectImportBuilder extends AbstractExternalProjectImportBuilder { public GradleProjectImportBuilder(@NotNull ExternalSystemSettingsManager settingsManager, @NotNull ProjectDataManager dataManager) { - // TODO den implement super(settingsManager, dataManager, new ImportFromGradleControl(), GradleConstants.SYSTEM_ID); } @@ -72,6 +71,9 @@ public class GradleProjectImportBuilder extends AbstractExternalProjectImportBui @Override protected void beforeCommit(@NotNull DataNode dataNode, @NotNull Project project) { + if (!ExternalSystemApiUtil.isNewProjectConstruction()) { + return; + } DataNode javaProjectNode = ExternalSystemApiUtil.find(dataNode, JavaProjectData.KEY); if (javaProjectNode == null) { return; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleStartupActivity.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleStartupActivity.java deleted file mode 100644 index 28e76a3ef4e6..000000000000 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/sync/GradleStartupActivity.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.jetbrains.plugins.gradle.sync; - -import com.intellij.openapi.externalSystem.model.ProjectSystemId; -import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.startup.StartupActivity; -import com.intellij.openapi.startup.StartupManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.config.GradlePatcher; -import org.jetbrains.plugins.gradle.util.GradleConstants; -import org.jetbrains.plugins.gradle.util.GradleUtil; - -/** - * Performs gradle-specific actions on IJ project loading. - *

- * Thread-safe. - * - * @author Denis Zhdanov - * @since 3/13/12 12:01 PM - */ -// TODO den generalize and move to 'external-system' -public class GradleStartupActivity implements StartupActivity { - @SuppressWarnings("UseOfArchaicSystemPropertyAccessors") - @Override - public void runActivity(@NotNull final Project project) { - Runnable task = new Runnable() { - @Override - public void run() { - // TODO den implement -// new GradlePatcher().patch(project); -// -// if (!Boolean.getBoolean(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT)) { -// ExternalSystemUtil.refreshProject(project, GradleConstants.SYSTEM_ID); -// } - } - }; - - if (project.isInitialized()) { - task.run(); - } - else { - StartupManager.getInstance(project).registerPostStartupActivity(task); - } - } -}