Grails clean build deletes target/classes folder

For some reason my Spring Tool Suite has a problem with grails clean target. Most of the time running clean script removes 'target/classes' folder after which i am getting errors like:

Error automatically restarting container: 
destination directory "/workspace/target/classes" 
does not exist or is not a directory

To get rid of the issue edit the file:

/grails-1.2.1/scripts/_GrailsClean.groovy

and add mkdir command at the end of cleanCompiledSources target

target (cleanCompiledSources:"Cleans compiled Java and Groovy sources" ) {
    def webInf = "${basedir}/web-app/WEB-INF"
    ant.delete(dir:"${webInf}/classes")
    ant.delete(file:webXmlFile.absolutePath, failonerror:false)
    ant.delete(dir:"${projectWorkDir}/gspcompile", failonerror:false)
    ant.delete(dir:"${webInf}/lib")
    ant.delete(dir:"${basedir}/web-app/plugins")
    ant.delete(dir:classesDirPath)
    ant.delete(dir:resourcesDirPath)
    ant.delete(dir:testDirPath)

    ant.mkdir(dir:classesDirPath)
}

This way Grails will create new classes folder in target folder every time you run clean command.

Hope it helps : )

Comments

Post new comment

Image CAPTCHA

About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog.

I am a passionate software engineer living in Sydney and working for Yahoo! Drop me a line or leave a comment.

Enjoy!