在gradle中,如何为插件版本使用变量? [英] In gradle, how to use a variable for a plugin version?

查看:1656
本文介绍了在gradle中,如何为插件版本使用变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个构建脚本导入了nebula插件:

 插件{
id'nebula.ospackage'版本'3.5.0'
}

我将所有版本信息一个单独的文件,所有项目都可以访问并且想知道什么是正确的语法转换为类似:

  plugins {
id'nebula.ospackage'version$ versions.nebula_gradle_ospackage_plugin
}

当我尝试使用gradle clean build运行上面的代码时,出现以下错误:


构建文件'build.gradle':2 :参数列表必须完全是1文字
非空字符串

请参阅
https://docs.gradle.org/2.7/userguide/plugins.html#sec:plugins_block
插件{}块



@ line 2,第33列。
id'nebula.ospackage'version$ versions.nebula_gradle_ospackage_plugin



<这篇链接文章展示了我如何使用buildscript模块,它可以工作,但似乎必须有一种方法可以在单行中完成这项工作?



其中plugin version和plugin id必须是常量,字面值
字符串。没有其他声明是允许的;他们的存在将导致
编译错误。



One of my build scripts imports that nebula plugin:

plugins {
  id 'nebula.ospackage' version '3.5.0'
}

I've been moving all of my version info into a separate file that all projects have access to and am wondering what is the correct syntax to convert to something like:

plugins {
  id 'nebula.ospackage' version "$versions.nebula_gradle_ospackage_plugin"
}

When I try running the above with "gradle clean build", I get the following error:

build file 'build.gradle': 2: argument list must be exactly 1 literal non empty string

See https://docs.gradle.org/2.7/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

@ line 2, column 33. id 'nebula.ospackage' version "$versions.nebula_gradle_ospackage_plugin"

The linked article shows how I could use the "buildscript" block, which works, but it seems like there must be a way to make this work in a single line?

解决方案

You cannot use variable here:

Where «plugin version» and «plugin id» must be constant, literal, strings. No other statements are allowed; their presence will cause a compilation error.

这篇关于在gradle中,如何为插件版本使用变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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