mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Allow to include "Provided" scope in classpath. IDEA-107048
This commit is contained in:
+14
-11
@@ -1,18 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.application.ApplicationConfigurable">
|
||||
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="53" y="36" width="708" height="326"/>
|
||||
<xy x="53" y="36" width="708" height="341"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="eeb03">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="50b09" class="com.intellij.execution.ui.CommonJavaParametersPanel" binding="myCommonProgramParameters">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
@@ -42,13 +37,13 @@
|
||||
</component>
|
||||
<component id="e88bd" class="com.intellij.execution.ui.JrePathEditor" binding="myJrePathEditor">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="b45cf" class="javax.swing.JCheckBox" binding="myShowSwingInspectorCheckbox">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="show.swing.inspector"/>
|
||||
@@ -63,20 +58,28 @@
|
||||
</vspacer>
|
||||
<vspacer id="7cceb">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="-1" height="10"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="c452d2" class="com.intellij.openapi.ui.LabeledComponent" binding="myShortenClasspathModeCombo" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelLocation value="West"/>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.shorten.command.line.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="241cb" class="com.intellij.ui.components.JBCheckBox" binding="myIncludeProvidedDeps">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.include.provided.scope"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+4
@@ -32,6 +32,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
import com.intellij.ui.EditorTextFieldWithBrowseButton;
|
||||
import com.intellij.ui.PanelWithAnchor;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -50,6 +51,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
private final ConfigurationModuleSelector myModuleSelector;
|
||||
private JrePathEditor myJrePathEditor;
|
||||
private JCheckBox myShowSwingInspectorCheckbox;
|
||||
private JBCheckBox myIncludeProvidedDeps;
|
||||
private final JreVersionDetector myVersionDetector;
|
||||
private final Project myProject;
|
||||
private JComponent myAnchor;
|
||||
@@ -82,6 +84,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
configuration.ALTERNATIVE_JRE_PATH_ENABLED = myJrePathEditor.isAlternativeJreSelected();
|
||||
configuration.ENABLE_SWING_INSPECTOR = (myVersionDetector.isJre50Configured(configuration) || myVersionDetector.isModuleJre50Configured(configuration)) && myShowSwingInspectorCheckbox.isSelected();
|
||||
configuration.setShortenCommandLine((ShortenCommandLine)myShortenClasspathModeCombo.getComponent().getSelectedItem());
|
||||
configuration.setIncludeProvidedScope(myIncludeProvidedDeps.isSelected());
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
@@ -92,6 +95,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
getMainClassField().setText(configuration.MAIN_CLASS_NAME != null ? configuration.MAIN_CLASS_NAME.replaceAll("\\$", "\\.") : "");
|
||||
myJrePathEditor.setPathOrName(configuration.ALTERNATIVE_JRE_PATH, configuration.ALTERNATIVE_JRE_PATH_ENABLED);
|
||||
myShortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine());
|
||||
myIncludeProvidedDeps.setSelected(configuration.isProvidedScopeIncluded());
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
|
||||
+10
-1
@@ -50,6 +50,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
public boolean ALTERNATIVE_JRE_PATH_ENABLED;
|
||||
public String ALTERNATIVE_JRE_PATH;
|
||||
public boolean ENABLE_SWING_INSPECTOR;
|
||||
public boolean INCLUDE_PROVIDED_SCOPE = false;
|
||||
|
||||
private ShortenCommandLine myShortenCommandLine = null;
|
||||
|
||||
@@ -223,6 +224,14 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
ALTERNATIVE_JRE_PATH = path;
|
||||
}
|
||||
|
||||
public boolean isProvidedScopeIncluded() {
|
||||
return INCLUDE_PROVIDED_SCOPE;
|
||||
}
|
||||
|
||||
public void setIncludeProvidedScope(boolean value) {
|
||||
INCLUDE_PROVIDED_SCOPE = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> getValidModules() {
|
||||
return JavaRunConfigurationModule.getModulesForClass(getProject(), MAIN_CLASS_NAME);
|
||||
@@ -280,7 +289,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
|
||||
if (module.getModule() != null) {
|
||||
DumbService.getInstance(module.getProject()).runWithAlternativeResolveEnabled(() -> {
|
||||
int classPathType = JavaParametersUtil.getClasspathType(module, myConfiguration.MAIN_CLASS_NAME, false);
|
||||
int classPathType = JavaParametersUtil.getClasspathType(module, myConfiguration.MAIN_CLASS_NAME, false, myConfiguration.isProvidedScopeIncluded());
|
||||
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,6 +77,12 @@ public class JavaParametersUtil {
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class)
|
||||
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
|
||||
final boolean classMustHaveSource) throws CantRunException {
|
||||
return getClasspathType(configurationModule, mainClassName, classMustHaveSource, false);
|
||||
}
|
||||
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class)
|
||||
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
|
||||
final boolean classMustHaveSource, final boolean includeProvidedDependencies) throws CantRunException {
|
||||
final Module module = configurationModule.getModule();
|
||||
if (module == null) throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
|
||||
Boolean inProduction = isClassInProductionSources(mainClassName, module);
|
||||
@@ -87,7 +93,9 @@ public class JavaParametersUtil {
|
||||
throw CantRunException.classNotFound(mainClassName, module);
|
||||
}
|
||||
|
||||
return inProduction ? JavaParameters.JDK_AND_CLASSES : JavaParameters.JDK_AND_CLASSES_AND_TESTS;
|
||||
return inProduction
|
||||
? (includeProvidedDependencies ? JavaParameters.JDK_AND_CLASSES_AND_PROVIDED : JavaParameters.JDK_AND_CLASSES)
|
||||
: JavaParameters.JDK_AND_CLASSES_AND_TESTS;
|
||||
}
|
||||
|
||||
@Nullable("null if class not found")
|
||||
|
||||
+6
-1
@@ -58,9 +58,11 @@ public class JavaParameters extends SimpleJavaParameters {
|
||||
public static final int JDK_ONLY = 0x1;
|
||||
public static final int CLASSES_ONLY = 0x2;
|
||||
public static final int TESTS_ONLY = 0x4;
|
||||
public static final int INCLUDE_PROVIDED = 0x8;
|
||||
public static final int JDK_AND_CLASSES = JDK_ONLY | CLASSES_ONLY;
|
||||
public static final int JDK_AND_CLASSES_AND_TESTS = JDK_ONLY | CLASSES_ONLY | TESTS_ONLY;
|
||||
public static final int CLASSES_AND_TESTS = CLASSES_ONLY | TESTS_ONLY;
|
||||
public static final int JDK_AND_CLASSES_AND_PROVIDED = JDK_ONLY | CLASSES_ONLY | INCLUDE_PROVIDED;
|
||||
|
||||
public void configureByModule(final Module module,
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class) final int classPathType,
|
||||
@@ -77,7 +79,7 @@ public class JavaParameters extends SimpleJavaParameters {
|
||||
}
|
||||
|
||||
setDefaultCharset(module.getProject());
|
||||
configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), classPathType, jdk).collectPaths(getClassPath());
|
||||
configureEnumerator(OrderEnumerator.orderEntries(module).recursively(), classPathType, jdk).collectPaths(getClassPath());
|
||||
configureJavaLibraryPath(OrderEnumerator.orderEntries(module).recursively());
|
||||
}
|
||||
|
||||
@@ -176,6 +178,9 @@ public class JavaParameters extends SimpleJavaParameters {
|
||||
}
|
||||
|
||||
private static OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, int classPathType, Sdk jdk) {
|
||||
if ((classPathType & INCLUDE_PROVIDED) == 0) {
|
||||
enumerator = enumerator.runtimeOnly();
|
||||
}
|
||||
if ((classPathType & JDK_ONLY) == 0) {
|
||||
enumerator = enumerator.withoutSdk();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user