Examples

authors : Jean Couteau
contact : couteau@codelutin.com
revision : $Revision$
date : $Date$

This page groups two plugin configuration/usage examples in a pom. The first example is very simple, the second is more complex and aimed to bring a better understanding of the plugin combined with the usages documentation.

Cette page regroupe deux examples de configuration/utilisation du plugin dans un pom. Le premier example est très simple, le second est plus complexe et est censé ammener une complète compréhension du plugin combiné à la documentation des usages .

Simple example

This example will generate the entities and interfaces from the package org.nuiton.eugene.demopackage from the zargo files present in the src/main/xmi directory.

<plugin>
    <groupId>org.nuiton.eugene</groupId>
    <artifactId>eugene-maven-plugin</artifactId>
    <version>3.1-SNAPSHOT</version>
    <executions>

    <execution>
            <phase>generate-sources</phase>
            <!-- By default, generation from ObjectModel -->
            <configuration>
                <!-- Corresponding to extracted package from zargo file -->
                <fullPackagePath>org.nuiton.eugene.demopackage</fullPackagePath>
                <!-- DefaultPackage used for DAOHelper generation -->
                <defaultPackage>org.nuiton.eugene.demopackage</defaultPackage>
                <!-- Use topia templates -->
                <templates>
                    org.nuiton.topia.generator.TopiaMetaTransformer,
                    org.nuiton.topia.generator.InterfaceTransformer,
                    org.nuiton.topia.generator.BeanTransformer
                </templates>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <-- dependency to topia to use their template -->
    <dependencies>
        <dependency>
            <groupId>org.nuiton.topia</groupId>
            <artifactId>topia-persistence</artifactId>
            <version>${topiaVersion}</version>
        </dependency>
    </dependencies>
</plugin>

Complex example

This example uses two zargo files as input and will generate them separately.

The two first phases are common, then two executions are configured, one per file, specificating the different templates to use for each model file.

<plugin>
    <groupId>org.nuiton.eugene</groupId>
    <artifactId>eugene-maven-plugin</artifactId>
    <version>3.1-SNAPSHOT</version>
    <configuration>
        <defaultPackage>org.nuiton.eugene.demopackage</defaultPackage>
        <fullPackagePath>org.nuiton.eugene.demopackage</fullPackagePath>
    </configuration>

    <executions>

        <!-- Execution that transforms zargo files to objectmodel by using
        the full run without the model phase -->
        <execution>
            <phase>generate-sources</phase>
            <id>toModel</id>
            <configuration>
                <inputs>zargo</inputs>
                <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
                <skipInputs>model</skipInputs>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>

        <-- Execution that transforms the entities.objectmodel file using
        specific templates from topia -->
        <execution>
            <phase>generate-sources</phase>
            <id>model-to-entities</id>
            <configuration>
                <inputs>model:target/generated-sources/models:entities.objectmodel</inputs>
                <templates>
                    org.nuiton.topia.generator.TopiaMetaTransformer,
                    org.nuiton.topia.generator.InterfaceTransformer
                </templates>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>

        <-- Execution that transforms the beans.objectmodel file using
        other specific templates from topia -->
        <execution>
            <phase>generate-sources</phase>
            <id>model-to-bean</id>
            <configuration>
                <inputs>
                    <input>model:target/generated-sources/models:beans.objectmodel</input>
                </inputs>
                <templates>org.nuiton.topia.generator.BeanTransformer</templates>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>

    </executions>

    <!-- dependency to use topia templates -->
    <dependencies>
        <dependency>
            <groupId>org.nuiton.topia</groupId>
            <artifactId>topia-persistence</artifactId>
            <version>${topiaVersion}</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</plugin>