Skip to content
Andrew Holland edited this page Mar 24, 2014 · 9 revisions

About

This site provides some custom extensions for the m2e Maven-Eclipse Integration. Currently available:

  • AspectJ extension
  • JAXB extension
  • HyperJAXB extension
  • OpenJPA extension

Installation

From your Eclipse menu bar, select Help | Install New Software... and enter this update site URL in the Work with field:

https://raw.github.com/hwellmann/m2eclipse-extras/master/p2/

Select the Omadac m2e Extensions category and the features you require.

Installation via the Discovery process under Window | Preferences | Maven is not yet supported.

Compatibility

The current version 0.2.0 of the extensions is compatible with any of

  • Eclipse Indigo/m2e 1.0.x
  • Eclipse Juno/m2e 1.1.x or 1.2.x.
  • Eclipse Kepler/m2e 1.4.0

AspectJ extension usage

The AspectJ extension supports compile-time weaving for AspectJ using the aspectj-maven-plugin, which is typically configured like this:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.3.1</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <verbose>true</verbose>
      <complianceLevel>1.6</complianceLevel>
      <showWeaveInfo>true</showWeaveInfo>
      <aspectLibraries>
        <aspectLibrary>
          <groupId>org.springframework</groupId>
          <artifactId>spring-aspects</artifactId>
        </aspectLibrary>
      </aspectLibraries>
    </configuration>
    <executions>
      <execution>
        <id>aspectj</id>
        <goals>
          <goal>compile</goal>
          <goal>test-compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

The AspectJ m2e extension runs the Mojo in the background when you save one of your source files of the given project, so your classes are always woven automatically in your Eclipse builds.

JAXB extension usage

The m2e extension for JAXB supports the maven-jaxb2-plugin, which is typically configured in the POM of your project like this:

  <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.7.4</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <extension>true</extension>
      <schemaIncludes>
        <include>xsd/whizbang.xsd</include>
      </schemaIncludes>
    </configuration>
  </plugin>

There are two optional configuration elements schemaDirectory and generateDirectory specifying the directories for your input schemas and for the JAXB classes to be generated by xjc.

The default values are:

  • schemaDirectory: src/main/resources
  • generateDirectory: target/generated-sources/xjc

The m2e JAXB extension automatically adds the generateDirectory source folder to your Eclipse project. It automatically runs xjc via the maven-jaxb2-plugin whenever you modify any resources in schemaDirectory.

OpenJPA extension usage

The OpenJPA extension supports build-time byte code enhancement of JPA entity classes for Apache OpenJPA using the openjpa-maven-plugin or the newer version org.apache.openjpa:openjpa-maven-plugin.

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>openjpa-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
      <persistenceXmlFile>${basedir}/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
    </configuration>
    <executions>
      <execution>
        <id>enhancer</id>
        <phase>process-classes</phase>
        <goals>
          <goal>enhance</goal>
        </goals>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa-all</artifactId>
        <version>${openjpa.version}</version>
      </dependency>
    </dependencies>
  </plugin>

The OpenJPA m2e extension runs the Mojo in the background when you save one of your source files of the given project, so your entity classes are always enhanced automatically in your Eclipse builds.

The schema, sql and test-enhance goals of the openjpa-maven-plugin are currently mapped to ignore by this extension.

About this repository

This repository is a fork of Sonatype's official m2eclipse-extras repository. The Sonatype sources are still left in trunk for reference and as a basis for further extensions. All custom plugins and features have a name prefix of org.omadac.

The top-level aggregator POM only builds the org.omadac modules.

Author

Harald Wellmann