Transferring Property Definitions

The properties-transfer Mojo allows to copy property definitions from a project (or some arbitrary source) to a destination (e.g. another folder or a database).

The following configuration copies properties found in one folder of the project to another. In the taget folder the properties are written as XML files.

<plugin>
  <groupId>de.smartics.properties</groupId>
  <artifactId>smartics-properties-maven-plugin</artifactId>
  <version>0.2.0</version>
  <executions>
    <execution>
      <id>properties-transfer</id>
      <phase>package</phase>
      <goals>
        <goal>properties-transfer</goal>
      </goals>
      <configuration>
        <propertiesFolder>${project.build.outputDirectory}</propertiesFolder>

        <definitionConfigParser
          implementation="de.smartics.properties.impl.config.domain.key.rtaware.TenantUserDefinitionConfigParser" />


        <propertySinkFactory implementation="de.smartics.properties.config.transfer.filesystem.Factory">
          <targetFolder>\${basedir}/target/testme</targetFolder>
          <outputFormat>xml</outputFormat>
        </propertySinkFactory>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>de.smartics.properties</groupId>
      <artifactId>smartics-properties-transfer-filesystem</artifactId>
      <version>/add current version here/</version>
    </dependency>
  </dependencies>
</plugin>

There are a couple of things to note in this configuration.

Binding

First, this example binds the execution to the package phase. Per default, the Mojo binds to no phase. It may usually be only called on the command line.

Source of Property Definitions

The source is specified by the propertiesFolder element. The standard implementation fetches all properties files (with extension properties) and writes them to the specified sink. The writing is specified by the propertySinkFactory we focus on in the next section.

If there are archive artifacts (such as JARs) in the folder and should these archives contain property definitions, these definitions will also be transferred to the sink. Those archives require a file called

META-INF/smartics-properties/definition.xml

If this file is present all properties files (with the extension properties) that are outside the META-INF folder within the archive file will be transferred. The configuration key for those files is determined the files section of the keys defined in the definition.xml.

Definition Parser

The parser for definition.xml files is determined by the definitionConfigParser property.

The XML namespace of the root element hints at the implementation to be used.

Sink of Property Definitions

The property definitions are written to a sink by an implementation of

de.smartics.properties.api.config.transfer.PropertySinkFactory

In this example this is an implementation that writes the property definitions to a folder in the file system. The implementation

de.smartics.properties.config.transfer.filesystem.Factory

provides implementation specific properties to specify the target folder (targetFolder element) and the output format (outputFormat element). The latter allows the values native (standard properties file format) and xml (standard XML properties file format).

The implementation is provided by the plugin's dependency section.

Please refer to the list of property sinks for implementations of the property sink interface.