diff options
Diffstat (limited to 'platform/external-system-impl')
7 files changed, 176 insertions, 53 deletions
diff --git a/platform/external-system-impl/external-system-impl.iml b/platform/external-system-impl/external-system-impl.iml index aa68fdc4d7b6..1cbf68f907f9 100644 --- a/platform/external-system-impl/external-system-impl.iml +++ b/platform/external-system-impl/external-system-impl.iml @@ -24,6 +24,7 @@ <orderEntry type="library" scope="TEST" name="JUnit4" level="project" /> <orderEntry type="module" module-name="testFramework" scope="TEST" /> <orderEntry type="module" module-name="testFramework-java" scope="TEST" /> + <orderEntry type="module" module-name="compiler-impl" scope="TEST" /> </component> </module> diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java deleted file mode 100644 index 1e6dadd0d3b8..000000000000 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/ProjectStructureServices.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.openapi.externalSystem.service.project; - -import org.jetbrains.annotations.NotNull; - -/** - * Facades all services necessary for the 'sync project changes' processing. - * <p/> - * Thread-safe. - * - * @author Denis Zhdanov - * @since 2/14/12 1:26 PM - */ -public class ProjectStructureServices { - - @NotNull private final ProjectStructureHelper myProjectStructureHelper; - @NotNull private final PlatformFacade myPlatformFacade; - @NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper; - - public ProjectStructureServices(@NotNull ProjectStructureHelper projectStructureHelper, - @NotNull PlatformFacade platformFacade, - @NotNull ExternalLibraryPathTypeMapper mapper) - { - myProjectStructureHelper = projectStructureHelper; - myPlatformFacade = platformFacade; - myLibraryPathTypeMapper = mapper; - } - - @NotNull - public ProjectStructureHelper getProjectStructureHelper() { - return myProjectStructureHelper; - } - - @NotNull - public PlatformFacade getPlatformFacade() { - return myPlatformFacade; - } - - @NotNull - public ExternalLibraryPathTypeMapper getLibraryPathTypeMapper() { - return myLibraryPathTypeMapper; - } -} 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 7e7483869728..3e1c95ad3766 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 @@ -33,8 +33,13 @@ 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.*; +import com.intellij.openapi.roots.ContentEntry; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootModificationUtil; +import com.intellij.openapi.roots.SourceFolder; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -151,7 +156,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true, createEmptyContentRootDirectories); } for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) { - createExcludedRootIfAbsent(contentEntry, path, module.getName()); + createExcludedRootIfAbsent(contentEntry, path, module.getName(), module.getProject()); } contentEntriesMap.remove(contentEntry.getUrl()); } @@ -214,14 +219,18 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat } } - private static void createExcludedRootIfAbsent(@NotNull ContentEntry entry, @NotNull SourceRoot root, @NotNull String moduleName) { + private static void createExcludedRootIfAbsent(@NotNull ContentEntry entry, @NotNull SourceRoot root, @NotNull String moduleName, @NotNull Project project) { + String rootPath = root.getPath(); for (VirtualFile file : entry.getExcludeFolderFiles()) { - if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) { + if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(rootPath)) { return; } } LOG.info(String.format("Importing excluded root '%s' for content root '%s' of module '%s'", root, entry.getUrl(), moduleName)); - entry.addExcludeFolder(toVfsUrl(root.getPath())); + entry.addExcludeFolder(toVfsUrl(rootPath)); + if (!Registry.is("ide.hide.excluded.files")) { + ChangeListManager.getInstance(project).addDirectoryToIgnoreImplicitly(rootPath); + } } @Override diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java index 4b1e3b13a22f..32919794eca4 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java @@ -274,6 +274,7 @@ public class ModuleDataService implements ProjectDataService<ModuleData, Module> module.putUserData(MODULE_DATA_KEY, moduleData); module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, moduleData.getOwner().toString()); + module.setOption(ExternalSystemConstants.LINKED_PROJECT_ID_KEY, moduleData.getId()); module.setOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY, moduleData.getLinkedExternalProjectPath()); final ProjectData projectData = moduleDataNode.getData(ProjectKeys.PROJECT); module.setOption(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY, projectData != null ? projectData.getLinkedExternalProjectPath() : ""); diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java index 6575ffb107f0..c2dcfe57b010 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java @@ -25,6 +25,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; @@ -40,8 +41,10 @@ public class ProjectDataManager { private static final Logger LOG = Logger.getInstance("#" + ProjectDataManager.class.getName()); - @NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>> myServices = - new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() { + @NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>> myServices; + + public ProjectDataManager() { + myServices = new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() { @NotNull @Override protected Map<Key<?>, List<ProjectDataService<?, ?>>> compute() { @@ -57,10 +60,22 @@ public class ProjectDataManager { for (List<ProjectDataService<?, ?>> services : result.values()) { ExternalSystemApiUtil.orderAwareSort(services); } - return result; } }; + } + + @Nullable + public List<ProjectDataService<?, ?>> getDataServices(Key<?> key) { + return myServices.getValue().get(key); + } + + @Nullable + public ProjectDataService<?, ?> getDataService(Key<?> key) { + final List<ProjectDataService<?, ?>> dataServices = myServices.getValue().get(key); + assert dataServices == null || dataServices.isEmpty() || dataServices.size() == 1; + return ContainerUtil.getFirstItem(dataServices); + } @SuppressWarnings("unchecked") public <T> void importData(@NotNull Collection<DataNode<?>> nodes, @NotNull Project project, boolean synchronous) { diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java index 5dcb5ef71e3b..deb9a9044ea6 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java @@ -193,6 +193,11 @@ public abstract class AbstractImportFromExternalSystemControl< return myProjectSettingsControl; } + @Nullable + public ExternalSystemSettingsControl<SystemSettings> getSystemSettingsControl() { + return mySystemSettingsControl; + } + public void setLinkedProjectPath(@NotNull String path) { myProjectSettings.setExternalProjectPath(path); myLinkedProjectPathField.setText(path); diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java index 22ec927eb30d..449de84f4627 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java @@ -15,24 +15,42 @@ */ package com.intellij.openapi.externalSystem.test; +import com.intellij.compiler.CompilerTestUtil; +import com.intellij.compiler.CompilerWorkspaceConfiguration; +import com.intellij.compiler.artifacts.ArtifactsTestUtil; +import com.intellij.compiler.impl.ModuleCompileScope; +import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.compiler.CompileContext; +import com.intellij.openapi.compiler.CompileScope; +import com.intellij.openapi.compiler.CompileStatusNotification; +import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.StdModuleTypes; import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; +import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.packaging.artifacts.Artifact; +import com.intellij.packaging.impl.compiler.ArtifactCompileScope; import com.intellij.testFramework.IdeaTestCase; +import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PsiTestUtil; import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; +import com.intellij.util.concurrency.Semaphore; +import com.intellij.util.io.TestFileSystemItem; import com.intellij.util.ui.UIUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; @@ -40,6 +58,7 @@ import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; +import javax.swing.*; import java.awt.*; import java.io.File; import java.io.IOException; @@ -129,11 +148,11 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { @Override public void tearDown() throws Exception { try { - myProject = null; - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + edt(new Runnable() { @Override public void run() { try { + CompilerTestUtil.disableExternalCompiler(myProject); tearDownFixtures(); } catch (Exception e) { @@ -141,6 +160,7 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { } } }); + myProject = null; if (!FileUtil.delete(myTestDir) && myTestDir.exists()) { System.err.println("Cannot delete " + myTestDir); //printDirectoryContent(myDir); @@ -319,7 +339,11 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { protected VirtualFile createProjectSubFile(String relativePath) throws IOException { File f = new File(getProjectPath(), relativePath); FileUtil.ensureExists(f.getParentFile()); - f.createNewFile(); + FileUtil.ensureCanCreateFile(f); + final boolean created = f.createNewFile(); + if(!created) { + throw new AssertionError("Unable to create the project sub file: " + f.getAbsolutePath()); + } return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f); } @@ -329,6 +353,116 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { return file; } + + protected void compileModules(final String... moduleNames) { + compile(createModulesCompileScope(moduleNames)); + } + + protected void buildArtifacts(String... artifactNames) { + compile(createArtifactsScope(artifactNames)); + } + + private void compile(final CompileScope scope) { + edt(new Runnable() { + @Override + public void run() { + for (Module module : scope.getAffectedModules()) { + setupJdkForModule(module.getName()); + } + } + }); + + CompilerWorkspaceConfiguration.getInstance(myProject).CLEAR_OUTPUT_DIRECTORY = true; + + final Semaphore semaphore = new Semaphore(); + semaphore.down(); + edt(new Runnable() { + @Override + public void run() { + CompilerTestUtil.enableExternalCompiler(); + CompilerManager.getInstance(myProject).make(scope, new CompileStatusNotification() { + @Override + public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { + //assertFalse(aborted); + //assertEquals(collectMessages(compileContext, CompilerMessageCategory.ERROR), 0, errors); + //assertEquals(collectMessages(compileContext, CompilerMessageCategory.WARNING), 0, warnings); + semaphore.up(); + } + }); + } + }); + while (!semaphore.waitFor(100)) { + if (SwingUtilities.isEventDispatchThread()) { + UIUtil.dispatchAllInvocationEvents(); + } + } + if (SwingUtilities.isEventDispatchThread()) { + UIUtil.dispatchAllInvocationEvents(); + } + } + + private CompileScope createModulesCompileScope(final String[] moduleNames) { + final List<Module> modules = new ArrayList<Module>(); + for (String name : moduleNames) { + modules.add(getModule(name)); + } + return new ModuleCompileScope(myProject, modules.toArray(new Module[modules.size()]), false); + } + + private CompileScope createArtifactsScope(String[] artifactNames) { + List<Artifact> artifacts = new ArrayList<Artifact>(); + for (String name : artifactNames) { + artifacts.add(ArtifactsTestUtil.findArtifact(myProject, name)); + } + return ArtifactCompileScope.createArtifactsScope(myProject, artifacts); + } + + protected Sdk setupJdkForModule(final String moduleName) { + final Sdk sdk = true ? JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk() : createJdk("Java 1.5"); + ModuleRootModificationUtil.setModuleSdk(getModule(moduleName), sdk); + return sdk; + } + + protected static Sdk createJdk(String versionName) { + return IdeaTestUtil.getMockJdk17(versionName); + } + + protected Module getModule(final String name) { + AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); + try { + Module m = ModuleManager.getInstance(myProject).findModuleByName(name); + assertNotNull("Module " + name + " not found", m); + return m; + } + finally { + accessToken.finish(); + } + } + + protected void assertExplodedLayout(String artifactName, String expected) { + assertJarLayout(artifactName + " exploded", expected); + } + + protected void assertJarLayout(String artifactName, String expected) { + ArtifactsTestUtil.assertLayout(myProject, artifactName, expected); + } + + protected void assertArtifactOutputPath(final String artifactName, final String expected) { + ArtifactsTestUtil.assertOutputPath(myProject, artifactName, expected); + } + + protected void assertArtifactOutputFileName(final String artifactName, final String expected) { + ArtifactsTestUtil.assertOutputFileName(myProject, artifactName, expected); + } + + protected void assertArtifactOutput(String artifactName, TestFileSystemItem fs) { + final Artifact artifact = ArtifactsTestUtil.findArtifact(myProject, artifactName); + final VirtualFile outputFile = artifact.getOutputFile(); + assert outputFile != null; + final File file = VfsUtilCore.virtualToIoFile(outputFile); + fs.assertFileEqual(file); + } + private static void setFileContent(final VirtualFile file, final String content, final boolean advanceStamps) throws IOException { new WriteAction<VirtualFile>() { @Override |