Skip to content

Add !include directive support to PropertyFileConfiguration #5253

@aleks-f

Description

@aleks-f

Summary

PropertyFileConfiguration should support !include <path> directive for splitting large properties files into smaller, reusable fragments.

Motivation

As properties files grow, managing all configuration in a single file becomes unwieldy. Common use cases:

  • Separating per-component or per-script configuration into dedicated files
  • Sharing common configuration fragments across multiple deployments
  • Keeping secrets or environment-specific overrides in separate files

Syntax

!include relative/path/to/other.properties
!include /absolute/path/to/other.properties
  • The directive must appear at the start of a line (after optional whitespace)
  • ! was chosen over # because editors are less likely to style it as a comment
  • Relative paths are resolved relative to the directory of the including file
  • Stream-based loads (load(std::istream&)) only support absolute paths (no base directory is known)
  • Includes are processed in-order, inline with the rest of the file
  • Duplicate keys follow the existing last-value-wins rule
  • A missing include file throws Poco::FileException
  • Nested includes are supported

Example

main.properties

app.name = MyApp

!include logging.properties
!include secrets.properties

app.timeout = 30

logging.properties

logging.loggers.root.level = information
logging.channels.file.class = FileChannel
logging.channels.file.path = /var/log/myapp.log

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions