简体   繁体   English

Gradle-Eclipse和IDEA插件在同一个脚本中?

[英]Gradle- Eclipse and IDEA plugin in same script?

I'm trying to figure out how Gradle applies IDE plugins. 我正在试图弄清楚Gradle如何应用IDE插件。 If I wanted a build.gradle script that accommodated both Eclipse and IDEA, can I declare both plugins in the script? 如果我想要一个同时兼容Eclipse和IDEA的build.gradle脚本,我可以在脚本中声明这两个插件吗? Will it try to create the metadata for both? 它会尝试为两者创建元数据吗? Or is the IDE Gradle implementation start enough to choose the correct one? 或者IDE Gradle实现是否足以选择正确的?

apply plugin: 'eclipse'
apply plugin: 'idea'

I just want to make sure that when I put any project source files in a GIT repository with the build.gradle script, the import and build experience will be fine for those IDEs. 我只想确保当我将任何项目源文件放在带有build.gradle脚本的GIT存储库中时,导入和构建体验对于这些IDE来说都是正常的。

Applying the eclipse plugin simply adds eclipse tasks to the build allowing to generate an eclipse project from the gradle project. 应用eclipse插件只需将eclipse任务添加到构建中,允许从gradle项目生成eclipse项目。

Applying the idea plugin simply adds idea tasks to the build allowing to generate an IDEA project from the gradle project. 应用构思插件只需将构思任务添加到构建中,从而允许从gradle项目生成IDEA项目。

I don't see any reason why you couldn't do both. 我没有看到你不能两者兼顾的任何理由。

Just adding the plugins to your build.gradle file doesn't do anything until you run one or more of the tasks that these plugins introduce. 在运行这些插件引入的一个或多个任务之前,只需将插件添加到build.gradle文件中就不会执行任何操作。 It wont create any metadata for either IDE until you run the specific tasks. 在运行特定任务之前,它不会为任何IDE创建任何元数据。

For a list of tasks that each plugin adds, see these links: 有关每个插件添加的任务列表,请参阅以下链接:

ref: 参考:
http://gradle.org/docs/current/userguide/idea_plugin.html http://gradle.org/docs/current/userguide/idea_plugin.html
http://gradle.org/docs/current/userguide/eclipse_plugin.html http://gradle.org/docs/current/userguide/eclipse_plugin.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM