<commit_before># [cfg4j](http://cfg4j.org) sample app (uses **git** as configuration store)
App demonstrating how to access configuration stored in a Git repository using cfg4j library. **Uses multiple configuration files.**

## Usage
```
> cd cfg4j-sample-apps/
> ./gradlew build
> java -jar git-multi-file/build/libs/git-multi-file-1.0.0-SNAPSHOT.jar
```

You can:
* use any git repository: **-DconfigRepoPath=\<repositoryUrl\>** parameter. Both local and remote repos are supported.
* use non-default branch: **-DconfigBranch=\<branchName\>**

```
> java -DconfigRepoPath=/tmp/myRepo.git -DconfigBranch=master -jar git-multi-file/build/libs/git-multi-file-1.0.0-SNAPSHOT.jar
```

## Code snippets

### Configuration beans - see ConfigBeans.java
```java
@Value("${configRepoPath:https://github.com/cfg4j/cfg4j-git-sample-config.git}")
private String configRepoPath; // Run with -DconfigRepoPath=<repositoryUrl> parameter to override

@Value("${configBranch:production-env}")
private String branch; // Run with -DconfigBranch=<branchName> parameter to override

@Bean
public ConfigurationProvider configurationProvider() {
  // Specify which files to load. Configuration from both files will be merged.
  ConfigFilesProvider configFilesProvider = () -> Arrays.asList(new File("application.properties"), new File("otherConfig.properties"));

  // Use Git repository as configuration store
  ConfigurationSource source = new GitConfigurationSourceBuilder()
      .withRepositoryURI(configRepoPath)
      .withConfigFilesProvider(configFilesProvider)
      .build();

  // Select branch to use (use new DefaultEnvironment()) for master
  Environment environment = new ImmutableEnvironment(branch);

  // Reload configuration every 5 seconds<commit_msg>Fix code examples from README.md<commit_after># [cfg4j](http://cfg4j.org) sample app (uses **git** as configuration store)
App demonstrating how to access configuration stored in a Git repository using cfg4j library. **Uses multiple configuration files.**

## Usage
```
> cd cfg4j-sample-apps/
> ./gradlew build
> java -jar git-multi-file/build/libs/git-multi-file-1.0.0-SNAPSHOT.jar
```

You can:
* use any git repository: **-DconfigRepoPath=\<repositoryUrl\>** parameter. Both local and remote repos are supported.
* use non-default branch: **-DconfigBranch=\<branchName\>**

```
> java -DconfigRepoPath=/tmp/myRepo.git -DconfigBranch=master -jar git-multi-file/build/libs/git-multi-file-1.0.0-SNAPSHOT.jar
```

## Code snippets

### Configuration beans - see ConfigBeans.java
```java
@Value("${configRepoPath:https://github.com/cfg4j/cfg4j-git-sample-config.git}")
private String configRepoPath; // Run with -DconfigRepoPath=<repositoryUrl> parameter to override

@Value("${configBranch:production-env}")
private String branch; // Run with -DconfigBranch=<branchName> parameter to override

@Bean
public ConfigurationProvider configurationProvider() {
  // Specify which files to load. Configuration from both files will be merged.
  ConfigFilesProvider configFilesProvider = () -> Arrays.asList(Paths.get("application.properties"), Paths.get("otherConfig.properties"));

  // Use Git repository as configuration store
  ConfigurationSource source = new GitConfigurationSourceBuilder()
      .withRepositoryURI(configRepoPath)
      .withConfigFilesProvider(configFilesProvider)
      .build();

  // Select branch to use (use new DefaultEnvironment()) for master
  Environment environment = new ImmutableEnvironment(branch);

  // Reload configuration every 5 seconds
{'fraction_non_alphanumeric': 0.1235444476001136, 'fraction_numerical': 0.007384265833570008, 'mean_word_length': 4.989795918367347, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6780743', 'n_tokens_mistral': 1009, 'n_tokens_neox': 1000, 'n_words': 279}