From 00e7649d8445387915e1baf351bc0fc71f5b10e9 Mon Sep 17 00:00:00 2001 From: gmyasoedov Date: Sat, 4 Jan 2025 16:59:44 +0300 Subject: [PATCH] chore: new features to 223 --- gmaven/build.gradle.kts | 4 +- .../rzn/gmyasoedov/gmaven/MavenManager.java | 1 - .../settings/MavenExecutionSettings.java | 9 --- .../settings/MavenExecutionWorkspace.java | 21 ------ .../gmyasoedov/gmaven/utils/MavenUtils.java | 10 +++ .../gmaven/dom/PomXmlDomGutterAnnotator.kt | 4 +- .../rzn/gmyasoedov/gmaven/dom/XmlPsiUtil.kt | 4 +- .../PomXmlCompletionTagListenerContributor.kt | 3 +- .../reference/MavenPropertyPsiReference.kt | 4 +- .../gmaven/project/DependencyDataConverter.kt | 2 +- .../project/action/EffectivePomAction.kt | 6 +- .../action/IgnoreMavenProjectAction.kt | 8 +-- .../ImportProjectFromBuildFIleAction.kt | 3 +- .../service/GMavenSystemConfigLocator.kt | 4 +- .../service/UnlinkedProjectAware.kt | 3 +- .../gmaven/server/GServerHelper2.kt | 6 +- .../gmaven/settings/MavenProjectSettings.kt | 2 - .../gmaven/settings/ProjectSettingsControl.kt | 11 --- .../gmyasoedov/gmaven/ui/MavenIconProvider.kt | 4 +- .../gmaven/util/ExecutionSettingsUtil.kt | 51 ------------- .../gmaven/wizard/MavenNewProjectWizard.kt | 71 +++++-------------- gradle.properties | 8 +-- 22 files changed, 56 insertions(+), 183 deletions(-) diff --git a/gmaven/build.gradle.kts b/gmaven/build.gradle.kts index a51192c2..523a8b55 100644 --- a/gmaven/build.gradle.kts +++ b/gmaven/build.gradle.kts @@ -17,7 +17,9 @@ repositories { dependencies { implementation(project(":server-api")) runtimeOnly(project(":maven-ext-event-handler")) - runtimeOnly("io.github.grisha9:maven-model-reader-plugin:0.4") + runtimeOnly("io.github.grisha9:maven-model-reader-plugin:0.4") { + exclude("com.google.code.gson", "gson") + } } // Configure Gradle IntelliJ Plugin diff --git a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/MavenManager.java b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/MavenManager.java index bd2b4397..46ff5bc1 100644 --- a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/MavenManager.java +++ b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/MavenManager.java @@ -219,7 +219,6 @@ public static MavenExecutionSettings getExecutionSettings( result.setOutputLevel(projectSettings.getOutputLevel()); result.setCheckSources(settings.isCheckSourcesInLocalRepo()); result.setSkipTests(settings.isSkipTests()); - result.setIncrementalSync(projectSettings.getIncrementalSync()); result.setShowPluginNodes(!Registry.is("gmaven.import.readonly") && projectSettings.getShowPluginNodes()); result.setReadonly(Registry.is("gmaven.import.readonly")); if (result.isReadonly()) { diff --git a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionSettings.java b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionSettings.java index 9cc614cc..b0491219 100644 --- a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionSettings.java +++ b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionSettings.java @@ -40,7 +40,6 @@ public class MavenExecutionSettings extends ExternalSystemExecutionSettings { private boolean showPluginNodes = true; private boolean isSkipTests = false; private boolean readonly = false; - private boolean incrementalSync = false; @NotNull private ProjectSettingsControlBuilder.OutputLevelType outputLevel = DEFAULT; @NotNull @@ -189,14 +188,6 @@ public void setReadonly(boolean readonly) { this.readonly = readonly; } - public boolean isIncrementalSync() { - return incrementalSync; - } - - public void setIncrementalSync(boolean incrementalSync) { - this.incrementalSync = incrementalSync; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionWorkspace.java b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionWorkspace.java index 23f9e611..4c2de947 100644 --- a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionWorkspace.java +++ b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/settings/MavenExecutionWorkspace.java @@ -22,10 +22,6 @@ public class MavenExecutionWorkspace implements Serializable { private String subProjectBuildFile; @Nullable private String externalProjectPath; - @Nullable - private String multiModuleProjectDirectory; - @Nullable - private String incrementalProjectName; public void addProfile(@Nullable ProfileExecution data) { if (data != null) { @@ -74,21 +70,4 @@ public String getExternalProjectPath() { public void setExternalProjectPath(String externalProjectPath) { this.externalProjectPath = externalProjectPath; } - - @Nullable - public String getMultiModuleProjectDirectory() { - return multiModuleProjectDirectory; - } - - public void setMultiModuleProjectDirectory(@Nullable String multiModuleProjectDirectory) { - this.multiModuleProjectDirectory = multiModuleProjectDirectory; - } - - public @Nullable String getIncrementalProjectName() { - return incrementalProjectName; - } - - public void setIncrementalProjectName(@Nullable String incrementalProjectName) { - this.incrementalProjectName = incrementalProjectName; - } } diff --git a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/utils/MavenUtils.java b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/utils/MavenUtils.java index a7e9426d..4e4ee6ad 100644 --- a/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/utils/MavenUtils.java +++ b/gmaven/src/main/java/ru/rzn/gmyasoedov/gmaven/utils/MavenUtils.java @@ -71,6 +71,16 @@ public class MavenUtils { private MavenUtils() { } + @Nullable + public static Path toNioPathOrNull(@Nullable VirtualFile file) { + if (file == null) return null; + try { + return file.toNioPath(); + } catch (Exception e) { + return null; + } + } + @NotNull public static VirtualFile getVFile(File file) { VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file); diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/PomXmlDomGutterAnnotator.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/PomXmlDomGutterAnnotator.kt index da78475c..776f6d5c 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/PomXmlDomGutterAnnotator.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/PomXmlDomGutterAnnotator.kt @@ -12,7 +12,6 @@ import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.project.Project import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil -import com.intellij.openapi.vfs.toNioPathOrNull import com.intellij.psi.PsiElement import com.intellij.psi.xml.XmlFile import com.intellij.psi.xml.XmlTag @@ -50,7 +49,8 @@ class PomXmlDomGutterAnnotator : Annotator { addGutterIcon(parentPath, xmlTag, holder, GMavenIcons.ParentProject, "GMaven:parent") } else if (tagName == MODULE) { val moduleName = xmlTag.value.text - val modulePath = xmlTag.containingFile.parent?.virtualFile?.toNioPathOrNull()?.resolve(moduleName) ?: return + val virtualFile = xmlTag.containingFile.parent?.virtualFile ?: return + val modulePath = MavenUtils.toNioPathOrNull(virtualFile)?.resolve(moduleName) ?: return addGutterIcon(modulePath, xmlTag, holder, AllIcons.Gutter.OverridenMethod, "GMaven:module") } else if (tagName == DEPENDENCY && xmlTag.parentTag?.parentTag?.name != DEPENDENCY_MANAGEMENT) { val management = getDependencyManagement(xmlFile, settingsHolder) diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/XmlPsiUtil.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/XmlPsiUtil.kt index e0eab015..089ba012 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/XmlPsiUtil.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/XmlPsiUtil.kt @@ -4,7 +4,6 @@ import com.intellij.lang.xml.XMLLanguage import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectRootManager import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.openapi.vfs.readText import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileFactory @@ -61,8 +60,9 @@ object XmlPsiUtil { val psiFile = PsiManager.getInstance(project).findFile(virtualFile) ?: return null return if (psiFile is XmlFile) psiFile else { try { + val content = String(virtualFile.contentsToByteArray()) PsiFileFactory.getInstance(project) - .createFileFromText(filePath.name, XMLLanguage.INSTANCE, virtualFile.readText()) as? XmlFile + .createFileFromText(filePath.name, XMLLanguage.INSTANCE, content) as? XmlFile } catch (e: Exception) { null } diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/completion/PomXmlCompletionTagListenerContributor.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/completion/PomXmlCompletionTagListenerContributor.kt index aac32d91..180cd933 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/completion/PomXmlCompletionTagListenerContributor.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/completion/PomXmlCompletionTagListenerContributor.kt @@ -9,7 +9,6 @@ import com.intellij.codeInsight.completion.CompletionType.BASIC import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementDecorator import com.intellij.codeInsight.template.TemplateManager -import com.intellij.openapi.vfs.toNioPathOrNull import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.xml.XmlFile import com.intellij.psi.xml.XmlTag @@ -28,7 +27,7 @@ class PomXmlCompletionTagListenerContributor : CompletionContributor() { return // Don't brake the template. } val psiFile = parameters.originalFile as? XmlFile ?: return - val filePath = psiFile.virtualFile.toNioPathOrNull()?.toString() ?: return + val filePath = MavenUtils.toNioPathOrNull(psiFile.virtualFile)?.toString() ?: return if (!CachedModuleDataService.getDataHolder(psiFile.project).isConfigPath(filePath)) return result.runRemainingContributors(parameters) { r -> diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/reference/MavenPropertyPsiReference.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/reference/MavenPropertyPsiReference.kt index 910f2740..10703465 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/reference/MavenPropertyPsiReference.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/dom/reference/MavenPropertyPsiReference.kt @@ -3,7 +3,6 @@ package ru.rzn.gmyasoedov.gmaven.dom.reference import com.intellij.codeInsight.lookup.LookupElementBuilder import com.intellij.openapi.util.TextRange import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.openapi.vfs.toNioPathOrNull import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiElement import com.intellij.psi.PsiManager @@ -14,6 +13,7 @@ import com.intellij.psi.xml.XmlTag import ru.rzn.gmyasoedov.gmaven.dom.XmlPsiUtil import ru.rzn.gmyasoedov.gmaven.settings.MavenSettings import ru.rzn.gmyasoedov.gmaven.utils.MavenArtifactUtil +import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils import java.nio.file.Path import java.util.* @@ -85,7 +85,7 @@ class MavenPropertyPsiReference( } if (propertyName == MULTIPROJECT_DIR_PROP) { - val dirPath = xmlFile.parent?.virtualFile?.toNioPathOrNull()?.toString() ?: return null + val dirPath = MavenUtils.toNioPathOrNull(xmlFile.parent?.virtualFile)?.toString() ?: return null val setting = MavenSettings.getInstance(element.project) .getLinkedProjectSettings(dirPath) ?: return null val virtualFile = LocalFileSystem.getInstance().findFileByPath(setting.externalProjectPath) ?: return null diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/DependencyDataConverter.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/DependencyDataConverter.kt index 51583324..2af55395 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/DependencyDataConverter.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/DependencyDataConverter.kt @@ -151,7 +151,7 @@ private fun linkProjectLibrary( val libraryData = cache.computeIfAbsent(libraryName) { var newValueToCache = ExternalSystemApiUtil - .findChild(ideProject, ProjectKeys.LIBRARY) { it.data.externalName == libraryName } + .find(ideProject, ProjectKeys.LIBRARY) { it.data.externalName == libraryName } if (newValueToCache == null) { newValueToCache = ideProject.createChild(ProjectKeys.LIBRARY, library) } diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/EffectivePomAction.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/EffectivePomAction.kt index f1cb3500..3e3210db 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/EffectivePomAction.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/EffectivePomAction.kt @@ -11,7 +11,6 @@ import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExe import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode import com.intellij.openapi.externalSystem.task.TaskCallback import com.intellij.openapi.externalSystem.util.ExternalSystemUtil -import com.intellij.openapi.vfs.toNioPathOrNull import com.intellij.psi.PsiFileFactory import com.intellij.util.execution.ParametersListUtil import ru.rzn.gmyasoedov.gmaven.GMavenConstants @@ -22,6 +21,7 @@ import ru.rzn.gmyasoedov.gmaven.util.CachedModuleDataService import ru.rzn.gmyasoedov.gmaven.util.GMavenNotification import ru.rzn.gmyasoedov.gmaven.util.MavenPathUtil import ru.rzn.gmyasoedov.gmaven.utils.MavenLog +import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils import java.io.IOException import java.nio.file.Files import kotlin.io.path.absolutePathString @@ -42,13 +42,13 @@ class EffectivePomAction : ExternalSystemAction() { override fun isVisible(e: AnActionEvent): Boolean { val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return false val project = e.getData(CommonDataKeys.PROJECT) ?: return false - val filePath = virtualFile.toNioPathOrNull()?.toString() ?: return false + val filePath = MavenUtils.toNioPathOrNull(virtualFile)?.toString() ?: return false return CachedModuleDataService.getDataHolder(project).isConfigPath(filePath) } override fun actionPerformed(e: AnActionEvent) { val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return - val configNioPath = virtualFile.toNioPathOrNull() ?: return + val configNioPath = MavenUtils.toNioPathOrNull(virtualFile) ?: return val project = e.getData(CommonDataKeys.PROJECT) ?: return val projectSettings = MavenSettings.getInstance(project) .getLinkedProjectSettings(configNioPath.parent.toString()) ?: return diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/IgnoreMavenProjectAction.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/IgnoreMavenProjectAction.kt index 3115e1f7..dd0dda46 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/IgnoreMavenProjectAction.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/IgnoreMavenProjectAction.kt @@ -16,13 +16,13 @@ import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.Task import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.toNioPathOrNull import ru.rzn.gmyasoedov.gmaven.GMavenConstants import ru.rzn.gmyasoedov.gmaven.GMavenConstants.SYSTEM_ID import ru.rzn.gmyasoedov.gmaven.bundle.GBundle import ru.rzn.gmyasoedov.gmaven.settings.MavenSettings import ru.rzn.gmyasoedov.gmaven.util.CachedModuleDataService import ru.rzn.gmyasoedov.gmaven.utils.MavenLog +import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils import java.nio.file.Path import kotlin.io.path.isDirectory @@ -40,7 +40,7 @@ class IgnoreMavenProjectAction : ExternalSystemToggleAction() { override fun isVisible(e: AnActionEvent): Boolean { val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return false val project = e.getData(CommonDataKeys.PROJECT) ?: return false - val nioPath = virtualFile.toNioPathOrNull()?.toString() ?: return false + val nioPath = MavenUtils.toNioPathOrNull(virtualFile)?.toString() ?: return false return if (virtualFile.isDirectory) MavenSettings.getInstance(project).getLinkedProjectSettings(nioPath) != null @@ -49,7 +49,7 @@ class IgnoreMavenProjectAction : ExternalSystemToggleAction() { } override fun setSelected(e: AnActionEvent, state: Boolean) { - val nioPath = e.getData(CommonDataKeys.VIRTUAL_FILE)?.toNioPathOrNull() ?: return + val nioPath = MavenUtils.toNioPathOrNull(e.getData(CommonDataKeys.VIRTUAL_FILE)) ?: return val project = e.getData(CommonDataKeys.PROJECT) ?: return val projectDataNode = getProjectDataNode(project, nioPath) ?: return val allModuleNodes = ExternalSystemApiUtil.findAll(projectDataNode, ProjectKeys.MODULE) @@ -78,7 +78,7 @@ class IgnoreMavenProjectAction : ExternalSystemToggleAction() { override fun doIsSelected(e: AnActionEvent): Boolean { try { - val nioPath = e.getData(CommonDataKeys.VIRTUAL_FILE)?.toNioPathOrNull() ?: return false + val nioPath = MavenUtils.toNioPathOrNull(e.getData(CommonDataKeys.VIRTUAL_FILE)) ?: return false val project = e.getData(CommonDataKeys.PROJECT) ?: return false val projectDataNode = getProjectDataNode(project, nioPath) ?: return false val allModuleNodes = ExternalSystemApiUtil.findAll(projectDataNode, ProjectKeys.MODULE) diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/ImportProjectFromBuildFIleAction.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/ImportProjectFromBuildFIleAction.kt index 1abdbf04..f2136deb 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/ImportProjectFromBuildFIleAction.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/action/ImportProjectFromBuildFIleAction.kt @@ -3,7 +3,6 @@ package ru.rzn.gmyasoedov.gmaven.project.action import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.externalSystem.action.ExternalSystemAction -import com.intellij.openapi.vfs.toNioPathOrNull import ru.rzn.gmyasoedov.gmaven.bundle.GBundle import ru.rzn.gmyasoedov.gmaven.util.CachedModuleDataService import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils @@ -21,7 +20,7 @@ class ImportProjectFromBuildFIleAction : ExternalSystemAction() { override fun isVisible(e: AnActionEvent): Boolean { val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return false val project = e.getData(CommonDataKeys.PROJECT) ?: return false - val filePath = virtualFile.toNioPathOrNull()?.toString() ?: return false + val filePath = MavenUtils.toNioPathOrNull(virtualFile)?.toString() ?: return false if (CachedModuleDataService.getDataHolder(project).isConfigPath(filePath)) return false return MavenUtils.isSimplePomFile(virtualFile.name) || MavenUtils.isPotentialPomFile(virtualFile.name) } diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/GMavenSystemConfigLocator.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/GMavenSystemConfigLocator.kt index 60ad5f43..e9f1b4e4 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/GMavenSystemConfigLocator.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/GMavenSystemConfigLocator.kt @@ -3,9 +3,9 @@ package ru.rzn.gmyasoedov.gmaven.project.externalSystem.service import com.intellij.openapi.externalSystem.service.settings.ExternalSystemConfigLocator import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.vfs.toNioPathOrNull import ru.rzn.gmyasoedov.gmaven.GMavenConstants import ru.rzn.gmyasoedov.gmaven.util.CachedModuleDataService +import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils class GMavenSystemConfigLocator : ExternalSystemConfigLocator { override fun getTargetExternalSystemId() = GMavenConstants.SYSTEM_ID @@ -16,7 +16,7 @@ class GMavenSystemConfigLocator : ExternalSystemConfigLocator { val cachedDataHolder = CachedModuleDataService.getCurrentData() for (child in configPath.children) { if (child.isDirectory) continue - val nioPath = child.toNioPathOrNull()?.toString() ?: continue + val nioPath = MavenUtils.toNioPathOrNull(child)?.toString() ?: continue if (cachedDataHolder.isConfigPath(nioPath)) return child } return null diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/UnlinkedProjectAware.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/UnlinkedProjectAware.kt index ab893ce3..f812f92f 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/UnlinkedProjectAware.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/project/externalSystem/service/UnlinkedProjectAware.kt @@ -7,7 +7,6 @@ import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListen import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.vfs.isFile import com.intellij.projectImport.ProjectOpenProcessor import ru.rzn.gmyasoedov.gmaven.GMavenConstants.SYSTEM_ID import ru.rzn.gmyasoedov.gmaven.settings.MavenProjectSettings @@ -21,7 +20,7 @@ class UnlinkedProjectAware : ExternalSystemUnlinkedProjectAware { override val systemId = SYSTEM_ID override fun isBuildFile(project: Project, buildFile: VirtualFile): Boolean { - return buildFile.isFile && MavenUtils.isSimplePomFile(buildFile) + return !buildFile.isDirectory && MavenUtils.isSimplePomFile(buildFile) } override fun isLinkedProject(project: Project, externalProjectPath: String): Boolean { diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/server/GServerHelper2.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/server/GServerHelper2.kt index a2543053..533957c7 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/server/GServerHelper2.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/server/GServerHelper2.kt @@ -161,10 +161,6 @@ private fun setupImportParamsFromSettings(request: GServerRequest, commandLine: request.settings.argumentsImport?.forEach { commandLine.addParameter(it) } val importTaskName = "$PLUGIN_BASE_NAME:" + (if (request.readOnly) "read" else "resolve") commandLine.addParameter(importTaskName) - if (request.settings.executionWorkspace.incrementalProjectName != null) { - commandLine.parametersList.addProperty("incremental", "true") - commandLine.addParameters("-pl", request.settings.executionWorkspace.incrementalProjectName, "-am", "-amd") - } } private fun runMavenImport( @@ -201,7 +197,7 @@ private fun runMavenImportInner( } finally { if (processSupport.exitCode != 0) { FileUtil.delete(resultFilePath) - } else if (!request.settings.isIncrementalSync && Registry.`is`("gmaven.process.remove.result.file")) { + } else if (Registry.`is`("gmaven.process.remove.result.file")) { if (!resultFilePath.parent.name.equals("target", true)) FileUtil.delete(resultFilePath) } } diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/MavenProjectSettings.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/MavenProjectSettings.kt index d0858927..8b64c037 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/MavenProjectSettings.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/MavenProjectSettings.kt @@ -13,7 +13,6 @@ class MavenProjectSettings : ExternalProjectSettings() { var resolveModulePerSourceSet = true var nonRecursive = false var showPluginNodes = true - var incrementalSync = false var snapshotUpdateType = SnapshotUpdateType.DEFAULT var outputLevel = OutputLevelType.DEFAULT var threadCount: String? = null @@ -37,7 +36,6 @@ class MavenProjectSettings : ExternalProjectSettings() { result.arguments = arguments result.argumentsImport = argumentsImport result.localRepositoryPath = localRepositoryPath - result.incrementalSync = incrementalSync return result } } \ No newline at end of file diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/ProjectSettingsControl.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/ProjectSettingsControl.kt index e91b307c..628c1feb 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/ProjectSettingsControl.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/settings/ProjectSettingsControl.kt @@ -51,7 +51,6 @@ class ProjectSettingsControl(private val project: Project, private val currentSe private val nonRecursiveBind = propertyGraph.property(false) private val resolveModulePerSourceSetBind = propertyGraph.property(false) private val showPluginNodesBind = propertyGraph.property(false) - private val incrementalSyncBind = propertyGraph.property(false) private val updateSnapshotsModel = CollectionComboBoxModel(SnapshotUpdateType.values().toList()) private val outputLevelModel = CollectionComboBoxModel(OutputLevelType.values().toList()) @@ -104,13 +103,6 @@ class ProjectSettingsControl(private val project: Project, private val currentSe .resizableColumn() } - row { - checkBox(message("gmaven.settings.project.incremental")) - .align(AlignX.FILL) - .bindSelected(incrementalSyncBind) - .resizableColumn() - } - row(message("gmaven.settings.project.snapshot.update")) { comboBox(updateSnapshotsModel) .align(AlignX.FILL) @@ -256,7 +248,6 @@ class ProjectSettingsControl(private val project: Project, private val currentSe nonRecursiveBind.set(currentSettings.nonRecursive) resolveModulePerSourceSetBind.set(currentSettings.resolveModulePerSourceSet) showPluginNodesBind.set(currentSettings.showPluginNodes) - incrementalSyncBind.set(currentSettings.incrementalSync) updateSnapshotsModel.selectedItem = currentSettings.snapshotUpdateType outputLevelModel.selectedItem = currentSettings.outputLevel @@ -284,7 +275,6 @@ class ProjectSettingsControl(private val project: Project, private val currentSe if (currentSettings.nonRecursive != nonRecursiveBind.get()) return true if (currentSettings.resolveModulePerSourceSet != resolveModulePerSourceSetBind.get()) return true if (currentSettings.showPluginNodes != showPluginNodesBind.get()) return true - if (currentSettings.incrementalSync != incrementalSyncBind.get()) return true if (currentSettings.snapshotUpdateType != updateSnapshotsModel.selected) return true if (currentSettings.outputLevel != outputLevelModel.selected) return true @@ -311,7 +301,6 @@ class ProjectSettingsControl(private val project: Project, private val currentSe settings.nonRecursive = nonRecursiveBind.get() settings.resolveModulePerSourceSet = resolveModulePerSourceSetBind.get() settings.showPluginNodes = showPluginNodesBind.get() - settings.incrementalSync = incrementalSyncBind.get() settings.snapshotUpdateType = updateSnapshotsModel.selected!! settings.outputLevel = outputLevelModel.selected!! diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/ui/MavenIconProvider.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/ui/MavenIconProvider.kt index 852ce361..4a3fcb0c 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/ui/MavenIconProvider.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/ui/MavenIconProvider.kt @@ -4,16 +4,16 @@ import com.intellij.ide.FileIconProvider import com.intellij.openapi.project.DumbAware import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.vfs.toNioPathOrNull import icons.GMavenIcons import ru.rzn.gmyasoedov.gmaven.util.CachedModuleDataService +import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils import javax.swing.Icon class MavenIconProvider : DumbAware, FileIconProvider { override fun getIcon(file: VirtualFile, flags: Int, project: Project?): Icon? { project ?: return null - val path = file.toNioPathOrNull()?.toString() ?: return null + val path = MavenUtils.toNioPathOrNull(file)?.toString() ?: return null val dataHolder = CachedModuleDataService.getDataHolder(project) if (dataHolder.activeConfigPaths.contains(path)) return GMavenIcons.MavenProject if (dataHolder.ignoredConfigPaths.contains(path)) return GMavenIcons.MavenIgnored diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/util/ExecutionSettingsUtil.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/util/ExecutionSettingsUtil.kt index 5631505f..2e37e3b2 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/util/ExecutionSettingsUtil.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/util/ExecutionSettingsUtil.kt @@ -9,10 +9,7 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData import com.intellij.openapi.externalSystem.model.project.ProjectData import com.intellij.openapi.externalSystem.service.project.ProjectDataManager import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil -import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.Project -import com.intellij.openapi.util.registry.Registry -import com.intellij.openapi.vfs.toNioPathOrNull import ru.rzn.gmyasoedov.gmaven.GMavenConstants import ru.rzn.gmyasoedov.gmaven.GMavenConstants.MODULE_PROP_BUILD_FILE import ru.rzn.gmyasoedov.gmaven.project.externalSystem.model.ProfileData @@ -20,12 +17,9 @@ import ru.rzn.gmyasoedov.gmaven.project.profile.ProjectProfilesStateService import ru.rzn.gmyasoedov.gmaven.settings.MavenExecutionWorkspace import ru.rzn.gmyasoedov.gmaven.settings.MavenProjectSettings import ru.rzn.gmyasoedov.gmaven.settings.ProjectExecution -import ru.rzn.gmyasoedov.gmaven.utils.MavenLog import ru.rzn.gmyasoedov.gmaven.utils.MavenUtils import java.nio.file.Path import java.util.* -import kotlin.io.path.absolutePathString -import kotlin.io.path.exists fun getLocalRepoPath(project: Project, externalProjectPath: String): String? { val projectDataNode = ProjectDataManager.getInstance() @@ -67,34 +61,9 @@ fun fillExecutionWorkSpace( } addedIgnoredModule(workspace, allModules, targetModuleNode) addedProfiles(projectDataNode, ProjectProfilesStateService.getInstance(project), workspace) - setIncrementalPath(project, workspace, projectSettings, allModules) setMultiModuleProjectDirectory(projectSettings.externalProjectPath, workspace) } -private fun setIncrementalPath( - project: Project, - workspace: MavenExecutionWorkspace, - projectSettings: MavenProjectSettings, - allModules: Collection> -) { - workspace.projectBuildFile ?: return - if (!projectSettings.incrementalSync) return - if (Registry.`is`("gmaven.import.readonly")) return - if (ActionManagerEx.getInstanceEx().lastPreformedActionId != "ExternalSystem.ProjectRefreshAction") return - - val incrementBuildFile = try { - FileEditorManager.getInstance(project)?.selectedTextEditor?.virtualFile?.toNioPathOrNull() - } catch (e: Exception) { - MavenLog.LOG.error(e.message, e) - null - } ?: return - val incrementBuildPath = incrementBuildFile.absolutePathString() - if (MavenUtils.equalsPaths(workspace.projectBuildFile, incrementBuildPath)) return - workspace.incrementalProjectName = allModules - .find { MavenUtils.equalsPaths(it.data.getProperty(MODULE_PROP_BUILD_FILE), incrementBuildPath) } - ?.data?.let { MavenUtils.toGAString(it) } -} - private fun getTargetModuleAndContextMap( projectPath: String, allModules: Collection> ): Pair?, TreeMap>> { @@ -186,24 +155,4 @@ private fun setMultiModuleProjectDirectory( val projectPath = Path.of(projectPathString) val projectDirPath = if (projectPath.toFile().isDirectory()) projectPath else projectPath.parent if (MavenUtils.equalsPaths(projectDirPath.toString(), externalProjectPath)) return - val mainProjectPath = Path.of(externalProjectPath) - workspace.multiModuleProjectDirectory = getMultiModuleProjectDirectory(projectDirPath, mainProjectPath).toString() -} - -private fun getMultiModuleProjectDirectory(projectPath: Path, mainProjectPath: Path): Path { - val workingDirectory = if (projectPath.toFile().isDirectory()) projectPath else projectPath.parent - var projectPathTmp = workingDirectory - try { - while (projectPathTmp != mainProjectPath) { - if (projectPathTmp.resolve(".mvn").exists()) { - return projectPathTmp - } - projectPathTmp = projectPathTmp.parent - } - if (projectPathTmp.resolve(".mvn").exists()) { - return projectPathTmp - } - } catch (ignored: Exception) { - } - return workingDirectory } \ No newline at end of file diff --git a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/wizard/MavenNewProjectWizard.kt b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/wizard/MavenNewProjectWizard.kt index 115f4971..e2ea5e5f 100644 --- a/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/wizard/MavenNewProjectWizard.kt +++ b/gmaven/src/main/kotlin/ru/rzn/gmyasoedov/gmaven/wizard/MavenNewProjectWizard.kt @@ -1,12 +1,13 @@ package ru.rzn.gmyasoedov.gmaven.wizard -import com.intellij.ide.projectWizard.generators.AssetsJavaNewProjectWizardStep +import com.intellij.ide.projectWizard.generators.AssetsNewProjectWizardStep import com.intellij.ide.projectWizard.generators.BuildSystemJavaNewProjectWizard import com.intellij.ide.projectWizard.generators.BuildSystemJavaNewProjectWizardData import com.intellij.ide.projectWizard.generators.JavaNewProjectWizard import com.intellij.ide.starters.local.StandardAssetsProvider -import com.intellij.ide.wizard.NewProjectWizardChainStep.Companion.nextStep -import com.intellij.ide.wizard.NewProjectWizardStep +import com.intellij.ide.wizard.NewProjectWizardBaseData.Companion.name +import com.intellij.ide.wizard.NewProjectWizardBaseData.Companion.path +import com.intellij.ide.wizard.chain import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder @@ -20,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.projectImport.ProjectOpenProcessor import com.intellij.ui.UIBundle import com.intellij.ui.dsl.builder.Panel +import com.intellij.ui.dsl.builder.TopGap import com.intellij.ui.dsl.builder.bindSelected import ru.rzn.gmyasoedov.gmaven.GMavenConstants import ru.rzn.gmyasoedov.gmaven.GMavenConstants.GMAVEN @@ -31,55 +33,27 @@ class MavenNewProjectWizard : BuildSystemJavaNewProjectWizard { override val name = GMAVEN - override val ordinal = 110 - - override fun createStep(parent: JavaNewProjectWizard.Step): NewProjectWizardStep = - Step(parent).nextStep(::AssetsStep) + override fun createStep(parent: JavaNewProjectWizard.Step) = Step(parent).chain(::AssetsStep) class Step(parent: JavaNewProjectWizard.Step) : GMavenNewProjectWizardStep(parent), - BuildSystemJavaNewProjectWizardData by parent, - JavaNewProjectWizardData { + BuildSystemJavaNewProjectWizardData by parent { - override val addSampleCodeProperty = propertyGraph.property(true) - .bindBooleanStorage(NewProjectWizardStep.ADD_SAMPLE_CODE_PROPERTY_NAME) - override val generateOnboardingTipsProperty = propertyGraph - .property(AssetsJavaNewProjectWizardStep.proposeToGenerateOnboardingTipsByDefault()) - .bindBooleanStorage(NewProjectWizardStep.GENERATE_ONBOARDING_TIPS_NAME) + private val addSampleCodeProperty = propertyGraph.property(true) + .bindBooleanStorage("NewProjectWizard.addSampleCodeState") - override var addSampleCode by addSampleCodeProperty - override var generateOnboardingTips by generateOnboardingTipsProperty + var addSampleCode by addSampleCodeProperty - private fun setupSampleCodeUI(builder: Panel) { + override fun setupSettingsUI(builder: Panel) { + super.setupSettingsUI(builder) builder.row { checkBox(UIBundle.message("label.project.wizard.new.project.add.sample.code")) .bindSelected(addSampleCodeProperty) - } - } - - private fun setupSampleCodeWithOnBoardingTipsUI(builder: Panel) { - builder.indent { - row { - checkBox(UIBundle.message("label.project.wizard.new.project.generate.onboarding.tips")) - .bindSelected(generateOnboardingTipsProperty) - } - }.enabledIf(addSampleCodeProperty) - } - - override fun setupSettingsUI(builder: Panel) { - parentData?.let { this.groupId = it.groupId } - setupJavaSdkUI(builder) - setupParentsUI(builder) - setupSampleCodeUI(builder) - setupSampleCodeWithOnBoardingTipsUI(builder) - } - - override fun setupAdvancedSettingsUI(builder: Panel) { - setupGroupIdUI(builder) - setupArtifactIdUI(builder) + }.topGap(TopGap.SMALL) } override fun setupProject(project: Project) { + super.setupProject(project) project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, true) project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, true) ExternalProjectsManagerImpl.setupCreatedProject(project) @@ -117,27 +91,16 @@ class MavenNewProjectWizard : BuildSystemJavaNewProjectWizard { } } } - - init { - data.putUserData(JavaNewProjectWizardData.KEY, this) - } } - private class AssetsStep(private val parent: Step) : AssetsJavaNewProjectWizardStep(parent) { - + private class AssetsStep(private val parent: Step) : AssetsNewProjectWizardStep(parent) { override fun setupAssets(project: Project) { + outputDirectory = Path.of(path, name).toString() if (context.isCreatingNewProject) { addAssets(StandardAssetsProvider().getMavenIgnoreAssets()) } if (parent.addSampleCode) { - withJavaSampleCodeAsset("src/main/java", parent.groupId, parent.generateOnboardingTips) - } - } - - override fun setupProject(project: Project) { - super.setupProject(project) - if (parent.generateOnboardingTips) { - prepareTipsInEditor(project) + withJavaSampleCodeAsset(Path.of("src", "main", "java").toString(), parent.groupId) } } } diff --git a/gradle.properties b/gradle.properties index 0069bf0e..e899f2a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ # IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html -pluginVersion=231.31 -pluginSinceBuild=231.8109.175 -pluginUntilBuild=231.* +pluginVersion=223.31 +pluginSinceBuild=223 +pluginUntilBuild=223.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType=IC -platformVersion=2023.1 +platformVersion=2022.3 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency=false