build.gradle - 在 doLast 块中未获取 Gradle 项目属性最新值
问题描述
I have a problem picking up the right parameter values in the doLast method in my customer task
Example
I have a task loadfile as below
task loadFile(type: JavaExec)
{
systemProperties = System.properties
group = "Execution"
main = "configurations.git.StreamYamlGitModule"
classpath = sourceSets.test.runtimeClasspath
jvmArgs = [
"-DENV_NAME=${System.getProperty("env")}",
]
}
doLast {
println (“Properites ${project.property(‘name’)}”)
}
任务运行 java 类并将值填充到 gradle.properties 文件中
gradle.properites
Name = test
Strategy = abc
我遇到的问题是下面的代码没有填充加载到 name 属性的 gradle.properties 文件中的最新值。它总是拾取旧值(在任务运行之前。示例任务运行并将值“stage”填充到属性文件中,但它打印旧值“test”)
期望打印最新值的代码部分 doLast {
println (“Properites ${project.property(‘name’)}”)
}
Any idea how can I get the latest value printed ? appreciate your help
解决方案
推荐阅读
- c# - 每次从数据库中获取相同的数据
- sql - 使用过滤器合并删除目标行的语法是什么?
- sql - 在不使用临时表的情况下优化查询并优化用户体验
- validation - 带有附加组件的 Google G-Suite 表单上的自定义验证
- sql - 如何在sql中查询123 *具有给定前缀的所有内容?
- visual-studio-code - 在 VSCode 中打开 csproj 时,OmniSharp 抛出错误
- apache - 原始的 httpd-vhosts.conf 是什么样的?
- php - ajax 调用仅显示每个循环中第一项的输入值。需要它根据按钮单击的上下文显示
- haskell - 用于从标准概率分布中采样的 Haskell 包
- php - 在 PHP 中调用 require_once 后,Echo 不起作用