Skip to content

cobigen maven_configuration

Malte Brunnlieb edited this page Feb 25, 2015 · 22 revisions

Build Integration

For maven integration of CobiGen you can include the following build plugin into your build:

Build integration of CobiGen
<build>
    <plugins>
        <plugin>
            <groupId>com.capgemini</groupId>
            <artifactId>cobigen-maven-plugin</artifactId>
            <version>VERSION-YOU-LIKE</version>
            <executions>
                <execution>
                    <id>cobigen-generate</id>
                    <phase>site</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Available goals

  • generate: Generates contents configured by the standard non-compiled configuration folder. Thus generation can be controlled/configured due to an location URI of the configuration and tempalte or increment ids to be generated for a set of inputs.

Available phases are all phases, which already provide compiled sources such that CobiGen can perform reflection on it. Thus possible phases are for example package, site.

GobiGen Configuration

For generation using the CobiGen maven plug-in, the CobiGen configuration can be provided in two different styles:

  1. By a configurationFolder, which should be available on the file system whenever you are running the generation. The value of configurationFolder should correspond to the maven file path syntax.

    Provide CobiGen configuration by configuration folder (file)
    <build>
        <plugins>
            <plugin>
                ...
                <configuration>
                    <configurationFolder>cobigen-templates</configurationFolder>
                </configuration>
                ...
            </plugin>
        </plugins>
    </build>
  2. By maven dependency, whereas the maven dependency should stick on the same conventions as the configuration folder. This explicitly means that it should contain non-compiled resources as well as the context.xml on top-level.

    Provide CobiGen configuration by maven dependency (jar)
    <build>
        <plugins>
            <plugin>
                ...
                <dependencies>
                    <dependency>
                        <groupId>com.capgemini</groupId>
                        <artifactId>cobigen-templates-XYZ</artifactId>
                        <version>VERSION-YOU-LIKE</version>
                    </dependency>
                </dependencies>
                ...
            </plugin>
        </plugins>
    </build>

    We currently provide a generic deployed version of the templates on the oasp-nexus for Register Factory (<artifactId>cobigen-templates-RF</artifactId>) and for the OASP itself (<artifactId>cobigen-templates-OASP</artifactId>).

Build Configuration

Using the following configuration you will be able to customize your generation as follows:

  • <destinationRoot> specifies the root directory the relative destinationPath of CobiGen templates configuration should depend on. Default ${basedir}

  • <inputPackage> declares a package name to be used as input for batch generation. This refers directly to the CobiGen Java Plug-in container matchers of type package configuration.

  • <inputFile> declares a file to be used as input. The CobiGen maven plug-in will try to parse this file to get an appropriate input to be interpreted by any CobiGen plug-in.

  • <increment> specifies an increment ID to be generated.

  • <template> specifies a template ID to be generated.

  • <forceOverride> specifies an overriding behavior, which enables non-mergable resources to be completely rewritten by generated contents. For mergable resources this flag indicates, that conflicting fragments during merge will be replaced by generated content. Default: false

Example for a simple build configuration
<build>
    <plugins>
        <plugin>
            ...
            <configuration>
                <destinationRoot>${basedir}</destinationRoot>
                <inputPackages>
                    <inputPackage>package.to.be.used.as.input</inputPackage>
                </inputPackages>
                <inputFiles>
                    <inputFile>path/to/file/to/be/used/as/input</inputFile>
                </inputFiles>
                <increments>
                    <increment>IncrementID</increment>
                </increments>
                <templates>
                    <template>TemplateID</template>
                </templates>
                <forceOverride>false</forceOverride>
            </configuration>
            ...
        </plugin>
    </plugins>
</build>
Clone this wiki locally