build.gradle
的一部分:
task runCraftBukkit(type:Exec) {
println "Starting CraftBukkit server..."
commandLine = ['cmd', '/C', 'start', 'D:/Projects/WorkSpaces/WorldCleaner/devserver/start.bat'] // cmd /C start D:/Projects/WorkSpaces/WorldCleaner/devserver/start.bat
workingDir = file('./devserver/')
}
jar.doLast {
runCraftBukkit.execute()
}
输出:
15:13:54: Executing external task 'jar'...
Starting CraftBukkit server...
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
BUILD SUCCESSFUL
...
但是命令提示符窗口和不会出现。
问题: 我做错了什么?
答案 0 :(得分:3)
工作解决方案:
task runCraftBukkit(type:Exec) {
doFirst {
println "Starting CraftBukkit server..."
workingDir = file('./devserver/')
commandLine = ['cmd', '/C', 'start', 'start.bat']
// cmd /C start D:/Projects/WorkSpaces/WorldCleaner/devserver/start.bat
}
}
jar.finalizedBy runCraftBukkit
我花了很多时间寻找错误。问题不在于:)
主要问题是任务没有执行。决策证明方法.finalizedBy
现在:
...
:jar UP-TO-DATE
:runCraftBukkit
Starting CraftBukkit server...
...
这正是我想看到的:]