Giter Site home page Giter Site logo

rakus / properties-constants-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 206 KB

Maven plugin to create Java constants for properties keys

Home Page: https://rakus.github.io/properties-constants-maven-plugin/

License: Apache License 2.0

Java 94.35% FreeMarker 5.65%
code-generation maven maven-plugin properties-file

properties-constants-maven-plugin's Introduction

Properties Constants Creator Maven Plugin

Maven plugin that creates Java constants for properties files.

Example

For this example the following properties file src/main/resources/messages.properties is assumed.

welcome.user=Hello user
goodby.user=Have a nice day

The plugin is configure with the mandatory option <basePackage>:

<plugin>
    <groupId>de.r3s6.maven</groupId>
    <artifactId>properties-constants-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>example</id>
            <configuration>
                <basePackage>de.r3s6.maven.example</basePackage>
            </configuration>
        </execution>
    </executions>
</plugin>

This results in the Java class Messages:

package de.r3s6.maven.example;

/**
 * Constants for messages.properties
 * <p>
 * The constant values are the keys to access the properties.
 *
 * @author properties-constants-maven-plugin
 */
public final class Messages {

    /**
     * Properties file used to generate this class: "messages.properties".
     */
    public static final String PROPERTIES_FILE_NAME = "messages.properties";

    /**
     * Key of welcome.user=Hello user
     */
    public static final String WELCOME_USER = "welcome.user";

    /**
     * Key of goodby.user=Have a nice day
     */
    public static final String GOODBY_USER = "goodby.user";

    /** Hidden constructor. */
    private Messages() {
        // nothing to instantiate
    }

}

The exact content of the generated class depends on the chosen code template and configuration.

BTW: It is also possible to use a custom Freemarker template.

Build

Full build with:

mvn clean install site -Pit,coverage

This builds the plugin, runs integration tests with coverage analysis, installs the plugin to your local repo and finally builds the documentation web site.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.