tscfg Maven Plugin

Maven plugin that generates the boiler-plate Java code for a Typesafe Config properties file using tscfg.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.timvlaer
ArtifactId

ArtifactId

tscfg-maven-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

tscfg Maven Plugin
Maven plugin that generates the boiler-plate Java code for a Typesafe Config properties file using tscfg.
Project URL

Project URL

https://github.com/timvlaer/tscfg-maven-plugin
Source Code Management

Source Code Management

https://github.com/timvlaer/tscfg-maven-plugin

Download tscfg-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.timvlaer</groupId>
    <artifactId>tscfg-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

Dependencies

compile (1)

Group / Artifact Type Version
com.github.carueda : tscfg_2.13 jar 0.9.981

provided (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.6.3
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5.2
org.apache.maven : maven-project jar 2.2.1

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 2.21.0
org.assertj : assertj-core jar 3.10.0
org.apache.maven : maven-core jar 3.6.3
org.apache.maven.shared : maven-verifier jar 1.6

Project Modules

There are no modules declared in this project.

Build Status PRs Welcome Maven Central

tscfg-maven-plugin

Maven plugin that generates the boiler-plate for a Typesafe Config properties file using the excellent tscfg library by @carueda.

This plugin takes a configuration file (templateFile) and generates objects to hold your configuration.

Usage

<plugin>
    <groupId>com.github.timvlaer</groupId>
    <artifactId>tscfg-maven-plugin</artifactId>
    <version>1.0.0</version>
    <configuration>
        <templateFile>config-spec/service.spec.conf</templateFile>
        <packageName>com.sentiance.service.config</packageName>
        <className>ServiceConfig</className>
        <generateGetters>true</generateGetters>
        <useOptionals>false</useOptionals>
        <useDurations>true</useDurations>
    </configuration>
     <executions>
        <execution>
            <id>tscfg-sources</id>
            <goals>
                <goal>generate-config-class</goal>
            </goals>
        </execution>
    </executions>
</plugin>

To compile the generated code, add the Lightbend Config dependency to your project:

<dependency>
    <groupId>com.typesafe</groupId>
    <artifactId>config</artifactId>
    <version>1.3.4</version>
</dependency>

Configuration

  • templateFile: typesafe configuration template file
  • className: the name of the generated config class
  • packageName: the package of the generated config class
  • outputDirectory: the output directory for the generated class, default is target/generated-sources/tscfg/
  • generateGetters: (true|false) generate getters for configuration
  • useOptionals: (true|false) use java8 Optional object for optional fields
  • useDurations: (true|false) if true, properties of type duration will be of type java.time.Duration in the generated code. If false, it will be a long.
  • allRequired: (true|false) if true, optional tags are ignored and every property in the config file is required. Defaults to false.

Current limitations

  • This plugin currently only generates Java code.
  • This plugin always generates java classes for Java 8 and above. Open a ticket or PR if you'd like to change the above.

Build the plugin yourself

  • git clone https://github.com/timvlaer/tscfg-maven-plugin.git
  • cd tscfg-maven-plugin
  • Update the <version> in the pom.xml file, e.g. 2.0.0-custom-SNAPSHOT
  • mvn clean install
  • Configure your project's pom to depend on your version of the plugin (e.g. 2.0.0-custom-SNAPSHOT.)

Versions

Version
1.0.0
1.0.0-rc1
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.4.0
0.3.0
0.2.0