How to add Maven RunConfiguration

Answered

Hi,

till now we used netbeans as favorite ide. In netbeans there is an file called "nbactions.xml" in this file u you can add custom maven run configuration for the maven project. For instance there is an action "generate" in this file, which runs maven phase clean+compile with some special profiles and properties.

Now some developers like to use intellij idea instead of netbeans. The only special netbeans things in our maven projects are this special nbactions-XML-files, which store special maven run configurations. In intellij idea u can use run configurations for this. But we don't want to manage to different run configurations for different ides. So we though about an intellij idea plugin which reads the nbactions-file on project-load and create maven run configurations in intellij.

My code looks like this

RunnerAndConfigurationSettings runnerAndConfigurationSettings = RunManager.getInstance(project).createConfiguration("Test", ConfigurationTypeUtil.findConfigurationType("MavenRunConfiguration").getConfigurationFactories()[0]);
RunManager.getInstance(project).addConfiguration(configuration,true);

the run configuration is created, but I can't find a description how to set working directory, command-line and profiles in the create run configuration api. Like I can do in intellij idea manually

I hope someone can help me.

Best regards

Matthias

0
2 comments

See org.jetbrains.idea.maven.execution.MavenRunConfiguration#getRunnerParameters

0

Thanks. The complete solution is:

  • Dependency to maven, my gradle groovy build-script looks like this
    intellij {
    version '2019.1'
    plugins 'maven'
    }
  • Then use MavenRunConfigurationType.createRunnerAndConfigurationSettings(...) to create RunnerAndConfig, so you can put MavenRunnerParameters

 

0

Please sign in to leave a comment.