Integration with Maven: Declaration

If you want to use smartics-properties in a Maven project, follow these steps.

In your project you provide property declarations in form of Java interfaces annotated with @PropertySet.

Note that the step of defining properties is separated from the declaration. For more information on this topic refer to Integration with Maven: Definition or Domain, for explanations of the terms declaration and definition.

Library Dependency

To use smartics-properties in your Maven project add the following dependencies to your POM:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>de.smartics.properties</groupId>
      <artifactId>smartics-properties-bom</artifactId>
      <version>${smartics-properties-bom_version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <!-- Optional: Only required if you use projectdoc annotations. -->
    <groupId>de.smartics.projectdoc</groupId>
    <artifactId>projectdoc-annotations</artifactId>
  </dependency>
  <dependency>
    <!-- Always required; here you find e.g. the PropertySet annotation. -->
    <groupId>de.smartics.properties</groupId>
    <artifactId>smartics-properties-annotations</artifactId>
  </dependency>
  <dependency>
    <!-- The core library is required to access properties from within your code. -->
    <groupId>de.smartics.properties</groupId>
    <artifactId>smartics-properties-core</artifactId>
  </dependency>
  <dependency>
    <!-- The config library is required to access configurations from within your code. -->
    <groupId>de.smartics.properties</groupId>
    <artifactId>smartics-properties-config</artifactId>
  </dependency>
</dependencies>

The BOM artifact provides a valid set of artifacts. Dependent on the technologies you choose (e.g. database store, CDI integration, security module), you may add further dependencies from the BOM.

For an overview over the individual modules that form the smartics-properties project, please refer to Modules.

Mark Archive as Declaration Provider

If smartics-properties scans an archive, it checks whether or not a META-INF/smartics-properties/declaration.xml is present. If it is, the archive is scanned for interfaces marked with the @PropertySet annotation and for each property found a property descriptor is registered. If the archive does not contain the declaration file, the scanning for this archive is skipped.

If you are using the smartics-properties-maven-plugin (see below), this file is generated for you. If you want to provide your own, add it at:

META-INF/smartics-properties/declaration.xml

The contents is, for instance, as follows:

<config xmlns="http://smartics.de/properties/declaration/1">
  <homepage-url>http://www.smartics.eu/test-module-mail</homepage-url>
  <properties-report-url>http://www.smartics.eu/test-module-mail/property</properties-report-url>
</config>

These are the two optional elements:

  1. homepage-url - the URL to the homepage of this project.
  2. properties-report-url - the reference to the online properties documentation.

The system uses this information to create URLs to the online information at runtime. If this information is not provided, the URLs will not be shown.

Generation of Metadata

To generate the optional but recommended properties metadata for the META-INF/smartics-properties folder of the Java archive artifact, add the smartics-properties-maven-plugin to your POM.

<plugin>
  <groupId>de.smartics.properties</groupId>
  <artifactId>smartics-properties-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>properties-xml-export</id>
      <goals>
        <goal>xml-export</goal>
      </goals>
    </execution>
  </executions>
</plugin>

The information may be edited manually. If you omit the information, the runtime system will have less information to the user of the system about properties (i.e. the Javadoc comments) and additional information (e.g. home page URL of the project) about them on the web.

For more information please refer to XML Report.

Examples

There are test modules that show how the information above fits together:

  1. test-module-mail
  2. test-module-announce
  3. test-module-agile