startScripts {
inputs.property("classpath", { classpath }) // for incremental build to work properly
outputs.dir "$buildDir/scripts"
classpath += files('src/main/config')
//workaround for gradle bug paths must be manually corrected
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
String text = windowsScriptFile.text
String textTmp = ""
text.readLines().each {
line ->
if (regExp.matcher(line).find()) {
textTmp += line + "\n\n@rem Change folder to application home\ncd %APP_HOME%\n"
} else {
textTmp += line + '\n'
}
}
windowsScriptFile.text = textTmp
windowsScriptFile.text = windowsScriptFile.text.replace("%APP_HOME%\lib\config", "%APP_HOME%\config")
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/config', '$APP_HOME/config')
}
}
No errors detected in compressed data of C:\Users\cwpl-zsokolow\Downloads\capella-1.0.51.20121217-141619.zip. Testing … It produces wrong zip file with doubled entries out put from winzip:
Did you make any customizations to the distZip task itself? If yes, can you share it?. My first guess is that you accidently declare the startscripts files twice to be included in the distZip.
Somehow, your code is adding the same files twice - otherwise, a ‘Zip’ task won’t produce duplicate entries. Can you provide a self-contained, reproducible example?
I have noticed also that it has included twice a one jar. I can send you Peter a script I don’t want to copy - paste whole here. But this particular is not so complicated. Stupid question do you put name of files which should be zipped in set collection before zipping?
I’m just interested why it happens. I think that it should be impossible for user to add more than one file to zip. When user uses just a plugin without any customizations. I can imagine that customization could spoil something.
There’s probably some problem with your workaround.
I think that it should be impossible for user to add more than one file to zip.
It must be possible for users to add duplicate entries to archives, because there are valid use cases for this. However, there should be an easy way to ignore duplicates, and maybe duplicates should be ignored by default (however that would be a breaking change). If you are interested in where we are going with this, you can follow the design spec.
Rene, for sure I don’t have two startScripts sections. This above is only one my section. Something is wrong with creating zip maybe when I’m using doLast? and something goes wrong