From da0f985ef88a9d2353ab8e85ad7c3e6da6fd1f95 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 16 Apr 2019 13:32:13 +0300 Subject: [PATCH] [groovy] don't use built-in groovy-starter.conf (IDEA-210733) It adds tools.jar unnecessarily; and it doesn't make sense in environments without full Groovy SDK (e.g. Maven). --- .../resources/conf/groovy-starter.conf | 23 ------------------- .../plugins/groovy/gant/GantRunner.java | 12 ++++++---- .../runner/DefaultGroovyScriptRunner.java | 10 ++++---- .../groovy/runner/GroovyScriptRunner.java | 20 +++------------- 4 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 plugins/groovy/groovy-psi/resources/conf/groovy-starter.conf diff --git a/plugins/groovy/groovy-psi/resources/conf/groovy-starter.conf b/plugins/groovy/groovy-psi/resources/conf/groovy-starter.conf deleted file mode 100644 index 6f24a10b0d8b..000000000000 --- a/plugins/groovy/groovy-psi/resources/conf/groovy-starter.conf +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################## -## ## -## Groovy Classloading Configuration ## -## ## -############################################################################## - -## -## $Revision: 9225 $ $Date: 2007-11-15 21:17:45 +0100 (Do, 15 Nov 2007) $ -## -## Note: do not add classes from java.lang here. No rt.jar and on some -## platforms no tools.jar -## -## See http://groovy.codehaus.org/api/org/codehaus/groovy/tools/LoaderConfiguration.html -## for the file format - - # load required libraries - load !{groovy.home}/lib/*.jar - - # load user specific libraries - load !{user.home}/.groovy/lib/*.jar - - # tools.jar for ant tasks - load ${tools.jar} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java index 4230c81e4470..bed835918c60 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.gant; import com.intellij.execution.CantRunException; @@ -50,6 +50,7 @@ public class GantRunner extends GroovyScriptRunner { } } + @Nullable private static String getGantConfPath(final String gantHome) { String confPath = FileUtil.toSystemDependentName(gantHome + "/conf/gant-starter.conf"); if (new File(confPath).exists()) { @@ -70,14 +71,15 @@ public class GantRunner extends GroovyScriptRunner { setGroovyHome(params, gantHome); final String confPath = getGantConfPath(gantHome); - params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); + if (confPath != null) { + params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); + params.getProgramParametersList().add("--conf"); + params.getProgramParametersList().add(confPath); + } params.getVMParametersList().addParametersString(configuration.getVMParameters()); params.setMainClass("org.codehaus.groovy.tools.GroovyStarter"); - params.getProgramParametersList().add("--conf"); - params.getProgramParametersList().add(confPath); - if (gantHome.contains("grails")) { params.getClassPath().addAllFiles(GroovyUtils.getFilesInDirectoryByPattern(gantHome + "/lib", ".*\\.jar")); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java index 1846d21c4882..ab2ff5c4501c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java @@ -102,14 +102,16 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner { } final String confPath = getConfPath(groovyHomeDependentName); - params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); + if (confPath != null) { + params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath); + params.getProgramParametersList().add("--conf"); + params.getProgramParametersList().add(confPath); + } + HttpConfigurable.getInstance().getJvmProperties(false, null).forEach(p -> params.getVMParametersList().addProperty(p.first, p.second)); params.setMainClass("org.codehaus.groovy.tools.GroovyStarter"); - params.getProgramParametersList().add("--conf"); - params.getProgramParametersList().add(confPath); - params.getProgramParametersList().add("--main"); params.getProgramParametersList().add(mainClass); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java index 41f2f4098ab8..7cd862e3026f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.runner; import com.intellij.execution.CantRunException; @@ -53,13 +39,13 @@ public abstract class GroovyScriptRunner { return false; } + @Nullable protected static String getConfPath(final String groovyHomePath) { String confpath = FileUtil.toSystemDependentName(groovyHomePath + "/conf/groovy-starter.conf"); if (new File(confpath).exists()) { return confpath; } - - return getPathInConf("groovy-starter.conf"); + return null; } public static String getPathInConf(String fileName) {