Skip to content

Sensitive and Common Data

Geert Bevin edited this page Jul 31, 2024 · 5 revisions

You often have sensitive data like usernames, passwords, keys, ... that are used throughout projects, and that you don't want to commit with your codebase. Other data like global or machine-specific configuration values are also better stored outside your project.

Bld property hierarchy

bld provides access to RIFE2's hierarchical properties infrastructure and allows you to put this sensitive data anywhere in the hierarchy that makes sense to you.

Since bld doesn't execute in a web environment, the property collection hierarchy is different:

   Project Properties
           ↓
Java System Properties
           ↓
[Local Properties File] 
           ↓
 [Bld Properties File] 
           ↓
[Custom Properties File] 
           ↓
  System Env Variables
  • [Local Properties File] is an optional properties file named local.properties that bld will search for in the top-level directory of your project.

  • [Bld Properties File] is another optional properties file name bld.properties that bld will search for in your home directory at $HOME/.bld/bld.properties

  • [Custom Properties File] is a third optional properties file that will be looked for at the location set in the RIFE2_PROPERTIES_FILE environment variable.

Use properties in your project

Once you have set up the properties in any of the locations in the hierarchy, you can easily access them in your project.

For example:

public class MyappBuild extends WebProject {
    public MyappBuild() {
        // ...
        publishOperation()
            .repository(
                repository("https://repo.rife2.com/releases",
                    property("rife2.username"),
                    property("rife2.password")))
            .info()
            .signKey(property("sign.key"))
            .signPassphrase(property("sign.passphrase"));
        // ...
    }
    // public static void main ...
}

Now, imagine that you have set up rife2.username and rife2.password in $HOME/.bld/bld.properties, but that you temporarily want to use different values, then you can for instance use Java system properties to override them:

./bld -Drife2.username=other_user -Drife2.password=other_pass clean publish

RIFE2's hierarchical properties are a really powerful and convenient way to externalize data.


Next learn more about Upgrading

Clone this wiki locally