https://github.com/anod/ksp-dotenv
Gradle multiplatform KSP plugin to generate code from .env file
https://github.com/anod/ksp-dotenv
gradle kotlin-ksp kotlin-multiplatform
Last synced: 15 days ago
JSON representation
Gradle multiplatform KSP plugin to generate code from .env file
- Host: GitHub
- URL: https://github.com/anod/ksp-dotenv
- Owner: anod
- License: mit
- Created: 2023-08-11T12:43:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-12T09:09:32.000Z (almost 2 years ago)
- Last Synced: 2025-04-28T13:12:44.638Z (2 months ago)
- Topics: gradle, kotlin-ksp, kotlin-multiplatform
- Language: Kotlin
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ksp-dotenv
Gradle KSP Multiplatform plugin to generate code from .env file# Example
`./gradlew example:run`
# Setup
1. Include [com.google.devtools.ksp](https://kotlinlang.org/docs/ksp-quickstart.html) in case it wasn't in the project yet
2. Add GitHup package repository following instructions https://github.com/anod/ksp-dotenv/packages/1921207
3. Add dependencies to build.gradle.kts
```kotlin
dependencies {
add("kspCommonMainMetadata", "info.anodsplace.dotenv:ksp-dotenv-jvm:$kspDotenvVersion")
add("kspJvm", project("info.anodsplace.dotenv:ksp-dotenv-jvm:$kspDotenvVersion"))
}
```
4. Configure the plugin inside build.gradle.kts
````
ksp {
arg("info.anodsplace.dotenv.path", project.rootDir.toString())
arg("info.anodsplace.dotenv.filename", "env.example") // default ".env"
arg("info.anodsplace.dotenv.allowedKeys", "ENDPOINT*;ENV") // list separated by ';', supports '*','?' pattern
arg("info.anodsplace.dotenv.camelCase", "true")
arg("info.anodsplace.dotenv.package", "info.anodsplace.dotenv.generated")
arg("info.anodsplace.dotenv.class", "DotEnvExample")
}
```
5. Build & use generated file
```kotlin
println("[ksp-dotenv] ENDPOINT_FE=${DotEnvExample.endpointFe}")
println("[ksp-dotenv] ENDPOINT_BE=${DotEnvExample.endpointBe}")
println("[ksp-dotenv] ENV=${DotEnvExample.env}")
```
# Publish`./gradlew publish`
# Author
Alexandr Gavrishev, 2023