Git Product home page Git Product logo

maven-flexiconf's Introduction

Secure, Flexible and Scalable Build Configuration with Maven

Maven project example accompanying article Secure, Flexible and Scalable Build Configuration with Maven

Prerequisites

  • Maven 3+
  • Java 1.8+

Instructions

1) Setup "local" profile

Before building the project you must configure local profile, which is active by default. An example Filter File SAMPLE-local.properties is provided as a template:

  • create a folder for application logs on your local file system, e.g.:
    • Linux/Unix-like: /var/logs/maven-flexiconf
    • Windows: C:/logs/maven-flexiconf
  • open configuration/SAMPLE-local.properties
  • copy and rename it local.properties
  • in local.properties set the values of the following properties according to the folder you created above:
    • log.path
    • log.rolled.path

In .gitignore there's an entry for the local filter file you created (configuration/local.properties), so it cannot be committed to the repository. This way you safely modify it, putting in it local paths, passwords, etc. without worrying that sensitive data will be pushed to the repository.

2) Build application

Default Build

Build command:

mvn package

As the default active profile is local, executing this build command will use properties from configuration/local.properties. The result of the build is a jar with its dependencies:

target/maven-flexiconf-jar-with-dependencies.jar

Production Build

To run a production build you need to activate the prod profile.

To simulate an actual production build you should provide informations (especially sensitive ones) on the command line, leaving configuration/prod.properties untouched.

Here's an example command (make sure to copy it on a single line):

mvn package -Pprod "-Djdbc.url=jdbc:mysql://prod.example.org:3306/maven-flexiconf" \
  "-Djdbc.username=prod-user" \
  "-Djdbc.password=prod-password"
  "-Dlog.path=/var/logs/my-application" \
  "-Dlog.rolled.path=/var/logs/my-application/rolled"

3) Run application

On Unix/Linux/Mac:

java -jar target/maven-flexiconf-jar-with-dependencies.jar

On Windows:

java -jar .\target\maven-flexiconf-jar-with-dependencies.jar

After running the application you will find a maven-flexiconf.log log file in the directory you created in Step 1.

4) Experiment!

Run different build profiles

  • do a local build and run the application
  • run a prod build and run the application
  • check the difference in log files

Create new build profiles

Try creating a new build profile, e.g. qa (Quality Assurance) or integration, overriding files in src/main/resources-override and putting properties in correct filter files.

Remember: security is a top priority. Try to understand why preventing sensitive data to leak in Git repository is important and how to ensure it.

maven-flexiconf's People

Contributors

megadix avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.