From 811375a09a09586a50dc7b2bb10505564a143ab1 Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 9 Nov 2024 17:04:24 +0400 Subject: [PATCH] #1835 Extracted java-dependent code to a separate module with optional java dependency --- build.gradle.kts | 1 + .../julia/lang/module/julia-modules.kt | 38 +++++-------------- java/build.gradle.kts | 18 +++++++++ .../configuration/JuliaCompileOutputEditor.kt | 33 ++++++++++++++++ .../JuliaModuleConfigEditorProvider.kt | 34 +++++++++++++++++ .../main/resources/org.ice1000.julia.java.xml | 9 +++++ settings.gradle.kts | 2 + src/main/resources/META-INF/plugin.xml | 8 +++- 8 files changed, 113 insertions(+), 30 deletions(-) create mode 100644 java/build.gradle.kts create mode 100644 java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaCompileOutputEditor.kt create mode 100644 java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaModuleConfigEditorProvider.kt create mode 100644 java/src/main/resources/org.ice1000.julia.java.xml diff --git a/build.gradle.kts b/build.gradle.kts index 49a6766b..0c137c38 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -243,6 +243,7 @@ intellijPlatform { dependencies { listOf( ":core", + ":java", ).forEach { compileOnly(project(it)) testCompileOnly(project(it)) diff --git a/core/src/main/java/org/ice1000/julia/lang/module/julia-modules.kt b/core/src/main/java/org/ice1000/julia/lang/module/julia-modules.kt index 8260e87d..36daa359 100644 --- a/core/src/main/java/org/ice1000/julia/lang/module/julia-modules.kt +++ b/core/src/main/java/org/ice1000/julia/lang/module/julia-modules.kt @@ -18,18 +18,24 @@ package org.ice1000.julia.lang.module -import com.intellij.ide.util.projectWizard.* +import com.intellij.ide.util.projectWizard.ModuleBuilder +import com.intellij.ide.util.projectWizard.ModuleBuilderListener +import com.intellij.ide.util.projectWizard.ModuleWizardStep +import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.module.* +import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleType +import com.intellij.openapi.module.ModuleTypeManager import com.intellij.openapi.project.guessProjectDir import com.intellij.openapi.project.rootManager import com.intellij.openapi.projectRoots.SdkTypeId import com.intellij.openapi.roots.ModifiableModelsProvider import com.intellij.openapi.roots.ModifiableRootModel -import com.intellij.openapi.roots.ui.configuration.* import icons.JuliaIcons -import org.ice1000.julia.lang.* +import org.ice1000.julia.lang.JULIA_DEFAULT_MODULE_NAME +import org.ice1000.julia.lang.JULIA_MODULE_ID +import org.ice1000.julia.lang.JuliaBundle import org.ice1000.julia.lang.action.errorNotification import org.ice1000.julia.lang.module.ui.JuliaSetupSdkWizardStepImpl @@ -90,27 +96,3 @@ class JuliaModuleType : ModuleType(JULIA_MODULE_ID) { } } -/** - * Module Configure - * Inspired by Haskell plugin - * @author: zxj5470 - * @date: 2018/1/29 - */ -class JuliaModuleConfigEditor : ModuleConfigurationEditorProvider { - override fun createEditors(state: ModuleConfigurationState): Array { - val module = state.rootModel?.module ?: return emptyArray() - return arrayOf(ContentEntriesEditor(module.name, state), - JuliaCompileOutputEditor(state)) - } -} - -class JuliaCompileOutputEditor(state: ModuleConfigurationState) : ModuleElementsEditor(state) { - var editor: BuildElementsEditor = object : BuildElementsEditor(state) { - } - - override fun createComponentImpl() = editor.createComponentImpl() - override fun saveData() = editor.saveData() - override fun getDisplayName() = "Paths" - override fun getHelpTopic() = editor.helpTopic -} - diff --git a/java/build.gradle.kts b/java/build.gradle.kts new file mode 100644 index 00000000..e7214667 --- /dev/null +++ b/java/build.gradle.kts @@ -0,0 +1,18 @@ +fun properties(key: String) = providers.gradleProperty(key) +fun environment(key: String) = providers.environmentVariable(key) + +dependencies { + listOf( + ":core", + ).forEach { + compileOnly(project(it)) + testCompileOnly(project(it)) + runtimeOnly(project(it)) + } + intellijPlatform { + val platformVersionProvider: Provider by rootProject.extra + create("IC", platformVersionProvider.get(), useInstaller = properties("useInstaller").get().toBoolean()) + bundledPlugins("com.intellij.java") + } +} + diff --git a/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaCompileOutputEditor.kt b/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaCompileOutputEditor.kt new file mode 100644 index 00000000..ea5a247b --- /dev/null +++ b/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaCompileOutputEditor.kt @@ -0,0 +1,33 @@ +/* + * Julia language support plugin for Intellij-based IDEs. + * Copyright (C) 2024 julia-intellij contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.ice1000.julia.java.ui.configuration + +import com.intellij.openapi.roots.ui.configuration.BuildElementsEditor +import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState +import com.intellij.openapi.roots.ui.configuration.ModuleElementsEditor + +class JuliaCompileOutputEditor(state: ModuleConfigurationState) : ModuleElementsEditor(state) { + var editor: BuildElementsEditor = object : BuildElementsEditor(state) { + } + + override fun createComponentImpl() = editor.createComponentImpl() + override fun saveData() = editor.saveData() + override fun getDisplayName() = "Paths" + override fun getHelpTopic() = editor.helpTopic +} diff --git a/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaModuleConfigEditorProvider.kt b/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaModuleConfigEditorProvider.kt new file mode 100644 index 00000000..76733477 --- /dev/null +++ b/java/src/main/java/org/ice1000/julia/java/ui/configuration/JuliaModuleConfigEditorProvider.kt @@ -0,0 +1,34 @@ +/* + * Julia language support plugin for Intellij-based IDEs. + * Copyright (C) 2024 julia-intellij contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.ice1000.julia.java.ui.configuration + +import com.intellij.openapi.module.ModuleConfigurationEditor +import com.intellij.openapi.roots.ui.configuration.ContentEntriesEditor +import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationEditorProvider +import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState + +class JuliaModuleConfigEditorProvider : ModuleConfigurationEditorProvider { + override fun createEditors(state: ModuleConfigurationState): Array { + val module = state.currentRootModel?.module ?: return emptyArray() + return arrayOf( + ContentEntriesEditor(module.name, state), + JuliaCompileOutputEditor(state) + ) + } +} diff --git a/java/src/main/resources/org.ice1000.julia.java.xml b/java/src/main/resources/org.ice1000.julia.java.xml new file mode 100644 index 00000000..94fb81bf --- /dev/null +++ b/java/src/main/resources/org.ice1000.julia.java.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index a17ae415..3ed70953 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,3 +7,5 @@ pluginManagement { rootProject.name = "julia-intellij" include("core") project(":core").projectDir = file("core") +include("java") +project(":java").projectDir = file("java") diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index bc8c2814..1b5912c8 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,5 +1,5 @@ - - "org.ice1000.julia + + org.ice1000.julia Julia Alexandr Evstigneev Custom Languages @@ -10,6 +10,10 @@ com.intellij.modules.go com.intellij.modules.idea + + + +