use of com.intellij.openapi.projectRoots.Sdk in project intellij-community by JetBrains.
the class GroovyHotSwapper method patchJavaParameters.
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
ApplicationManager.getApplication().assertReadAccessAllowed();
if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
return;
}
if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
return;
}
if (hasSpringLoadedReloader(javaParameters)) {
return;
}
if (!(configuration instanceof RunConfiguration)) {
return;
}
final Project project = ((RunConfiguration) configuration).getProject();
if (project == null) {
return;
}
if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
if (configuration instanceof ModuleBasedConfiguration) {
final Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
if (module != null) {
final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
}
}
Sdk jdk = javaParameters.getJdk();
if (jdk != null) {
String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
if (vendor != null && vendor.contains("IBM")) {
LOG.info("Due to IBM JDK peculiarities (IDEA-59070) we don't add Groovy agent when running applications under it");
return;
}
}
if (!project.isDefault() && containsGroovyClasses(project)) {
final String agentPath = handleSpacesInPath(getAgentJarPath());
if (agentPath != null) {
javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
}
}
}
use of com.intellij.openapi.projectRoots.Sdk in project intellij-community by JetBrains.
the class MavenAnnotationProcessorConfigurer method configure.
@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
if (module == null)
return;
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null) {
String versionString = sdk.getVersionString();
if (versionString != null) {
if (versionString.contains("1.5") || versionString.contains("1.4") || versionString.contains("1.3") || versionString.contains("1.2")) {
return;
}
}
}
final CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
final MavenProject rootProject = ObjectUtils.notNull(MavenProjectsManager.getInstance(project).findRootProject(mavenProject), mavenProject);
if (shouldEnableAnnotationProcessors(mavenProject)) {
final String moduleProfileName;
String annotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(mavenProject, false);
if (annotationProcessorDirectory == null) {
annotationProcessorDirectory = DEFAULT_ANNOTATION_PATH_OUTPUT;
}
String testAnnotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(mavenProject, true);
if (testAnnotationProcessorDirectory == null) {
testAnnotationProcessorDirectory = DEFAULT_TEST_ANNOTATION_OUTPUT;
}
final boolean isDefault;
if (isMavenDefaultAnnotationProcessorConfiguration(annotationProcessorDirectory, testAnnotationProcessorDirectory, mavenProject)) {
moduleProfileName = MAVEN_DEFAULT_ANNOTATION_PROFILE;
isDefault = true;
} else if (isMavenProcessorPluginDefaultConfiguration(annotationProcessorDirectory, testAnnotationProcessorDirectory, mavenProject)) {
moduleProfileName = MAVEN_BSC_DEFAULT_ANNOTATION_PROFILE;
isDefault = true;
} else {
moduleProfileName = PROFILE_PREFIX + module.getName();
isDefault = false;
}
ProcessorConfigProfile moduleProfile = compilerConfiguration.findModuleProcessorProfile(moduleProfileName);
if (moduleProfile == null) {
moduleProfile = new ProcessorConfigProfileImpl(moduleProfileName);
compilerConfiguration.addModuleProcessorProfile(moduleProfile);
}
moduleProfile.setOutputRelativeToContentRoot(true);
moduleProfile.setEnabled(true);
moduleProfile.setObtainProcessorsFromClasspath(true);
moduleProfile.setGeneratedSourcesDirectoryName(annotationProcessorDirectory, false);
moduleProfile.setGeneratedSourcesDirectoryName(testAnnotationProcessorDirectory, true);
moduleProfile.clearProcessorOptions();
for (Map.Entry<String, String> entry : mavenProject.getAnnotationProcessorOptions().entrySet()) {
moduleProfile.setOption(entry.getKey(), entry.getValue());
}
moduleProfile.clearProcessors();
final List<String> processors = mavenProject.getDeclaredAnnotationProcessors();
if (processors != null) {
for (String processor : processors) {
moduleProfile.addProcessor(processor);
}
}
moduleProfile.addModuleName(module.getName());
cleanAndMergeModuleProfiles(rootProject, compilerConfiguration, moduleProfile, isDefault, module);
} else {
cleanAndMergeModuleProfiles(rootProject, compilerConfiguration, null, false, module);
}
}
use of com.intellij.openapi.projectRoots.Sdk in project intellij-community by JetBrains.
the class MavenIdeaPluginConfigurer method configureJdk.
private static void configureJdk(Element cfg, @NotNull Module module) {
String jdkName = cfg.getChildTextTrim("jdkName");
if (StringUtil.isEmptyOrSpaces(jdkName))
return;
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
String currentSdkName = null;
Sdk sdk = rootManager.getSdk();
if (sdk != null) {
currentSdkName = sdk.getName();
}
if (!jdkName.equals(currentSdkName)) {
ModifiableRootModel model = rootManager.getModifiableModel();
if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
model.inheritSdk();
} else {
Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
if (jdk != null) {
model.setSdk(jdk);
} else {
model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
}
}
model.commit();
}
}
use of com.intellij.openapi.projectRoots.Sdk in project intellij-community by JetBrains.
the class XsltDebuggerExtension method patchParameters.
public void patchParameters(final SimpleJavaParameters parameters, XsltRunConfiguration configuration, UserDataHolder extensionData) throws CantRunException {
final XsltRunConfiguration.OutputType outputType = configuration.getOutputType();
final Sdk jdk = configuration.getEffectiveJDK();
assert jdk != null;
final String ver = jdk.getVersionString();
if (ver == null || (ver.contains("1.0") || ver.contains("1.1") || ver.contains("1.2") || ver.contains("1.3") || ver.contains("1.4"))) {
throw new CantRunException("The XSLT Debugger can only be used with JDK 1.5+");
}
// TODO: fix and remove
if (outputType != XsltRunConfiguration.OutputType.CONSOLE) {
throw new CantRunException("XSLT Debugger requires Output Type == CONSOLE");
}
try {
final int port = NetUtils.findAvailableSocketPort();
parameters.getVMParametersList().defineProperty("xslt.debugger.port", String.valueOf(port));
extensionData.putUserData(PORT, port);
} catch (IOException e) {
LOG.info(e);
throw new CantRunException("Unable to find a free network port");
}
final char c = File.separatorChar;
final PluginId pluginId = PluginManagerCore.getPluginByClassName(getClass().getName());
assert pluginId != null || System.getProperty("xslt-debugger.plugin.path") != null;
final File pluginPath;
if (pluginId != null) {
final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(pluginId);
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
// -Dxslt-debugger.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-debugger-engine
pluginPath = new File(System.getProperty("xslt-debugger.plugin.path"));
}
File rtClasspath = new File(pluginPath, "lib" + c + "xslt-debugger-engine.jar");
if (rtClasspath.exists()) {
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
final File rmiStubs = new File(pluginPath, "lib" + c + "rmi-stubs.jar");
assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
final File engineImpl = new File(pluginPath, "lib" + c + "rt" + c + "xslt-debugger-engine-impl.jar");
assert engineImpl.exists() : engineImpl.getAbsolutePath();
parameters.getClassPath().addTail(engineImpl.getAbsolutePath());
} else {
if (!(rtClasspath = new File(pluginPath, "classes")).exists()) {
if (ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists()) {
rtClasspath = pluginPath;
final File engineImplInternal = new File(pluginPath, ".." + c + "xslt-debugger-engine-impl");
assert engineImplInternal.exists() : engineImplInternal.getAbsolutePath();
parameters.getClassPath().addTail(engineImplInternal.getAbsolutePath());
} else {
throw new CantRunException("Runtime classes not found");
}
}
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
final File rmiStubs = new File(rtClasspath, "rmi-stubs.jar");
assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
}
File trove4j = new File(PathManager.getLibPath() + c + "trove4j.jar");
if (!trove4j.exists()) {
trove4j = new File(PathManager.getHomePath() + c + "community" + c + "lib" + c + "trove4j.jar");
assert trove4j.exists() : trove4j.getAbsolutePath();
}
parameters.getClassPath().addTail(trove4j.getAbsolutePath());
final String type = parameters.getVMParametersList().getPropertyValue("xslt.transformer.type");
if ("saxon".equalsIgnoreCase(type)) {
addSaxon(parameters, pluginPath, SAXON_6_JAR);
} else if ("saxon9".equalsIgnoreCase(type)) {
addSaxon(parameters, pluginPath, SAXON_9_JAR);
} else if ("xalan".equalsIgnoreCase(type)) {
final Boolean xalanPresent = isValidXalanPresent(parameters);
if (xalanPresent == null) {
addXalan(parameters, pluginPath);
} else if (!xalanPresent) {
throw new CantRunException("Unsupported Xalan version is present in classpath.");
}
} else if (type != null) {
throw new CantRunException("Unsupported Transformer type '" + type + "'");
} else if (parameters.getClassPath().getPathsString().toLowerCase().contains("xalan")) {
if (isValidXalanPresent(parameters) == Boolean.TRUE) {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "xalan");
}
}
final VirtualFile xsltFile = configuration.findXsltFile();
final PsiManager psiManager = PsiManager.getInstance(configuration.getProject());
final XsltChecker.LanguageLevel level;
if (xsltFile != null) {
level = XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile));
} else {
level = XsltChecker.LanguageLevel.V1;
}
extensionData.putUserData(VERSION, level);
if (!parameters.getVMParametersList().hasProperty("xslt.transformer.type")) {
// add saxon for backward-compatibility
if (level == XsltChecker.LanguageLevel.V2) {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon9");
addSaxon(parameters, pluginPath, SAXON_9_JAR);
} else {
parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon");
addSaxon(parameters, pluginPath, SAXON_6_JAR);
}
}
parameters.getVMParametersList().defineProperty("xslt.main", "org.intellij.plugins.xsltDebugger.rt.XSLTDebuggerMain");
}
use of com.intellij.openapi.projectRoots.Sdk in project intellij-community by JetBrains.
the class RunPythonConsoleAction method update.
@Override
public void update(final AnActionEvent e) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(false);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
Pair<Sdk, Module> sdkAndModule = PydevConsoleRunner.findPythonSdkAndModule(project, e.getData(LangDataKeys.MODULE));
if (sdkAndModule.first != null) {
e.getPresentation().setEnabled(true);
}
}
}
Aggregations