Monday, April 13, 2009

Setup IntelliJ to Resolve XInclude Paths

If you are using XInclude in IntelliJ, you might have seen errors like this:

An XInclude errors reported by IntelliJ 8.1

IntelliJ attempts to resolve paths in XInclude relative to the paths you defined as source folders in your Project Structure. You might have defined paths like src/java as a source folder; that is: folders in which you have Java code. But if you keep you resources separate from your Java files (i.e. in src/resources and src/resource-packaged like we do in Orbeon Forms), you will get the error above as IntelliJ fails to find a file src/java/foo/bar.xhtml.

As of IntelliJ 8.1, you can't disable this behavior so rather than become numb to errors reported by IntelliJ, you can setup it up to look for those files in your resources folder by adding resources a Source Folder or Test Source Folder.

Adding resource paths as source folders in Project Structure (screenshot in IntelliJ 8.1)

A negative side-effect of this configuration is that when compiling your source with IntelliJ as described earlier, it will copy all the files that it considers to be resources in the output path. Mostly, this means that compiling will start taking more time than it should. You can disable this behavior by editing the pattern that describes what IntelliJ considers to be a resource. You can change this pattern under Settings, Compiler, Resource patterns. Entirely removing the pattern will do.

Removing the resource pattern under Settings, Compiler (screenshot in IntelliJ 8.1)

No comments:

Post a Comment