public static boolean parseResource(IResource res) {
if (res instanceof IFile && "drl".equals(res.getFileExtension())) {
removeProblemsFor(res);
try {
IJavaProject project = JavaCore.create(res.getProject());
// exclude files that are located in the output directory,
// unless the ouput directory is the same as the project location
if (!project.getOutputLocation().equals(project.getPath())
&& project.getOutputLocation().isPrefixOf(res.getFullPath())) {
return false;
}
} catch (JavaModelException e) {
// do nothing
}
RuleBaseContext factoryContext = new RuleBaseContext();
RuleSetReaderWithErrors reader = new RuleSetReaderWithErrors(factoryContext);
try {
ClassLoader oldLoader = Thread.currentThread()
.getContextClassLoader();
ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
if (res.getProject().getNature("org.eclipse.jdt.core.javanature") != null) {
IJavaProject project = JavaCore.create(res.getProject());
newLoader = ProjectClassLoader.getProjectClassLoader(project);
}
try {
Thread.currentThread().setContextClassLoader(newLoader);
reader.read(new StringReader(new String(Util.getResourceContentsAsCharArray((IFile) res))));