Gradle将重复的启动脚本创建到bin目录中 [英] Gradle creating duplicate start scripts into bin directory
本文介绍了Gradle将重复的启动脚本创建到bin目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过gradle创建多个启动脚本文件。但不知怎的,一个特定的启动脚本文件正在被复制。
I am trying to create multiple start script files through gradle. But somehow one particular start script file is getting duplicated.
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')
in bin directory我可以看到,
in bin directory I can see,
- A.sh
- A.sh
- A.bat
- A.bat
- B.sh
- B.bat
- A.sh
- A.sh
- A.bat
- A.bat
- B.sh
B.bat
我在这里错过了什么?如何解决这个问题?
What am I missing here? How to fix this?
感谢您的帮助。
Thank you for help.
推荐答案
我解决了这个问题。其实这是我的错误,并感谢@Opal。我不知何故忘记从头中删除'mainClassName =com.main.A'行。
I solved this problem. Actually it was a mistake from my side and thanks to @Opal. I somehow forgot to delete 'mainClassName="com.main.A"' line from the header.
另外我还要添加
Also I have to add
distZip {
duplicatesStrategy = 'exclude'
}
这篇关于Gradle将重复的启动脚本创建到bin目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文