A Gradle Plugin to download Google Sheets as CSV files.
- You can download multiple sheets at once so that you can include some data in your build process.
- You have to set up a google service account and create application credential key in Google Cloud Console.
- Then, you have to share the Google Sheet with the service account email.
- You can set GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your application credential file. Otherwise, you can set the path in the plugin configuration.
For more details about Google Sheets API, see Google Sheets API.
Find the example folder for a working example.
You can run the task with the following command:
./gradlew gsheetDownload
build.gradle.kts
import com.vrerv.gradle.plugin.gsheet.download.DownloadConfig
plugins {
id("com.vrerv.gradle.plugin.gsheet.download")
}
gsheetDownloadConfig {
// googleApplicationCredentials = "path/to/your/service-account-key.json"
downloads.set(
listOf(
DownloadConfig(
sheetId = "1SVp5gkj-aHZCxfSLKLIzGKyJOY5Tzadqo-_TFuxGBOg",
sheetName = "Sheet1",
rangeFrom = "A1",
rangeTo = "H1000",
outputFileName = "test.csv",
),
),
)
outputDir = file("build")
}
build.gradle
import com.vrerv.gradle.plugin.gsheet.download.DownloadConfig
plugins {
id "com.vrerv.gradle.plugin.gsheet.download"
}
gsheetDownloadConfig {
// googleApplicationCredentials = "path/to/your/service-account-key.json"
downloads = [
new DownloadConfig(
"1SVp5gkj-aHZCxfSLKLIzGKyJOY5Tzadqo-_TFuxGBOg",
"Sheet1",
"A1",
"H1000",
"test.csv",
)
]
outputDir = file("build")
}
Feel free to open a issue or submit a pull request for any bugs/improvements.
This plugin is licensed under the MIT License - see the License file for details. Please note that the generated template is offering to start with a MIT license but you can change it to whatever you wish, as long as you attribute under the MIT terms that you're using the template.