插件之前仅允许构建脚本和其他插件脚本块 [英] only build script and other plugins script blocks are allowed before plugins

查看:1383
本文介绍了插件之前仅允许构建脚本和其他插件脚本块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用具有这种语法的gradle插件

I want to use gradle plugin having this syntax

 plugins {
  id "id" version "version"
}

但是我有错误

only build script and other plugins script blocks are allowed before plugins 

我将其移至bloc buildscript,但仍无法正常工作.

I moved it to the bloc buildscript but still not working.

我如何应用这种插件?

这是我要包含在项目中的插件

This is the plugin that I want to include in my project

渐变git properties插件

这是我的gradle版本的输出

and here is the output of my gradle version

    Gradle 4.3.1
------------------------------------------------------------

Build time:   2017-11-08 08:59:45 UTC
Revision:     e4f4804807ef7c2829da51877861ff06e07e006d

Groovy:       2.4.12

推荐答案

无论何时编写build.gradle脚本并使用新的plugins脚本块,都需要将其作为文件中的第一块.此规则唯一的例外是其他plugins块或特殊的buildScript块,它们必须始终排在最前面.

Whenever you write a build.gradle script and use the new plugins script block, you need to put it as first block in the file. The only exceptions from this rule are other plugins blocks or the special buildScript block, which always must go first.

例如,此脚本很好:

plugins {
    // ...
}

dependencies {
    // ...
}

这也很好:

buildScript {
    // ...
}

plugins {
    // ...
}

repositories {
    // ...
}

但这是无效的:

repositories {
     // ...
}

plugins {
    // ...
}

这篇关于插件之前仅允许构建脚本和其他插件脚本块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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