Gradle plugin for Chamaleon
plugins {
id("io.github.gerardorodriguezdev.chamaleon") version "xxx" // Latest release version
}
This plugin is hosted on the Gradle Plugins Portal
Create a directory named environments
in the root of your project and create the following empty files:
myProject --> The root of your project
environments --> The directory you created
properties.chamaleon.json
template.chamaleon.json
local.environment.chamaleon.json
You can see a sample on Sample Gradle Project
The json schemas for this files have been uploaded to Schema store so you can see hints if the schema is valid or not and have auto-completions as well. Alternatively you can find them here Schemas
This file will be used to select an environment. In this case local
{
"selectedEnvironmentName": "local"
}
This file will be used only to validate that all the environments have the same structure
{
"supportedPlatforms": [
"android"
],
"propertyDefinitions": [
{
"name": "HOST",
"propertyType": "String",
"nullable": false
}
]
}
- supportedPlatforms: Can be one or all the supported platforms
(android, wasm, ios, jvm)
- propertyDefinitions: It's an array of property definition
- propertyDefinition:
- name: The name of your property (cannot be an empty string) ->
required
- propertyType: Can be
String
orBoolean
->required
- nullable: If the property is
nullable
or not (default=false)->optional
- name: The name of your property (cannot be an empty string) ->
- propertyDefinition:
This file is your first environment. Any json file with this suffix .environment.chamaleon.json
inside the
environments
directory will be considered an environment. You can have as many as you want
[
{
"platformType": "android",
"properties": [
{
"name": "HOST",
"value": "localhost"
}
]
}
]
- platformType: Can be any of the supported platforms
(android, wasm, ios, jvm)
->required
- properties: It's an array of property
- property:
- name: The name of your property (cannot be an empty string) ->
required
- value: The value of your property. Can be
String
,Boolean
ornull
->optional
if it's nullable otherwiserequired
- name: The name of your property (cannot be an empty string) ->
- property:
Now that you have applied the plugin and added the required files you should be able to do this on the
build.gradle.kts
chamaleon.selectedEnvironmentName // The currently selectedEnvironmentName
chamaleon.environments // All the defined environments. You can search for one in particular or see it's properties