@@ -40,6 +40,23 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver
4040
4141class PluginBuildSettings {
4242
43+ /**
44+ * Resources to be excluded from the final packaged plugin. Defined as Ant paths.
45+ */
46+ public static final EXCLUDED_RESOURCES = [
47+ " web-app/WEB-INF/**" ,
48+ " web-app/plugins/**" ,
49+ " grails-app/conf/spring/resources.groovy" ,
50+ " grails-app/conf/*DataSource.groovy" ,
51+ " grails-app/conf/DataSource.groovy" ,
52+ " grails-app/conf/BootStrap.groovy" ,
53+ " grails-app/conf/Config.groovy" ,
54+ " grails-app/conf/BuildConfig.groovy" ,
55+ " grails-app/conf/UrlMappings.groovy" ,
56+ " **/.svn/**" ,
57+ " test/**" ,
58+ " **/CVS/**"
59+ ]
4360 private static final PathMatchingResourcePatternResolver RESOLVER = new PathMatchingResourcePatternResolver ()
4461
4562 /**
@@ -290,7 +307,7 @@ class PluginBuildSettings {
290307 if (! sourceFiles) {
291308 cache[' sourceFilesPerPlugin' ] = [:]
292309 sourceFiles = new Resource [0 ]
293- sourceFiles = resolvePluginResourcesAndAdd(sourceFiles, pluginDirPath) { pluginDir ->
310+ sourceFiles = resolvePluginResourcesAndAdd(sourceFiles, pluginDirPath, true ) { pluginDir ->
294311 Resource [] pluginSourceFiles = resourceResolver(" file:${ pluginDir} /grails-app/*" )
295312 pluginSourceFiles = ArrayUtils . addAll(pluginSourceFiles,resourceResolver(" file:${ pluginDir} /src/java" ))
296313 pluginSourceFiles = ArrayUtils . addAll(pluginSourceFiles,resourceResolver(" file:${ pluginDir} /src/groovy" ))
@@ -439,7 +456,7 @@ class PluginBuildSettings {
439456 def resources = [] as Resource []
440457
441458 // first scan plugin sources. These need to be loaded first
442- resources = resolvePluginResourcesAndAdd(resources) { String pluginDir ->
459+ resources = resolvePluginResourcesAndAdd(resources, this . pluginDirPath, true ) { String pluginDir ->
443460 getArtefactResourcesForOne(pluginDir)
444461 }
445462
@@ -580,6 +597,7 @@ class PluginBuildSettings {
580597 return descriptor
581598 }
582599
600+
583601 /**
584602 * Takes a Resource[] and optional pluginsDirPath and goes through each plugin directory. It will then used the provided
585603 * resolving resolving closures to attempt to resolve a new set of resources to add to the original passed array.
@@ -588,13 +606,21 @@ class PluginBuildSettings {
588606 * in the closure
589607 */
590608 private resolvePluginResourcesAndAdd (Resource [] originalResources , String pluginsDirPath = this . pluginDirPath, Closure resolver ) {
609+ resolvePluginResourcesAndAdd originalResources, pluginsDirPath, false , resolver
610+ }
611+
612+ private resolvePluginResourcesAndAdd (Resource [] originalResources , String pluginsDirPath = this . pluginDirPath, boolean processExcludes , Closure resolver ) {
591613 Resource [] pluginDirs = getPluginDirectories()
592614 for (dir in pluginDirs) {
593615 def newResources = dir ? resolver(dir. file. absolutePath) : null
594616 if (newResources) {
595- originalResources = ArrayUtils . addAll(originalResources, newResources)
617+ if (processExcludes) {
618+ def excludes = EXCLUDED_RESOURCES
619+ newResources = newResources. findAll { Resource r -> ! excludes. any { r. file. absolutePath. endsWith(it) } }
620+ }
621+ originalResources = ArrayUtils . addAll(originalResources, newResources as Resource [])
596622 }
597623 }
598624 return originalResources
599- }
625+ }
600626}
0 commit comments