IntelliJ run configurations in build.gradle file

▼魔方 西西 提交于 2020-05-30 08:26:27

问题


I have a Gradle project which I can currently import into IntelliJ via the build.gradle file. IntelliJ will setup the correct source locations and pull in the dependencies for me.

What I would like to do is list the IntelliJ "run configurations" in the build.gradle file so it will automatically set these up for me (correct class/arguments). Is this possible?


回答1:


There is an experimental plugin for Gradle developed by an employee of JetBrains.

https://github.com/JetBrains/gradle-idea-ext-plugin

It provides several options to adjust the configuration of IntelliJ from within the build-script. Adding a run configuration could look like this.

plugins {
  id "org.jetbrains.gradle.plugin.idea-ext" version "0.5"
}

idea.project.settings.runConfigurations {
  'App'(org.jetbrains.gradle.ext.Application) {
    mainClass = 'com.example.myapp.App'
    moduleName = project.idea.module.name + '.main'
    programParameters = '--some-option some-argument'
    jvmArgs = '-Xmx1G'
  }
}


来源:https://stackoverflow.com/questions/45476700/intellij-run-configurations-in-build-gradle-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!