Skip to content

Commit 8ee4335

Browse files
author
graeme
committed
fix for GRAILS-1519
git-svn-id: https://svn.codehaus.org/grails/trunk@5274 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent beb1255 commit 8ee4335

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed
5 Bytes
Binary file not shown.

scripts/Init.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ void setClasspath() {
394394
def grailsDir = resolveResources("file:${basedir}/grails-app/*")
395395
def pluginLibs = resolveResources("file:${basedir}/plugins/*/lib")
396396

397-
Ant.path(id:"grails.classpath") {
397+
Ant.path(id:"grails.classpath") {
398+
pathelement(location:"${classesDir.absolutePath}")
398399
pathelement(location:"${basedir}")
399400
pathelement(location:"${basedir}/test/unit")
400401
pathelement(location:"${basedir}/test/integration")

scripts/RunApp.groovy

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ task( watchContext: "Watches the WEB-INF/classes directory for changes and resta
6969
Ant.groovyc(destdir:classesDirPath,
7070
classpathref:"grails.classpath",
7171
resourcePattern:"file:${basedir}/**/grails-app/**/*.groovy",
72-
projectName:baseName) {
73-
src(path:"${basedir}/src/java")
74-
src(path:"${basedir}/src/groovy")
75-
src(path:"${basedir}/grails-app/domain")
76-
}
72+
projectName:baseName,
73+
cleanJavaCompile:true,
74+
compilerClasspath.curry(false))
7775

7876
}
7977
catch(Exception e) {

src/groovy/org/codehaus/groovy/grails/compiler/GrailsCompiler.groovy

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import org.codehaus.groovy.grails.compiler.injection.*
2323
import org.apache.tools.ant.BuildException
2424
import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit
2525
import 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.*
2728
import 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

Comments
 (0)