Skip to content

Martini Package Properties

Overview

Martini's package properties are essential for storing configuration values unique to each package. This feature is beneficial for persisting values, like API access keys or specific settings, within an individual package.

Defining Package Properties

Location and Structure

You can find package properties within the conf/properties directory of a package:

1
2
3
4
├── conf
│   ├── properties
│   │   └── package.properties
...

Custom Naming for Property Files

The naming convention for property files can be adjusted using the package.properties.prefix in the application properties. Setting a prefix, such as develop, would look for develop.package.properties instead of the standard package.properties. This is useful for handling properties in various environments or for different development teams.

Immediate Reflection of Changes

Modifications to package properties take effect instantly if the package.properties.reload-strategy is configured to always-check.

Note: If .properties files do not exist, they should be manually created in the conf/properties directory.

Property Merging

Martini merges properties following the package dependency hierarchy.

Example Scenario

  • petclinic-demo depends on the petclinic package.
  • petclinic declares:
1
petclinic.petstore-url=https://petstore.swagger.io

In petclinic-demo, this URL is the resolved value. Overriding it in petclinic-demo would change the resolved value.

Properties not found within the package are inherited from the global application properties.

Modifying Properties via Martini's User Interface

To modify package properties:

  1. Navigate to the Navigator view.
  2. Locate and expand your package, then open the conf directory.
  3. Open the .properties file to make edits.
  4. Add, change, or remove key-value pairs as needed.

Tip: In Martini Desktop, you can quickly find .properties files using the Open Resource dialog.

Managing Properties Programmatically

Martini's classloader includes a Groovy extension module with methods for managing package properties.

Adding or Changing Properties

1
'key'.savePackageProperty('value')

Removing Properties

1
'key'.removePackageProperty()

Retrieving Property Values

1
2
3
4
'key'.getPackageProperty() // For a single property
'key'.getPackageProperty('default-value') // With a default value
'key'.getPackagePropertyArray() // To fetch an array of values
'key'.getPackagePropertyArray(['default-value-one', 'default-value-two']) // Array with default values

These methods are specific to the package containing the script.