Docs
Declarations
Examples
Combine resources

Combining Resources

You can generate arbitrary files or parameter files from multiple resource files. This can be useful for configuring your applications based on the compatibilities of your targets.

Basics

Let's start with the simplest by combining texts. To combine text files, you need to declare the source files one after the other with a pipe delimiter |. Here's a concrete example to combine 3 parameter files into a single parameter file.

    • .aiop
      • .aml
      • param1.txt
      • param2.txt
      • param3.txt
  • resources/.aml
    - source: param1.txt | param2.txt | param3.txt
      destination: param.txt
      compatibility:
        - ...

    The param.txt file generated in the package will be the combination of the param1.txt, param2.txt, and param3.txt files.

    Combining Parameters

    Now let's see how to combine parameter files. Here we'll see how to combine files of the following formats:

    ⚠️

    Note

    It is currently impossible to convert one parameter file to another.

    Combining yaml or yml

    The declaration is the same except that you declare YAML or YML configuration files here. Here's an example of combining YAML or YML configuration files.

    • .aiop
      • .aml
      • param1.yaml
      • param2.yaml
      • param3.yml
      • param4.yml
  • We will here combine the parameter files param1.yaml, param2.yaml together as well as param3.yml and param4.yml. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.yaml | param2.yaml
      destination: param.yaml
      compatibility:
        - ...
     
    - source: param3.yml | param4.yml
      destination: param.yml
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.yaml, param2.yaml), then combines the fields and writes to the destination file (param.yaml) by sorting the keys alphabetically.

    For example, if param1.yaml contains:

    param1.yaml
    version:
      major: 1
      minor: 0
    name: aiop

    and param2.yaml contains:

    param2.yaml
    version:
      patch: 0

    then the destination file param.yaml will contain:

    param.yaml
    name: aiop
    version:
      major: 1
      minor: 0
      patch: 0

    The keys are sorted alphabetically and the version fields are combined.

    Combining json

    Here's an example of combining JSON configuration files.

    • .aiop
      • .aml
      • param1.json
      • param2.json
  • We will here combine the parameter files param1.json, param2.json. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.json | param2.json
      destination: param.json
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.json, param2.json), then combines the fields and writes to the destination file (param.json) by sorting the keys alphabetically.

    For example, if param1.json contains:

    param1.json
    {
      "version": {
        "major": 1,
        "minor": 0
      },
      "name" : "aiop"
    }

    and param2.json contains:

    param2.json
    {
      "version": {
        "patch": 0
      }
    }

    then the destination file param.json will contain:

    param.json
    {
      "name": "aiop",
      "version": {
        "major": 1,
        "minor": 0,
        "patch": 0
      }
    }

    Combining xml

    Here's an example of combining XML configuration files.

      • .aml
      • param1.xml
      • param2.xml
  • We will here combine the parameter files param1.xml, param2.xml. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.xml | param2.xml
      destination: param.xml
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.xml, param2.xml), then combines the fields and writes to the destination file (param.xml) by sorting the keys alphabetically.

    For example, if param1.xml contains:

    param1.xml
    </version>
      <major>1</major>
      <minor>0</minor>
    </version>
    <name>aiop</name>

    and param2.xml contains:

    param2.xml
    <version>
      <patch>0</patch>

    then the destination file param.xml will contain:

    param.xml
    <name>aiop</name>
    <version>
      <major>1</major>
      <minor>0</minor>
      <patch>0</patch>

    Combining ini

    Here's an example of combining INI configuration files.

    • .aiop
      • .aml
      • param1.ini
      • param2.ini
  • We will here combine the parameter files param1.ini, param2.ini. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.ini | param2.ini
      destination: param.ini
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.ini, param2.ini), then combines the fields and writes to the destination file (param.ini) by sorting the keys alphabetically.

    For example, if param1.ini contains:

    param1.ini
    [version]
    major = 1
    minor = 0
     
    [name]
    value = aiop

    and param2.ini contains:

    param2.ini
    [version]
    patch = 0

    then the destination file param.ini will contain:

    param.ini
    [name]
    value = aiop
     
    [version]
    major = 1
    minor = 0
    patch = 0

    Combining toml

    Here's an example of combining TOML configuration files.

    • .aiop
      • .aml
      • param1.toml
      • param2.toml
  • We will here combine the parameter files param1.toml, param2.toml. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.toml | param2.toml
      destination: param.toml
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.toml, param2.toml), then combines the fields and writes to the destination file (param.toml) by sorting the keys alphabetically.

    For example, if param1.toml contains:

    param1.toml
    [version]
    major = 1
    minor = 0
     
    [name]
    value = aiop

    and param2.toml contains:

    param2.toml
    [version]
    patch = 0

    then the destination file param.toml will contain:

    param.toml
    [name]
    value = aiop
     
    [version]
    major = 1
    minor = 0
    patch = 0

    Combining plist

    Here's an example of combining PLIST configuration files.

    • .aiop
      • .aml
      • param1.plist
      • param2.plist
  • We will here combine the parameter files param1.plist, param2.plist. Here's how it looks in the resource file.

    resources/.aml
    - source: param1.plist | param2.plist
      destination: param.plist
      compatibility:
        - ...

    AIOP reads the parameter files in the order of declaration (param1.plist, param2.plist), then combines the fields and writes to the destination file (param.plist) by sorting the keys alphabetically.

    For example, if param1.plist contains:

    param1.plist
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>version</key>
        <dict>
            <key>major</key>
            <integer>1</integer>
            <
     
    key>minor</key>
            <integer>0</integer>
        </dict>
        <key>name</key>
        <string>aiop</string>
    </dict>
    </plist>
     

    and param2.plist contains:

    param2.plist
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>version</key>
        <dict>
            <key>patch</key>
            <integer>0</integer>
        </dict>
    </dict>
    </plist>
     

    then the destination file param.plist will contain:

    param.plist
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>name</key>
        <string>aiop</string>
        <key>version</key>
        <dict>
            <key>major</key>
            <integer>1</integer>
            <key>minor</key>
            <integer>0</integer>
            <key>patch</key>
            <integer>0</integer>
        </dict>
    </dict>
    </plist>

    Other Files

    Any other type of file can be combined in the same manner. The only difference will be that the files will be simply concatenated without line breaks or separators.