Maven Tools

< Main Index Visual Page Editor/BrowserSim >


JBoss Maven Integration


JBoss Source Lookup

JBoss Source lookup utilizes the Maven metadata found in Jar's to locate source code found in runtime directories.

Normal m2e source lookup only does this for launch configurations related to a Maven project and on Maven classpaths. This source lookup is useful for all launch configurations which uses jar's (with Maven metadata) from one or more directories which are not even on your project classpath. This is the case for many runtimes these days.

The Source lookup feature automatically recognizes JBoss AS runtimes, but if you are using other runtimes (such as Glassfish or Tomcat) you can point it at a directory and source lookup will recursively scan this directorys jar and look for maven metadata to use against the list of known repositories.

It will use standard maven artifact id lookups to find matching source artifacts and if that does not work it will do a checksum lookup to try and locate the source.

To enable it for all JBoss AS launch configurations you need to go enable it in the preferences.

There are more about this feature in the JBoss Source Lookup wiki.

Related jira.


Annotation Processing support

m2e-apt is a m2e plugin allowing automatic configuration of Eclipse JDT's built-in Annotation Processing Toolkit (APT) based on your maven project's pom.xml configuration.
m2e-apt is preinstalled with JBoss Developer Studio 5.0.0.Beta3. For JBoss Tools 3.0.0.Beta3 users, m2e-apt can be installed via the Software/Update tab in JBoss Central :

With m2e-apt, you can now automatically enable annotation processing support for maven projects, based on their classpath dependencies (Requires Java >= 1.6).

m2e-apt supports both annotation processing set on the maven-compiler-plugin or the maven-processor-plugin (the latter takes precedence over the former).

For example, to enable the JPA modelgen annotation processor, you can either set :

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
    </configuration> 
    <dependencies> 
        <dependency> 
            <groupId>org.hibernate</groupId> 
            <artifactId>hibernate-jpamodelgen</artifactId> 
            <version>1.2.0.Final</version> 
        </dependency> 
    </dependencies> 
</plugin> 

or 

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArgument>-proc:none</compilerArgument> 
    </configuration> 
</plugin> 
<plugin> 
    <groupId>org.bsc.maven</groupId> 
    <artifactId>maven-processor-plugin</artifactId> 
    <version>2.0.5</version> 
    <executions> 
        <execution> 
            <id>process</id> 
            <goals> 
                <goal>process</goal> 
            </goals> 
            <phase>generate-sources</phase> 
        </execution> 
    </executions> 
    <dependencies> 
        <dependency> 
            <groupId>org.hibernate</groupId> 
            <artifactId>hibernate-jpamodelgen</artifactId> 
            <version>1.2.0.Final</version> 
        </dependency> 
    </dependencies> 
</plugin> 

The generated source folders (target/generated-sources/annotation for maven-compiler-plugin; target/generated-sources/apt for maven-processor-plugin) are automatically added to the project classpath.

Since Annotation Processing is managed by Eclipse JDT APT by default, a change in your source classes triggers incremental processing automatically. The downside of using JDT APT is, there's no separation between main and test classes (the way maven-processor-plugin handles them). To mitigate that limitation, you can change the workspace or project preferences to delegate annotation processing to maven, instead of JDT APT (Note this only works when using maven-processor-plugin). This will result in slower incremental builds (all classes will be processed) but will provide identical results to maven command line builds.

Automatic Annotation Processing configuration from the maven pom.xml can also be disabled altogether. In this case, your manual settings for Eclipse JDT APT will remain untouched.

Go to Window > Preferences > Maven > Annotation processing or right-click on your project > Properties > Maven > Annotation processing to select the Annotation Processing strategy of your choice.

See JBIDE-8208 for more details.


GWT configurator

You can enable/disable GWT Project Configurator by using follow preference:

GWT Project Configurator scans configuration "gwt-maven-plugin" in pom.xml for modules and adds them to the configuration.
For example, to define module(s) in pom.xml you can either set:

or

If there are no modules defined in pom.xml then Configurator adds all existing modules to configuration.

GWT Project Configurator sets GWT Compiler output folder to the same folder which is used by Maven Compiler.

You can use Maven or GWT Compiler to compile your application and Deploy to Server or Running on an External Server, it does not require additional compilation.

See:


Hibernate 3.6.x and 4.x maven provided libraries

When you start a project and you need to add Hibernate as your JPA provider, adding the Hibernate dependencies manually one by one can be a chore. Now if your project is Facet enabled, adding both the JBoss Maven and the JPA Facet will give you access to new JPA library providers for the Hibernate platform.

  • Right-click on your project > Properties > Project Facets
  • Convert to Faceted form if necessary
  • Select both the JBoss Maven and JPA Facet
  • Click on the "Further Configuration required/available..." link
  • On the JPA Facet page, select the Hibernate JPA 2.X platorm and the type of JPA implementation
  • Hibernate 4.1.0 or 3.6.10 libraries are available


You can change the dependencies version and exclusions :

Once you finish the Facets configuration, your project will have the Hibernate dependencies added to its pom.xml

See JBIDE-10911 for more details.