0

Need some help with writing the gradle dependices to download a single file from github repository

We have a scenario where we need to download .yaml file from the github repository so that we can use it further to autogenerarte it . How do I download a single file form github report via gradle

elect
  • 6,765
  • 10
  • 53
  • 119
Swati Jha
  • 33
  • 1
  • 2
  • 7
  • A `build.gradle` file is basically just Groovy. You can use there what the language provides. Alternatively you could try to find a plugin that does it. – Henry Feb 19 '19 at 12:26
  • Hi Henry, I m very new to Gradle dont have any idea how to do this – Swati Jha Feb 19 '19 at 12:43
  • Possible duplicate of [how to download external files in gradle?](https://stackoverflow.com/questions/17123606/how-to-download-external-files-in-gradle) – Henry Feb 19 '19 at 12:46

1 Answers1

0

The best option, if you have freedom to change the source project, is for the yaml to be built, versioned and published to a repository. Eg packed inside a zip/jar in nexus. You could then get the zip/jar in Gradle similar to any other dependency then unpack the yaml file.

Failing that there's a couple of options with github

  1. Download via http (see download plugin)
  2. Get using git (see gradle-git plugin)
lance-java
  • 25,497
  • 4
  • 59
  • 101
  • Can some please help me understand where is it I m going wrong ? – Swati Jha Feb 22 '19 at 08:01
  • My file SimpleTask.gradle looks like this `buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "de.undercouch:gradle-download-task:3.4.3" } } apply plugin: "de.undercouch.download" task downloadFile(type: Download) { src 'https://github.com/qlik-trial/qix-data-reload/blob/master/api-docs.yml' dest 'Artifactory' }` – Swati Jha Feb 22 '19 at 08:01
  • `gradlew.bat -b simpleTask.gradle downloadFile --no-daemon --refresh-dependencies --stacktrace --warning-mode all` – Swati Jha Feb 22 '19 at 08:01
  • It is downloadin me all other files but nothing from github – Swati Jha Feb 22 '19 at 11:32