Monday, August 6, 2012

IDE errors with Maven projects after upgrading to NetBeans 7.2

A recent upgrade of NetBeans from version 7.1 to 7.2 seemed to cause problems with Maven multi-module projects. Normally, a newly created class in one Maven project module will be instantly visible to other modules open in the IDE, at least for editing purposes. But after the upgrade I started to see "cannot find symbol" errors in the IDE for such new classes. Despite this, a full build of the project would succeed.

Googling for an answer drew a blank. The usual kludge fixes such as deleting the NetBeans cache (for NetBeans 7.2 on OSX this seems to have moved from ~/.netbeans to ~/Library/Application Support/Netbeans) and re-indexing my local repo didn't make any difference. Despair loomed.

Happily, I stumbled across the cause of the problem after only a moderate amount of pulling of hair and gnashing of teeth. My Maven settings.xml file included this section...


    <profiles>
        <profile>
            <id>netbeans-ide</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <netbeans.installation>/Applications/NetBeans/NetBeans 7.1.app/Contents/Resources/NetBeans</netbeans.installation>
            </properties>
        </profile>
    </profiles>

After editing the path to point to 7.2.app the IDE errors disappeared.