Gradle中的全球插件 [英] Global Plugins in Gradle

查看:125
本文介绍了Gradle中的全球插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Gradle作为我的Scala项目的构建工具。我也使用Eclipse进行开发,因此我总是在我的构建文件中使用 apply插件:'eclipse'



是否还有一种方法可以全局定义 apply插件? SBT已经有这样的功能。我之所以想这样做,是因为使用我的项目的其他开发人员可能不使用Eclipse,而是使用另一个IDE,他们必须根据需要更改构建脚本。如果有全局配置文件,可以在其中放置个人配置,并且不会与其他配置冲突。 可以把它放到〜/ .gradle / init.gradle

  rootProject.allprojects {
apply plugin:eclipse
}

缺点这种方法的缺点是它使得构建的重现性较低。人们现在需要添加一些东西到他们的 init.gradle 中,以使构建工作(某些方面)成为可能。因此,我建议在主构建脚本中应用Eclipse插件;它不会伤害不使用它的人。


I am using Gradle as a build tool for my Scala projects. I am also using Eclipse for development, so I always use the apply plugin: 'eclipse' in my build files.

Is there also a way to define the apply plugin globally? SBT already has such a feature. The reason why I want this, is that other developers who’re using my project probably don’t use Eclipse but another IDE and they would have to change the build script for their needs. If there were a global configuration file, one could put personal configurations in there and it wouldn’t conflict other ones.

解决方案

You can put this into ~/.gradle/init.gradle:

rootProject.allprojects {
    apply plugin: "eclipse"
}

The drawback of this approach is that it makes the build less reproducible. People now need to add something to their init.gradle to make (some aspect of) the build work. Therefore, I would recommend to apply the Eclipse plugin in the main build script; it won't hurt people who don't use it.

这篇关于Gradle中的全球插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆