guys, help me, please.
I defined a task type into my build.gradle
:
class BumpFrontendVersionTask extends DefaultTask {
@Internal String jsonFilePath
@TaskAction
void bumpFrontendVersion() {
def packageJsonPath = new File(jsonFilePath as String)
def parsedPackageJson = new JsonSlurper().parse(packageJsonPath)
parsedPackageJson.version = Optional.ofNullable(System.getenv('RELEASE_VERSION')).orElseGet { '0.0.0' }
def packageJson = new JsonBuilder(parsedPackageJson).toPrettyString()
def fileWriter = new FileWriter(packageJsonPath)
fileWriter.write(packageJson)
fileWriter.close()
}
}
Also I made a custom task:
tasks.register('bumpFrontendVersion', BumpFrontendVersionTask) {
description 'Task bumps frontend version with environment variable value'
jsonFilePath 'frontend/package.json'
jsonFilePath 'frontend/package-lock.json'
}
When I call this task bumpFrontendVersion
it processes only 1 file (last one).
What shall I change in my code to launch my task type twice from one custom task?