我正在尝试将预构建前的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()
发布评论