@@ -23,7 +23,8 @@ import org.codehaus.groovy.grails.compiler.injection.*
2323import org.apache.tools.ant.BuildException
2424import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit
2525import org.codehaus.groovy.tools.ErrorReporter
26- import org.apache.tools.ant.AntClassLoader
26+ import org.apache.tools.ant.AntClassLoader
27+ import org.apache.tools.ant.util.*
2728import org.codehaus.groovy.control.*
2829
2930/**
@@ -47,7 +48,8 @@ class GrailsCompiler extends Groovyc {
4748 def compileList = []
4849
4950 String resourcePattern
50- String projectName
51+ String projectName
52+ boolean cleanJavaCompile = false
5153
5254 void resetFileLists () { compileList. clear() }
5355
@@ -103,7 +105,23 @@ class GrailsCompiler extends Groovyc {
103105 def resourceLoader = new GrailsResourceLoader (resources)
104106 GrailsResourceLoaderHolder . resourceLoader = resourceLoader
105107
106- if (compileList) {
108+ if (compileList) {
109+ // if there are Java sources do a complete re-compile
110+ if (cleanJavaCompile && compileList. find { it. name. endsWith(" .java" ) }) {
111+ compileList. clear()
112+ def m = new IdentityMapper ()
113+ def sfs = new SourceFileScanner (this );
114+ for (srcPath in src. list()) {
115+ def srcDir = getProject(). resolveFile(srcPath)
116+ def files = getDirectoryScanner(srcDir). getIncludedFiles()
117+ files = sfs. restrictAsFiles(files, srcDir, destDir, m)
118+ for (f in files) {
119+ if (f. name. endsWith(" .groovy" ) || f. name. endsWith(" .java" ))
120+ compileList << f
121+ }
122+
123+ }
124+ }
107125 println " Compiling ${ compileList.size()} source file${ compileList ? 's' : ''} to ${ destdir} "
108126
109127 if (classpath) configuration. classpath = classpath. toString()
0 commit comments