gpt4 book ai didi

gradle - 在 Gradle Exec Task 中,命令行搜索环境但不是可执行文件的工作目录

转载 作者:行者123 更新时间:2023-12-03 03:33:54 29 4
gpt4 key购买 nike

似乎 Exec commandLine 没有查看 workingDir 的可执行命令,而是搜索环境。

如果您的项目结构如下:

+ projectRoot
+ libraryMod
- build.gradle
+ app
- gradlew
- build.gradle

你想跑
./gradlew -b ../libraryMod/build.gradle someTask

作为执行官:
exec{
workingdir = getAbsolutePath("../app")
commandLine = ['./gradlew', '-b ../libraryMod/build.gradle', 'someTask]
}

返回
[org.gradle.process.internal.DefaultExecHandle] Starting process 'command 'gradlew''. Working directory: /Users/dev/app Command: gradlew -b /Users/dev/libraryMod/build.gradle sometask
[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Environment for process 'command 'gradlew'': {PATH=/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin, SHELL=/bin/bash, JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home, JAVA_MAIN_CLASS_29464=org.gradle.wrapper.GradleWrapperMain, TERM=xterm-256color, OLDPWD=/Users/dev/java/android/api/TestApp, USER=dev, TMPDIR=/var/folders/gj/c0vstk4s0c5632d92hp72prxy5h3g7/T/, APP_NAME_29464=Gradle, SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.HaOOxHKo1q/Listeners, DISPLAY=/private/tmp/com.apple.launchd.G54BIfEQjR/org.macosforge.xquartz:0, XPC_FLAGS=0x0, __CF_USER_TEXT_ENCODING=0x7C580DE7:0x0:0x0, Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.pUgDDkEH6R/Render, APP_ICON_29464=/Users/dev/app/media/gradle.icns, LOGNAME=dev, LC_CTYPE=en_US.UTF-8, XPC_SERVICE_NAME=0, PWD=/Users/dev/app, SHLVL=1, HOME=/Users/dev, BUILD_NUM=802}



[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command 'gradlew'.
[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'gradlew'' finished with exit value -1 (state: FAILED)

有没有办法使用 exec 使命令行的第一个参数在 workingDir 中查找?

我可以将其作为任务成功运行:
task publishAAR(type:GradleBuild){
description 'publish the lib module aar bundle to artifactory'
buildFile = libModScript
tasks = ['someTask']

}

但需要使用 exec 合并到更大的构建文件中。

最佳答案

尝试将可执行文件设置为 gradlew 文件的绝对路径。

exec {
executable "${projectDir}/gradlew"
}

关于gradle - 在 Gradle Exec Task 中,命令行搜索环境但不是可执行文件的工作目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29289200/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com