Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: plugin file as system property #145

Merged
merged 12 commits into from
Nov 5, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,9 @@ class CopilotPluginUtil {
LOG.info("Project directory: $projectDir")
return projectDir.findOrCreateDirectory(IDEA_DIR)
}

fun getDotFile(project: Project): VirtualFile? {
return getDotFileDirectory(project)?.findFile(DOTFILE)
}
}
}
24 changes: 24 additions & 0 deletions src/main/kotlin/com/vaadin/plugin/copilot/DefaultProgramPatcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.vaadin.plugin.copilot

import com.intellij.execution.Executor
import com.intellij.execution.configurations.JavaParameters
import com.intellij.execution.configurations.RunConfiguration
import com.intellij.execution.configurations.RunProfile
import com.intellij.execution.runners.JavaProgramPatcher

class DefaultProgramPatcher : JavaProgramPatcher() {

override fun patchJavaParameters(executor: Executor?, runProfile: RunProfile?, javaParameters: JavaParameters?) {

if (javaParameters == null) {
return
}
val paramsList = javaParameters.vmParametersList

if (runProfile is RunConfiguration) {
CopilotPluginUtil.getDotFile(runProfile.project)?.let {
paramsList.add("-Dvaadin.copilot.pluginDotFilePath=${it.path}")
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<actionOnSave id="VaadinCompileOnSaveAction"
implementation="com.vaadin.plugin.actions.VaadinCompileOnSaveAction" order="last"/>

<!-- Default program patcher to inject plugin file location -->
<java.programPatcher implementation="com.vaadin.plugin.copilot.DefaultProgramPatcher"/>

<!-- Debug using Hotswap Agent -->
<programRunner implementation="com.vaadin.plugin.hotswapagent.HotswapAgentRunner"/>
<java.programPatcher implementation="com.vaadin.plugin.hotswapagent.HotswapAgentProgramPatcher"/>
Expand Down