Usage

Modify your project POM to look something like this:

<project ...>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>net.sf.qxs</groupId>
        <artifactId>configuration-plugin</artifactId>
        <version>1.0.8</version>
        <configuration>
          <!--
            The following configuration parameters are allowed:

              sourceDir (optional)
                Directory of the source tree where generated code is written to.

              className (optional)
                Name of the generated Java class.

              attributes (mandatory)
                A set of attribute definitions which will be used to
                configure your application.
          -->
          <!--
          <sourceDir>${project.basedir}/src/main/java</sourceDir>
          <className>${project.groupId}.Configuration</className>
          -->
          <attributes>
            <!--
              Add attributes here. An attribute may have the following
              fields:

               name (mandatory)
                 the name of the attribute.

               type (mandatory)
                 the attribute type. Should be one of: boolean, int, long,
                 float, double, String.

               required (default: false)
                 flag to indicate whether or not the attribute is required
                 to configure your application.

               description (optional)
                 a free-text description of the attribute.
            -->
            <param>
              <name>someAttribute</name>
              <type>String</type>
              <required>true</required>
              <description>Explains the attribute.</description>
            </param>
            <param>
              <name>anotherAttribute</name>
              <type>int</type>
              <required>false</required>
            </param>
          </attributes>
        </configuration>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals><goal>generate-configuration</goal></goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <pluginRepositories>
    <pluginRepository>
      <id>qxs.sourceforge.net</id>
      <name>QXS Plugin Repository</name>
      <url>http://downloads.sourceforge.net/project/qxs/m2repo</url>
      <snapshots><enabled>false</enabled></snapshots>
      <releases><updatePolicy>never</updatePolicy></releases>
    </pluginRepository>
  </pluginRepositories>
</project>

Change the configuration according to your needs. Next, generate the configuration class by issueing the following command:

mvn generate-sources

Note that there is usually no need for calling the generate-sources target explicitly, because it is implied by compile. Check out your new configuration class. It contains get and set methods for each attribute, and also some utility methods:

  • load(MapString,String): loads the configuration values from a Map object.
  • load(Reader): loads the configuration from a Properties file.
  • validate(): checks whether the configuration is valid.