Skip to content

Commit

Permalink
GRAILS-9429 fixed path separator for file-based resources in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Burt Beckwith committed Oct 21, 2012
1 parent a1b2e15 commit 14fe38a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
Expand Up @@ -202,7 +202,7 @@ class PluginBuildSettings {

def pluginInfos = []
Resource[] pluginDescriptors = getPluginDescriptors()
def pluginDescriptorReader = new CompositePluginDescriptorReader(this)
CompositePluginDescriptorReader pluginDescriptorReader = new CompositePluginDescriptorReader(this)
for (desc in pluginDescriptors) {
try {
GrailsPluginInfo info = pluginDescriptorReader.readPluginInfo(desc)
Expand Down Expand Up @@ -409,9 +409,9 @@ class PluginBuildSettings {
sourceFiles = new Resource[0]
sourceFiles = resolvePluginResourcesAndAdd(sourceFiles, true) { pluginDir ->
Resource[] pluginSourceFiles = resourceResolver("file:${pluginDir}/grails-app/*")
pluginSourceFiles = (Resource[])IOUtils.addAll(pluginSourceFiles,resourceResolver("file:${pluginDir}/src/java"))
pluginSourceFiles = (Resource[])IOUtils.addAll(pluginSourceFiles,resourceResolver("file:${pluginDir}/src/groovy"))
cache.sourceFilesPerPlugin[pluginDir] = pluginSourceFiles
pluginSourceFiles = (Resource[])IOUtils.addAll(pluginSourceFiles, resourceResolver("file:${pluginDir}/src/java"))
pluginSourceFiles = (Resource[])IOUtils.addAll(pluginSourceFiles, resourceResolver("file:${pluginDir}/src/groovy"))
cache['sourceFilesPerPlugin'][pluginDir] = pluginSourceFiles
return pluginSourceFiles
}
cache.sourceFiles = sourceFiles
Expand All @@ -426,7 +426,7 @@ class PluginBuildSettings {
Resource[] getPluginSourceDirectories(File pluginDir) {
getPluginSourceDirectories() // initialize cache

cache.sourceFilesPerPlugin[pluginDir.absolutePath]
cache['sourceFilesPerPlugin'][pluginDir.absolutePath]
}

/**
Expand Down Expand Up @@ -847,12 +847,12 @@ class PluginBuildSettings {
private resolvePluginResourcesAndAdd(Resource[] originalResources, boolean processExcludes, Closure resolver) {

Resource[] pluginDirs = getPluginDirectories()
for (dir in pluginDirs) {
AntPathMatcher pathMatcher = new AntPathMatcher()
for (Resource dir in pluginDirs) {
def newResources = dir ? resolver(dir.file.absolutePath) : null
if (newResources) {
if (processExcludes) {
def excludes = EXCLUDED_RESOURCES
AntPathMatcher pathMatcher=new AntPathMatcher()
newResources = newResources.findAll { Resource r ->
def relPath = relativePath(dir.file, r.file)
!excludes.any { String it ->
Expand Down
Expand Up @@ -36,7 +36,6 @@
public class FileSystemResource implements Resource {

private final File file;

private final String path;

/**
Expand All @@ -45,25 +44,9 @@ public class FileSystemResource implements Resource {
* @param file a File handle
*/
public FileSystemResource(File file) {
assertNotNull(file, "File must not be null");
this.file = file;
if (file.exists()) {

String canonicalPath = null;
try {
canonicalPath = file.getCanonicalPath();
} catch (IOException e) {
// ignore
}
if (canonicalPath != null) {
path = canonicalPath;
}
else {
path = file.getPath();
}
}
else {
path = file.getPath();
}
path = GrailsResourceUtils.cleanPath(file.getPath());
}

/**
Expand All @@ -72,7 +55,9 @@ public FileSystemResource(File file) {
* @param path a file path
*/
public FileSystemResource(String path) {
this(new File(path));
assertNotNull(path, "Path must not be null");
file = new File(path);
this.path = GrailsResourceUtils.cleanPath(path);
}

/**
Expand Down Expand Up @@ -204,4 +189,10 @@ public boolean equals(Object obj) {
public int hashCode() {
return path.hashCode();
}

protected void assertNotNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}
}

0 comments on commit 14fe38a

Please sign in to comment.