public static void addJavaHome(@NotNull JavaParameters params, @NotNull Module module) { final Sdk sdk = ModuleUtilCore.getSdk(module, JavaModuleExtensionImpl.class); if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) { String path = StringUtil.trimEnd(sdk.getHomePath(), File.separator); if (StringUtil.isNotEmpty(path)) { Map<String, String> env = params.getEnv(); if (env == null) { env = new HashMap<String, String>(); params.setEnv(env); } env.put("JAVA_HOME", FileUtil.toSystemDependentName(path)); } } }
public void collectCommonPluginRoots( Map<String, VirtualFile> result, @NotNull Module module, boolean refresh) { if (isCommonPluginsModule(module)) { for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) { String pluginName = getInstalledPluginNameByPath(module.getProject(), root); if (pluginName != null) { result.put(pluginName, root); } } } else { VirtualFile root = findAppRoot(module); if (root == null) return; extractPlugins( module.getProject(), root.findChild(MvcModuleStructureUtil.PLUGINS_DIRECTORY), result); extractPlugins( module.getProject(), MvcModuleStructureUtil.findFile(getCommonPluginsDir(module), refresh), result); extractPlugins( module.getProject(), MvcModuleStructureUtil.findFile(getGlobalPluginsDir(module), refresh), result); } }
@Override public void writeExternal(Element element) throws WriteExternalException { super.writeExternal(element); JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element); writeModule(element); DefaultJDOMExternalizer.writeExternal(this, element); DefaultJDOMExternalizer.writeExternal(getPersistantData(), element); EnvironmentVariablesComponent.writeExternal(element, getPersistantData().getEnvs()); Element propertiesElement = element.getChild("properties"); if (propertiesElement == null) { propertiesElement = new Element("properties"); element.addContent(propertiesElement); } Map<String, String> properties = getPersistantData().TEST_PROPERTIES; for (Map.Entry<String, String> entry : properties.entrySet()) { Element property = new Element("property"); property.setAttribute("name", entry.getKey()); property.setAttribute("value", entry.getValue()); propertiesElement.addContent(property); } Element listenersElement = element.getChild("listeners"); if (listenersElement == null) { listenersElement = new Element("listeners"); element.addContent(listenersElement); } List<String> listeners = getPersistantData().TEST_LISTENERS; for (String listener : listeners) { Element listenerElement = new Element("listener"); listenerElement.setAttribute("class", listener); listenersElement.addContent(listenerElement); } final Set<String> patterns = getPersistantData().getPatterns(); if (!patterns.isEmpty()) { final Element patternsElement = new Element(PATTERNS_EL_NAME); for (String o : patterns) { final Element patternElement = new Element(PATTERN_EL_NAME); patternElement.setAttribute(TEST_CLASS_ATT_NAME, o); patternsElement.addContent(patternElement); } element.addContent(patternsElement); } }
@Override public void readExternal(Element element) throws InvalidDataException { PathMacroManager.getInstance(getProject()).expandPaths(element); super.readExternal(element); JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element); readModule(element); DefaultJDOMExternalizer.readExternal(this, element); DefaultJDOMExternalizer.readExternal(getPersistantData(), element); EnvironmentVariablesComponent.readExternal(element, getPersistantData().getEnvs()); Map<String, String> properties = getPersistantData().TEST_PROPERTIES; properties.clear(); Element propertiesElement = element.getChild("properties"); if (propertiesElement != null) { List<Element> children = propertiesElement.getChildren("property"); for (Element property : children) { properties.put(property.getAttributeValue("name"), property.getAttributeValue("value")); } } List<String> listeners = getPersistantData().TEST_LISTENERS; listeners.clear(); Element listenersElement = element.getChild("listeners"); if (listenersElement != null) { List<Element> children = listenersElement.getChildren("listener"); for (Element listenerClassName : children) { listeners.add(listenerClassName.getAttributeValue("class")); } } final Element patternsElement = element.getChild(PATTERNS_EL_NAME); if (patternsElement != null) { final LinkedHashSet<String> tests = new LinkedHashSet<String>(); for (Object o : patternsElement.getChildren(PATTERN_EL_NAME)) { Element patternElement = (Element) o; tests.add(patternElement.getAttributeValue(TEST_CLASS_ATT_NAME)); } getPersistantData().setPatterns(tests); } }
private void extractPlugins( Project project, @Nullable VirtualFile pluginRoot, Map<String, VirtualFile> res) { if (pluginRoot != null) { VirtualFile[] children = pluginRoot.getChildren(); if (children != null) { for (VirtualFile child : children) { String pluginName = getInstalledPluginNameByPath(project, child); if (pluginName != null) { res.put(pluginName, child); } } } } }
public Collection<VirtualFile> getCommonPluginRoots(@NotNull Module module, boolean refresh) { Map<String, VirtualFile> result = new HashMap<String, VirtualFile>(); collectCommonPluginRoots(result, module, refresh); return result.values(); }
protected static void addCommonEnvironmentVariables(Map<String, String> env) { PythonEnvUtil.setPythonUnbuffered(env); env.put("PYCHARM_HOSTED", "1"); }