运行 gradlew 中的可执行文件

Run executables in gradlew

如何从 gradle 包装器中 运行 mvn 可执行文件?

 task install(type: Exec, dependsOn: assemble) {
   description = "Som description."
   executable = 'mvn'
   args = ["install:install-file", <more-args-here>]
 }

我可以正常从终端访问命令。我还在路径变量中添加了 MAVEN_HOME 但看起来 gradlew 仍然找不到命令。

取决于您的 OS。如果你在 Windows 尝试将你的任务重写成这个

task install(type: Exec, dependsOn: assemble) {
    description = "Som description."
    commandLine 'cmd', '/c', 'mvn', 'install:install-file', <more-args-here>
}

在 linux 上

task install(type: Exec, dependsOn: assemble) {
    description = "Som description."
    commandLine './mvn', 'install:install-file', <more-args-here>
}