@@ -31,6 +31,7 @@ import java.lang.reflect.Field
3131 *
3232 */
3333@CompileStatic
34+ @Slf4j
3435class GrailsAutoConfiguration implements GrailsApplicationClass , ApplicationContextAware {
3536
3637 private static final String APC_PRIORITY_LIST_FIELD = " APC_PRIORITY_LIST" ;
@@ -75,15 +76,24 @@ class GrailsAutoConfiguration implements GrailsApplicationClass, ApplicationCont
7576 if (ignoredRootPackages(). contains(pkg)) {
7677 continue
7778 }
78- String pattern = ResourcePatternResolver . CLASSPATH_ALL_URL_PREFIX +
79- ClassUtils . convertClassNameToResourcePath(pkg) + Settings . CLASS_RESOURCE_PATTERN ;
79+ // if it is the default package
80+ if (pkg == " " ) {
81+ // try the default package in case of a script without recursing into subpackages
82+ log. error(" The application defines a Groovy source using the default package. Please move all Groovy sources into a package." )
83+ String pattern = ResourcePatternResolver . CLASSPATH_ALL_URL_PREFIX + " *.class"
84+ classes. addAll scanUsingPattern(pattern, readerFactory)
85+ }
86+ else {
87+
88+ String pattern = ResourcePatternResolver . CLASSPATH_ALL_URL_PREFIX +
89+ ClassUtils . convertClassNameToResourcePath(pkg) + Settings . CLASS_RESOURCE_PATTERN ;
90+
91+
92+ classes. addAll scanUsingPattern(pattern, readerFactory)
93+ }
8094
81- classes. addAll scanUsingPattern(pattern, readerFactory)
8295 }
8396
84- // try the default package in case of a script without recursing into subpackages
85- String pattern = ResourcePatternResolver . CLASSPATH_ALL_URL_PREFIX + " *.class"
86- classes. addAll scanUsingPattern(pattern, readerFactory)
8797
8898 def classLoader = Thread . currentThread(). contextClassLoader
8999 for (cls in AbstractGrailsArtefactTransformer . transformedClassNames) {
@@ -224,10 +234,10 @@ class GrailsAutoConfiguration implements GrailsApplicationClass, ApplicationCont
224234
225235 this . rootResource = getURLs()[0 ]
226236 this . applicationClass = applicationClass
227- def urlStr = rootResource. toString()
237+ String urlStr = rootResource. toString()
228238 jarDeployed = urlStr. startsWith(" jar:" )
229239 try {
230- def withoutBang = new URL (" ${ urlStr.substring(0, urlStr.length() - 2)} /" )
240+ URL withoutBang = new URL (" ${ urlStr.substring(0, urlStr.length() - 2)} /" )
231241 addURL(withoutBang)
232242
233243 } catch (MalformedURLException e) {
0 commit comments