{"id":19587199,"url":"https://github.com/leocolman/simpleproperties","last_synced_at":"2025-04-27T12:31:27.880Z","repository":{"id":57725878,"uuid":"180673121","full_name":"LeoColman/SimpleProperties","owner":"LeoColman","description":"Simple to use Property Library that allows multiple profiles to be configured and used with ease. This mimics the behavior of profiles from Spring, and is easy for those that are used to it.","archived":false,"fork":false,"pushed_at":"2023-12-15T05:32:37.000Z","size":70,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-01T16:48:51.090Z","etag":null,"topics":["configuration","hacktoberfest","kotlin","profile","properties","property","spring"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeoColman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-10T22:26:16.000Z","updated_at":"2024-05-01T16:48:51.091Z","dependencies_parsed_at":"2023-01-22T02:07:01.702Z","dependency_job_id":null,"html_url":"https://github.com/LeoColman/SimpleProperties","commit_stats":null,"previous_names":["kerooker/simpleproperties"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoColman%2FSimpleProperties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoColman%2FSimpleProperties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoColman%2FSimpleProperties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeoColman%2FSimpleProperties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeoColman","download_url":"https://codeload.github.com/LeoColman/SimpleProperties/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224069488,"owners_count":17250456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","hacktoberfest","kotlin","profile","properties","property","spring"],"created_at":"2024-11-11T08:02:24.676Z","updated_at":"2024-11-11T08:02:25.631Z","avatar_url":"https://github.com/LeoColman.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Simple Properties\n\n\n[![Build Status](https://travis-ci.com/LeoColman/SimpleProperties.svg?branch=master)](https://travis-ci.com/LeoColman/SimpleProperties) [![GitHub](https://img.shields.io/github/license/LeoColman/SimpleProperties.svg)](https://github.com/Kerooker/SimpleProperties/blob/master/LICENSE) [![Maven Central](https://img.shields.io/maven-central/v/com.kerooker.simpleproperties/simple-properties.svg)](https://search.maven.org/search?q=g:com.kerooker.simpleproperties)\n\n## Introduction\n\nAplications might behave differently in different environments. One might have a specific configuration for Production Environment, which is different from Development Environment. \n\nWith simple properties, you can configure a different profile of properties for each of your environments, and access them through an easy to use DSL.\n\nThis library was inspired and is very similar to [**Spring Profiles**](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html), but only for Properties, and in a simpler way.\n\n## Adding to your project\nEdit your `build.gradle` to contain the following dependency, from Maven Central:\n\n```\nimplementation(\"com.kerooker.simpleproperties:simple-properties:{currentVersion}\")\n```\n\n## Usage Example\n\n```kotlin\n\nobject MySystemProperties {\n\n    private val simpleProperties = SimpleProperties()\n    \n    val databaseUrl: String = simpleProperties[\"my.database.url\"]\n\n}\n\n```\n\n| File | Value of \"my.database.url\" |\n| --- | --- |\n| application-local.properties | localhost:3306 |\n| application-qa.properties | qa.database.server.intranet:3306 |\n| application-prod.properties | prod.database.server.intranet:7725 | \n\n\nLaunching app:\n\nWith local profile:\n\n`java -jar myapp.jar -Dactive_profiles=local`\n\n```kotlin\nMySystemProperties.databaseUrl == \"localhost:3306\"\n```\n\nWith production profile:\n`java -jar myapp.jar -Dactive_profiles=prod`\n```kotlin\nMySystemProperties.databaseUrl == \"prod.database.server.intranet:7725\"\n```\n\n## Default profile\n\nSimpleProperties will always try to read an optional default file `application.properties`. Any profile may override properties from the default file.\n\n## Configuring profiles\n\nSimpleProperties will try to find your profiles in some places:\n\n1. System Environment Variables\n2. Java Properties\n3. Defined at instantiation\n    1. `SimpleProperties(profiles = listOf(\"qa\"))`\n    \n## More than one profile\n\nMultiple profiles may be used at once, in a comma separated value in case of System (`-Dactive_profiles=foo,bar,baz`).\n\nIf keys are overriden, the last profile in the list will take priority.\n\n## Where to place files\n\nFiles are expected to be in the classpath. In `Spring`, this is usually done by placing the file in the `resources` folder, and this is allowed in Simple Properties too:\n\n```\nMyProject\n`-- src\n    `-- main\n        |-- kotlin\n        |   |-- Foo.kt\n        |   `-- Bar.kt\n        `-- resources\n            |-- application.properties\n            |-- application-foo.properties\n            `-- application-bar.properties\n```\n\n\nYou can customize where your files will be placed when creating the `SimpleProperties` instance:\n\n```kotlin\nSimpleProperties(filesLocation = \"foo/bar\")\n```\n\nWhich allows for example the structure\n```\nMyProject\n`-- resources\n    `-- foo\n        `-- bar\n            |-- application.properties\n            `-- application-foo.properties\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocolman%2Fsimpleproperties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleocolman%2Fsimpleproperties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocolman%2Fsimpleproperties/lists"}