Skip to content

Commit

Permalink
Add .env variables to build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
pouryafard75 committed Jun 25, 2024
1 parent 2a80d33 commit 2b49a64
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,30 @@ test {
useJUnitPlatform()
}

def loadEnvFile() {
def envFile = file('.env')
if (envFile.exists()) {
envFile.eachLine { line ->
if (!line.startsWith("#") && line.contains("=")) {
def (key, value) = line.split("=")
project.ext.set(key.trim(), value.trim())
}
}
}
}

// Load the .env file
loadEnvFile()
run {
def refactoringMinerPathValue = System.properties['refactoringMinerPath']
if (refactoringMinerPathValue && !refactoringMinerPathValue.isEmpty()) {
systemProperty("refactoringMinerPath", refactoringMinerPathValue)
}
doFirst {
project.ext.properties.each { key, value ->
if (key != 'ext') {
environment key, value
}
}
}
}

0 comments on commit 2b49a64

Please sign in to comment.