Gradle create duplicate startup scripts in bin directory

I am trying to create multiple start script files via gradle. But somehow, one script run file is 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 the bin directory i see

  • A.sh
  • A.sh
  • A.bat
  • A.bat
  • B.sh
  • B.bat

    What am I missing here? How to fix it?

Thank you for your help.

+5
source share
1 answer

I solved this problem. Actually it was a mistake on my part and thanks to @Opal. I somehow forgot to remove the line mainClassName = "com.main.A" from the header.

I also need to add

 distZip { duplicatesStrategy = 'exclude' } 
+3
source

Source: https://habr.com/ru/post/1235067/


All Articles