destination: file()

in src/main/scripts/CreateJob.groovy [23:39]


        destination: file( "grails-app/jobs/$model.packagePath/${trimTrailingJobFromJobName(model.simpleName)}Job.groovy"),
        model: model

/**
 * //if 'Job' already exists in the end of JobName, then remove it from jobName.
 * @param name
 * @return
 */
String trimTrailingJobFromJobName(String name){
    String type = "Job"
    String processedName = name
    Integer lastIndexOfJOBInJobName = name.lastIndexOf(type)
    if(lastIndexOfJOBInJobName == (name.length() - type.length())){
        processedName = name.substring(0, lastIndexOfJOBInJobName)
    }
    return processedName
}