我试图通过gradle创建多个启动脚本文件.但不知何故,一个特定的启动脚本文件正在重复.
startScripts.enabled = false
run.enabled = false
def createScript(project,mainClass,name) {
project.tasks.create(name: name,type: CreateStartScripts) {
outputDir = new File(project.buildDir,'scripts')
mainClassName = mainClass
applicationName = name
classpath = jar.outputs.files + project.configurations.runtime
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\conf','%APP_HOME%\\conf')
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/conf','$APP_HOME/conf')
}
}
project.tasks[name].dependsOn(project.jar)
project.applicationDistribution.with {
into("bin") {
from(project.tasks[name])
fileMode = 0755
}
}
}
// Call this for each Main class you want to expose with an app script
createScript(project,'com.main.A','A')
createScript(project,'com.main.B','B')
在bin目录中我可以看到,
> A.sh
> A.sh
> A.bat
> A.bat
> B.sh
> B.bat
我在这里错过了什么?如何解决这个问题?
谢谢你的帮助.
最佳答案
原文链接:https://www.f2er.com/java/437223.html