Maven Project Configuration

Content

Introduction

To make use of JEAF the following configurations must be added to your Maven projects

Add required Maven dependencies to your project

The following properties and dependencies needed to be added to your pom.xml

The latest version of a all JEAF artifacts can be found here: Latest Versions

Required changes to pom.xml

<!-- The following properties should be added to the properties section of your POM. --> <properties> <!-- Version of the JEAF X-Fun API that will be used to demonstrate usage of JEAF X-Fun. X-Fun API is a compile time dependency. As JEAF in general supports semantic versioning (https://semver.org/) upgrades within the same major version are always possible without having any impact on the application code. --> <jeaf.x-fun.api.version>1.6.2</jeaf.x-fun.api.version> <!-- Version of JEAF X-Fun implementation that will be used during runtime. This is only a runtime dependency. --> <jeaf.xfun.impl.version>1.6.4</jeaf.xfun.impl.version> <!-- JEAF Maven Plugin can be used to generate configuration files that are required by JEAF. However the actual configuration of JEAF is done through annotations. In case of JEAF X-Fun no specific configuration is required at all. All information that is needed is available by choosing the version of the default runtime for your project. --> <maven.jeaf-plugin.version>1.6.1</maven.jeaf-plugin.version> <!-- Version of JEAF Generator that is used. In case of JEAF X-Fun this Maven plugin is required to generate so called message constants that can be used in the application code to reference messages / error codes that are provided by JEAF's internationalization mechanism. Also refer to class com.anaptecs.jeaf.xfun.samples.messages.InternationalizationSample --> <maven.jeaf-generator-plugin.version>1.6.1</maven.jeaf-generator-plugin.version> <!-- Define versions of used Maven plugins --> <!-- Build helper plugin is required to add directories with generated sources to build. For further details see section about plugin build plugins. --> <maven.build.helper.version>3.0.0</maven.build.helper.version> </properties> <!-- The following dependencies should be added to your POM --> <dependencies> <!-- Compile time dependency of JEAF X-Fun API --> <dependency> <groupId>com.anaptecs.jeaf.x-fun</groupId> <artifactId>jeaf-x-fun-api</artifactId> <version>${jeaf.x-fun.api.version}</version> </dependency> <!-- Runtime dependency for X-Fun implementation. In almost all cases the X-Fun default runtime can be used. --> <dependency> <groupId>com.anaptecs.jeaf.x-fun</groupId> <artifactId>jeaf-x-fun-default-runtime</artifactId> <version>${jeaf.xfun.impl.version}</version> <scope>runtime</scope> <type>pom</type> </dependency> </dependencies>

Add JEAF Maven Plugins to your build

When working with JEAF there are several scenarios when code and / or resources will be generated. By default code will be written to the following directories:

Path

Description

Path

Description

src-gen/main/java

Directory where source code will be written to. Please ensure that inside this directories only generated code will be located as this directory might be deleted during code generation

src-gen/main/resources

Directory where resources will be written to. Please ensure that inside this directories only generated resources will be located as this directory might be deleted during code generation

src-gen/test/java

Directory where test source code will be written to. Please ensure that inside this directories only generated test code will be located as this directory might be deleted during code generation

src-gen/test/resources

Directory where resources will be written to. Please ensure that inside this directories only generated test resources will be located as this directory might be deleted during code generation

 

In addition to the needed Maven dependencies it is also strongly recommended to add the following Maven Plugins to your build:

  • Maven Build Helper Plugin
    Build helper plugin is required to add directories with generated sources to build. For further details see section about plugin build plugins.

  • JEAF Maven Plugin
    JEAF is configured using annotations. In order to improve startup times JEAF Maven Plugin analyzes the class path during build time and generates configuration files that are used to find the classes that hold the configuration values using annotations.

  • JEAF Generator
    JEAF Generator is used in several cases. One of them is to generate Java classes with constants so that are codes of JEAF X-Fun can be used very easy inside your code.


The latest versions of the plugins can be found here: Latest Versions

If you want to understand why a Maven Plugin is needed please refer to FAQ JEAF Maven Plugin

Maven Build Helper Plugin

Please refer to Maven Build Helper Plugin to see how the plugin should be configured.

JEAF Maven Plugin

JEAF Generator Maven Plugin

<!-- JEAF Generator is provided as Maven Plugin. It's strongly recommended to integrate JEAF Generator into the standard build process, so that the generated code is always up to date. In case of JEAF X-Fun the plugin cares about the following things: - Generate constants for all types for messages that are defined. - Messages can by maintained using Excel workbooks. In order to avoid runtime dependencies to Excel libraries workbooks will be transformed into XML files that will be used during runtime. This is also done by the plugin. --> <plugin> <groupId>com.anaptecs.jeaf.generator</groupId> <artifactId>jeaf-generator-maven-plugin</artifactId> <version>${maven.jeaf-generator-plugin.version}</version> <executions> <execution> <goals> <goal>Generator</goal> </goals> <phase>generate-sources</phase> </execution> </executions> <configuration> <!-- Define input files and directories where output should be write to. --> <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> <sourceGenDirectory>${project.basedir}/src-gen/main/java</sourceGenDirectory> <resourceDirectory>${project.basedir}/src/main/resources</resourceDirectory> <resourceGenDirectory>${project.basedir}/src-gen/main/resources</resourceGenDirectory> <!-- Configure behavior concerning existing files in src-gen and res-gen directory. It is strongly recommended to clean directories before generating new files. --> <cleanSourceGen>true</cleanSourceGen> <cleanResourceGen>true</cleanResourceGen> <!-- Define resource files that should be ignored when generating message constant classes from resources. --> <ignoredResourceFiles></ignoredResourceFiles> <!-- Define what should be generated. By default nothing is generated. --> <generateMessageConstants>true</generateMessageConstants> <!-- Define information that are written to file headers --> <fileHeaderCompany>anaptecs GmbH, Ricarda-Huch-Str. 71, 72760 Reutlingen, Germany</fileHeaderCompany> <fileHeaderAuthor>JEAF Generator</fileHeaderAuthor> <fileHeaderCopyright>Copyright 2004 - 2021. All rights reserved.</fileHeaderCopyright> <fileHeaderVersion>JEAF Release 1.6.x</fileHeaderVersion> </configuration> </plugin>