Class EnvVariablesLoader

java.lang.Object
com.mohamnag.jstatic.plugins.env_var_loader.EnvVariablesLoader
All Implemented Interfaces:
BuildTask

public class EnvVariablesLoader extends Object implements BuildTask
Loads data from environment variables into DataTree's root
invalid reference
DataNode#getData()
.

"JSTATIC_DATA_ROOT__"{field name} will be added to root node's data. To use multi-word field names, separate words with a "_".

For field names only following chars are allowed: A-Z and 0-9

Following values are handled specially (case sensitive):

  • "true" into boolean true
  • "false" into boolean false

Example of conversion between environment variables and roo node fields:

  • "JSTATIC_DATA_ROOT__"ENV=development will be set as data with key env and value development on
    invalid reference
    DataTree#getRootNode()
    's
    invalid reference
    DataNode#getData()
    .
  • "JSTATIC_DATA_ROOT__"SOME_FIELD="the value" will be set as data with key someField and value the value on
    invalid reference
    DataTree#getRootNode()
    's
    invalid reference
    DataNode#getData()
    .

This plugin does not support hot reloading in watch mode and in mostly meant to override specific variables in CI and similar environments.

The functionality of this plugin is intentionally kept simple and limited to data injection into root node.

  • Constructor Details

    • EnvVariablesLoader

      public EnvVariablesLoader()
  • Method Details

    • run

      public void run(BuildContext buildContext)
      Specified by:
      run in interface BuildTask
    • underWatchInputPaths

      public List<Path> underWatchInputPaths()
      Description copied from interface: BuildTask
      If a plugin depends on file input, it shall return list of its input paths to be watched for changes. Paths can be either files or directories. In case of directories, only root path are necessary to be listed and if input path has subdirectories, they will be automatically watched.
      Specified by:
      underWatchInputPaths in interface BuildTask
    • underWatchConfigPaths

      public List<Path> underWatchConfigPaths()
      Description copied from interface: BuildTask
      If a plugin depends on config files in addition to the general config file of the application, like functionality extensions stored in files, it shall return these paths here. A change detected in these paths will result in recreation of the plugin.
      Specified by:
      underWatchConfigPaths in interface BuildTask