Setup an application to use JBG

This page will guide you to set up an application to use JBG.

Standard directory layout

It is recommended that the directory layout follows these guidelines:

  • Configuration file names end with "-beans.xml".
  • For production scope beans:
    • Configuration files are placed in an arbitrary directory structure nested under /src/main/gen-config.
    • The generated Java source files are created under /target/generated-sources/jbg.
    • The generated documentation of the beans is created under /target/site/jbg.
  • For test scope beans:
    • Configuration files are placed in an arbitrary directory structure nested under /src/test/gen-config.
    • The generated Java source files are created under /target/generated-test-sources/jbg.
    • The generated documentation of the beans is created under /target/site/jbg.

POM set up

The items to be set-up in your POM include the following.

Dependencies

Add dependency to JBG to the POM:

<dependency>
        <groupId>net.sf.jbg</groupId>
        <artifactId>jbg</artifactId>
        <version>1.0</version>
</dependency>

Execute jbg-maven-plugin

Execute jbg-maven-plugin to perform the generation itself.

  • To generate the Java source files, execute the beans goal.
  • To generate the reports, execute the report goal.

Add the dependency to Saxon, as the JBG templates use XSLT 2.0.

See the JBG Maven plugin site for details on using the plugin.

Java version >= 1.5

Set up the maven-compiler-plugin to use Java 1.5 or higher as the generated sources use parameterized types.

POM example

See an example POM file with a configuration of JBG.

Next >>