Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Change your config-definition.xml to use a system property (of your choice) instead of the hardcoded name "local.cfg".  The Configuration Definition file itself does allow for variables to be included, but they must be specified in a previous configuration source (in that config-definition.xml) or via a system property. See the Configuration File Documentation for more details.  So, you could simply change your config-definition.xml to use a "dspace.env" system property, and pass "-Ddspace.env=dev" to have it use a [dspace.dir]/config/dev.cfg:

    Code Block
    <!-- Change local.cfg to be ${dspace.env} in your config-definition.xml -->
    <properties fileName="${dspace.env}.cfg" throwExceptionOnMissing="false" config-name="local" config-optional="true">
    ...
    </properties>
    
    <!-- OPTIONALLY: If you wanted to have some default local configs shared among *all* environments, you could add
         a NEW "properties" file to always load those defaults. In this example, default.cfg would be loaded for ALL 
         environments. Configs in the environment-specific ${dspace.env}.cfg would override default.cfg, and
         both would override dspace.cfg (and other *.cfg). -->
    <properties fileName="default.cfg" throwExceptionOnMissing="false" config-name="default" config-optional="true">
    ...
    </properties>
  2. Alternatively, you could use the "include=" option (of Apache Commons Configuration Properties Files) within your local.cfg file to load a different configuration file, again based on a setting specified as a system property. For example, your local.cfg file would ONLY consist of "include=" statement(s), which would load whichever configuration file was specified as the "dspace.env" system property:

    Code Block
    # This is the ENTIRE local.cfg (all settings would instead be located in environment-specific config files)
    # Its job is just to load up the configuration for the environment specified by "dspace.env"
    # For example, -Ddspace.env=dev would load [dspace.dir]/config/dev.cfg
    #         and  -Ddspace.env=prod would load [dspace.dir]/config/prod.cfg
    
    # Load the environment-specific file
    include = ${dspace.env}.cfg
    
    # OPTIONALLY: If you wanted to have some default local configs shared among *all* environments, you could add 
    # a second "include=" statement to always load those defaults from a file of your choice. In this example, 
    # a default.cfg would be loaded for ALL environments. Configs in the environment-specific ${dspace.env}.cfg 
    # would override default.cfg, and both would override dspace.cfg (and other *.cfg).
    include = default.cfg
Info

While the above examples both use a property named ${dspace.env}, you can use whatever property you want. The name itself doesn't matter.  Additionally, both show examples of using a "default.cfg" to specify properties which are shared between several environments. This file can also be named whatever you want. Just tweak the name(s) in the examples above to meet your local needs.

The option you choose above would likely depend on your own local practices/needs. Either of these options should work, provided that you place your environment-specific configuration files within the [dspace.dir]/config directory alongside the local.cfg file.

...