Here is the code curl to download file in github private repo
def command = "curl -s -O https://[email protected]/myGitHubAccount/myrepo/master/app/src/main/res/values/colors.xml"
task myCurlTask(){
command.execute()
When I execute it the output file place in my root project directory. I want to execute it and put the file in my res/values folder of my android project.
How can I do that? And How to write that code in gradle.kts?
CodePudding user response:
Finally I found
tasks.register("downloadColorsFromPrivateRepo") {
val destinationPath = "${project.projectDir}/src/main/res/values/colors.xml"
val githubPrivateRepoToken = "myToken"
val command = "curl -o $destinationPath https://${githubPrivateRepoToken}@raw.githubusercontent.com/myGitHubAccount/myrepo/master/app/src/main/res/values/colors.xml"
Runtime.getRuntime().exec(command)
}
CodePudding user response:
Gradle build files are written in a language called Groovy. You might consider looking for how to make an HTTP request and write the response to a file with this language directly rather than executing an external command.