The script files generated by type CreateStartScripts get added twice

Hi,

I wanted to add a custom script to gradle build job. So added the below to my build.gradle file as recommended in the Gradle Application file

task createStartScriptsForUpdate(type: CreateStartScripts) {
    mainClassName = 'com.connector.AppUpdater'
    applicationName = 'app_updater'
    outputDir = new File(project.buildDir, 'scripts')
    classpath = jar.outputs.files + project.configurations.runtime
}

//tasks.build.dependsOn 'createStartScriptsForUpdate'

applicationDistribution.into("bin") {
    from(createStartScriptsForUpdate)
    fileMode = 0755
}

But the script file gets added twice in the final zip file when I run gradle build. Can someone help me fix the problem? Thanks.

Gradle Version: 2.9
Operating System and JVM version: Mac OS X 10.11.6 x86_64, JVM version is 1.8

Thanks,
Leena

Hi Leena,

thank you for reporting. The Gradle version you are using is pretty old. Could you try with a current version, like Gradle 3.0?

Thanks,
Stefan

Hi Stefan,

Thanks for the quick response.

I upgraded to the latest version i.e 3.0. I was still facing the problem.

Then I changed the script a little bit i.e. replaced

applicationDistribution.into("bin") {
    from(createStartScriptsForUpdate)
    fileMode = 0755
}

with the below:

distributions {
    main {
        contents {
            from(createStartScriptsForUpdate)
        }
    }
}

And it resolved the problem :slight_smile:. I am not very clear how it resolved, the only change I could see is that explicitly mentioning that the script needs to be copied to bin directory.

May be you could explain it in detail.

Thanks again,