Closed GoogleCodeExporter closed 9 years ago
this is definitely working. please check that the result of
ClasspathHelper.getUrlsForPackagePrefix("your.package") contains the relevant
url, and that the url contais the relevant class files
Original comment by ronm...@gmail.com
on 22 Dec 2010 at 9:49
I found that there is an issue with reflections. It does not handle spaces in
the file path to get to the source directory.
This works: C:\workspaces\main\Test\src\...
This does not work C:\workspaces\main\Test Space\src\...
I end up writing my own class because I didn't want to bring around 2MB of jars
into my project.
This was the code I used to allow me to have spaces in my file directory path:
String path = packageName.replace('.', '/');
Enumeration<URL> resources = null;
try {
resources = classLoader.getResources(path);
} catch (IOException e) {
logger.error(e,e);
}
logger.info("Find all Classes in this package: "+packageName);
while (resources != null && resources.hasMoreElements()) {
try {
URL resource = resources.nextElement();
String urlPath = resource.getFile().replaceAll("%20", " ");
logger.info(new File(urlPath).getPath());
classes.addAll(findClasses(new File(urlPath), packageName));
} catch (Exception e) {
logger.error(e.getMessage());
}
}
Original comment by curtis.p...@gmail.com
on 5 Jan 2011 at 4:31
Original issue reported on code.google.com by
curtis.p...@gmail.com
on 16 Dec 2010 at 8:32Attachments: