Search code examples
mavenintellij-ideaversioningcollaboration

Share Maven run configurations with other developers using Intellij IDEA


We have the following project setup: Maven, Eclipse, Subversion. Eclipse Launch configurations are in a separate docs folder next to the pom.xml. The launch configurations run something like mvn clean install -Pdev or mvn tomee:run -pl something-ear

The good thing is that a shared run configuration is picked up by the IDE and shown in the External Tools run commands. This way, every developer that checks out this project immediately has access to run the build.

We would like to have something similar using IntelliJ IDEA, but I haven't found a good equivalent. What I have considered so far:

Share run scripts

My first idea was to replace the launch configurations with run scripts. I just could not figure out how to have those run scripts run inside IntelliJ IDEA just the way a Maven goal would be executed.

Share IDEA project configuration

The IDEA project configuration (specifically .idea/runConfigurations) inside the checked out directory is not a good solution. We have (speaking one IDEA project with different IDEA modules depending on the task at hand: as a developer you might need multiple IDEA modules (and sub-modules) in the same IDEA project

An IDEA project consisting of the following modules is not something unusal

projectA/trunk
projectB/tags/1.2
projectC/branches/some-change

My preferred solution would remove all IDE-specific configuration from the repository and have some kind of run definitions either in the project folder or a folder next to the pom.xml that a developer can run from the command line or from her IDE of choice.

The optimal solution would let me define something like this in the pom:

<runConfigs>
    <default>clean install</default>
    <container>tomee:run -pl something-ear</container>
</runConfigs>

This configuration would then be picked up by the IDE and provided as a run or launch configuration to the developer.

Any ideas or suggestions?

Thank you very much!


Solution

  • My current approach is a hybrid solution:

    • No configuration in the separate modules
    • One IDEA project configuration with run configurations managed in VCS

    The .idea/runConfigurations directory is versioned separately from the project sources. It contains commands with a working directory set relative to the PROJECT_DIR:

    <MavenRunnerParameters>
        …
        <option name="workingDirPath" value="$PROJECT_DIR$/path/to/submodule" />
    </MavenRunnerParameters>
    

    When setting up a new project, the developer also checks out this folder and has a set of pre-configured launch configurations for all projects. The downsides are

    • All launch configurations are managed centrally instead of with the module
    • The IDEA project directory has a fixed location relative to the modules. If you set up another project, you will have to change the run configurations
    • The setup does not clearly state how changes to the launch configurations are shared with other developers