找不到方法commandLine()

编程入门 行业动态 更新时间:2024-10-27 14:24:00
本文介绍了找不到方法commandLine()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将预构建前的shell脚本添加到我的gradle/Android-Studio构建中.我已将以下内容添加到app/build.gradle:

I'm attempting to add a pre-pre-build shell script to my gradle/Android-Studio build. I've added the following to app/build.gradle:

task prePreBuild << { commandLine 'ls' } preBuild.dependsOn prePreBuild

当我使用./gradlew assembleDebug调用构建时,出现以下错误:

When I invoke my build with ./gradlew assembleDebug I get the following error:

Could not find method commandLine() for arguments [ls] on project ':app'

如果将commandLine行替换为println 'Hello',则可以正常工作,并且可以看到新任务的输出.

If I replace the commandLine line with something like println 'Hello' then it works fine, and I can see the output from my new task.

我搜索了其他提及找不到方法commandLine"的内容,但一无所获.从此gradle任务中调用Shell脚本的正确方法是什么?

I searched for other mentions of "Could not find method commandLine" and found nothing. What is the correct way to invoke a shell script from this gradle task?

推荐答案

您需要指出任务的类型或使用exec块:

You need to indicate the type of the task or use the exec block:

task execute(type: Exec) { }

exec { }

您可以在 docs.gradle上找到更多信息./current/dsl/org.gradle.api.tasks.Exec.html

更多推荐

找不到方法commandLine()

本文发布于:2023-11-14 05:00:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586288.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   方法   commandLine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!