Developing a DataGrip plugin

Synopsis

Developing a DataGrip plugin from scratch.

Prerequisites

  • IntelliJ for developing the plugin. The community edition is perfectly fine.
  • DataGrip. You can use a trial license.

Init

  • launch IntelliJ
  • New project > IDE plugin
    ** Name: xanthidae-JB ** Group: org.xanthidae ** location: choose a suitable location in your file system

register an action

  • open src/main/resources/META-INF/plugin.xml
  • add the following block after the extensions section (just before the end)
 <actions>
        <action id="org.xanthidae.xanthidaejb.FlywayVersionedMigrationAction"
                class="org.xanthidae.xanthidaejb.FlywayVersionedMigrationAction"
                text="Flyway: versioned migration"
                description="Creates a versioned migration for Flyway">
            <override-text place="MainMenu" text="Xanthidae-JB: versioned migration"/>
            <add-to-group group-id="ToolsMenu" anchor="first"/>
            <keyboard-shortcut
                    keymap="$default"
                    first-keystroke="control alt A"
                    second-keystroke="C"/>
            <mouse-shortcut
                    keymap="$default"
                    keystroke="control button3 doubleClick"/>
        </action>
    </actions>
  • add a new Kotlin class named FlywayVersionedMigration in the org.xanthidaejb package

Test it

  • Run > Run plugin -> a new IDE will start
  • Tools > Repeatable migration -> the file chooser dialog will be shown

156 Words

2023-09-24