Skip to content

PropMe: Simplify and Automate Java file generation from properties effortlessly!

Notifications You must be signed in to change notification settings

rikkarth/propme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

PropMe is a lightweight application designed to automate the generation of .java files, mapping them to all fields from your .properties configuration file.

This application emerged from a real-world scenario where a comprehensive configuration setup required mapping all fields from a configuration file to a constants Java class for subsequent validation.

Source

#.properties configuration file
db.url=jdbc:mysql://localhost:3306/mydatabase
db.username=root
db.password=password
db.connection.pool.size=10

# Server configuration
server.port=8080
server.host=localhost
server.contextPath=/myapp

Result

public class MyConfigConstants {
    static final String DB_URL = "db.url";
    static final String DB_USERNAME = "db.username";
    static final String DB_PASSWORD = "db.password";
    static final String DB_CONNECTION_POOL_SIZE = "db.connection.pool.size";
    static final String SERVER_PORT = "server.port";
    static final String SERVER_HOST = "server.host";
    static final String SERVER_CONTEXTPATH = "server.contextPath";
}

Download

propme.jar

Installation

To run PropMe you just need to have minimum Java 8 installed, download propme.jar and run it as instructed bellow.

How to run

java -jar propme.jar path/to/source/config.properties path/to/target/folder/

Additional Information

Currently the name of the output file is MyConfigConstants.java.

This will change in the future and it will be configurable.

More features will be introduced.