2017-02-21 140 views
-1

如何從gradle包裝中運行mvn可執行文件?在gradlew中運行可執行文件

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

我可以正常訪問終端的命令。我還在路徑變量中添加了MAVEN_HOME,但看起來像gradlew仍然無法找到該命令。

回答

0

取決於您的操作系統。如果您使用的是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> 
}