本文介绍了IntelliJ在build.gradle文件中运行配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Gradle项目,目前可以通过build.gradle文件导入IntelliJ. IntelliJ将设置正确的源位置并为我提取依赖项.

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.

我想做的是在build.gradle文件中列出IntelliJ运行配置",这样它将自动为我设置这些设置(正确的类/参数).这可能吗?

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?

推荐答案

JetBrains的一名员工为Gradle开发了一个实验性插件.

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

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

它提供了几个选项,可从构建脚本中调整IntelliJ的配置.添加运行配置可能如下所示.

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'
  }
}

这篇关于IntelliJ在build.gradle文件中运行配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 00:06