Using annotations in Maven NetBeans Module projects

Since version 6.8 NetBeans provides annotations to simplify various NetBeans platform API usages. So you can register a ServiceProvider and the build process generates the proper META-INF/service entry. Other annotations are capable of generating layer file entries. So far this didn't work in Maven based project due to MCOMPILER-98 bug of the maven-compiler-plugin. The issue is fixed now, but it will take time to propagate into a released version of the compiler plugin. Here is how to enable it in your Apache Maven projects now.

Open your netbeans module project pom.xml file (or the parent pom of your module projects to configure all modules)
and add the following maven-compiler-plugin configuration:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.1</version>
   <configuration>
     <source>1.6</source>
     <target>1.6</target>
   </configuration>
   <dependencies>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-compiler-javac</artifactId>
       <version>1.7-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-compiler-api</artifactId>
       <version>1.7-SNAPSHOT</version>
     </dependency>
   </dependencies>
</plugin>

Since you are depending on unreleased snapshots, a snapshot repository declaration pointing to Plexus snapshot repository is necessary.

Afterward you are ready to use the annotations in NetBeans APIs. Enjoy!

Reblog this post [with Zemanta]

About this Entry

This page contains a single entry by mkleint published on January 21, 2010 1:24 PM.

Task oriented UI for Maven projects was the previous entry in this blog.

Maven snapshot repository for NetBeans daily builds is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.