Search code examples
javamavenmaven-3maven-pluginebean

How do I enable Ebean Enhancement in Maven?


I've been using Avaje.org ebean ORM layer for a while, but I don't understand how to enable the byte-code enhancement functionality described in the "Ebean v2.6.0 User Guide" with Maven.

I found a configuration example on the Avaje.org homepage, but it doesn't work. Neither does the demo Maven boilerplate on GitHub.

Help!


Solution

  • EBeans now has its own Maven Plugin, but I can't find any documentation online, so here is an example of how to use it:

    <plugin>
        <groupId>org.avaje.ebeanorm</groupId>
        <artifactId>avaje-ebeanorm-mavenenhancer</artifactId>
        <version>${ebean.version}</version>
        <executions>
            <execution>
                <id>main</id>
                <phase>process-classes</phase>
                <goals>
                    <goal>enhance</goal>
                </goals>
                <configuration>
                    <packages>com.package1.**,com.package2.**</packages>
                    <transformArgs>debug=1</transformArgs>
                    <classSource>${project.build.outputDirectory}</classSource>
                    <classDestination>${project.build.outputDirectory}</classDestination>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    With Eclipse

    If you use Eclipse, you will want to make sure it runs the plugin when needed, like this:

    <build>
        <plugins>
            <!-- plugins here -->
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.avaje.ebeanorm</groupId>
                                        <artifactId>avaje-ebeanorm-mavenenhancer</artifactId>
                                        <versionRange>[3.3.2,)</versionRange>
                                        <goals>
                                            <goal>enhance</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnConfiguration>true</runOnConfiguration>
                                            <runOnIncremental>true</runOnIncremental>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>