gpt4 book ai didi

linux - lessc exec 任务未在 Gradle 中执行

转载 作者:太空狗 更新时间:2023-10-29 12:42:52 26 4
gpt4 key购买 nike

这是我的任务:

task less(group:'web',dependsOn:checkDirs) << {
file(skinsDir).listFiles().each { dir ->
if (dir.isDirectory() && dir.list().contains("pmc.less")) {
def inFile = dir.toPath().resolve("pmc.less").toString()
def outFile = "$buildDir/css/skins/${dir.name}/pmc.css"
def minOutFile = "$buildDir/css/skins/${dir.name}/pmc.min.css"
exec {
workingDir dir
commandLine "lessc",inFile,">",outFile
}
}
}
}

当我运行时

gradle -i less

然后命令在信息级输出中正确列出:

:flat_pmc:less
Executing task ':flat_pmc:less' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/contrast Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/contrast/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/contrast/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/eggshell Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/eggshell/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/eggshell/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/sand Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/sand/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/sand/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/nebel Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/nebel/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/nebel/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/aqua Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/aqua/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/aqua/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/venezia Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/venezia/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/venezia/pmc.css
Successfully started process 'command 'lessc''
Starting process 'command 'lessc''. Working directory: /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/inverno Command: lessc /home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/inverno/pmc.less > /home/dys/dev/synosteel/flat_pmc/build/css/skins/inverno/pmc.css
Successfully started process 'command 'lessc''
:flat_pmc:less (Thread[Daemon worker Thread 6,5,main]) completed. Took 1.722 secs.

“正确列出”是指如果我复制 lessc/home/dys/dev/synosteel/flat_pmc/src/webapp/m3/skins/venezia/pmc.less >/home/dys/dev/synosteel/flat_pmc/build/css/skins/venezia/pmc.css 直接在控制台运行,生成css文件。

但是使用 gradle 执行无法创建 css 文件。

这里发生了什么?

最佳答案

commandLine 仅用于传递命令名称和参数,不支持 shell 重定向语法。试试这个:

exec {
workingDir dir
commandLine "lessc",inFile
standardOutput = new FileOutputStream(outFile)
}

Exec:commandLine
Exec:standardOutput
FileOutputStream

关于linux - lessc exec 任务未在 Gradle 中执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35942134/

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