Gradle download file if not exist






















Thanks for sharing. I just bumped into this. Using Internal and FileTree works well but it breaks the chaining of dependencies when wiring outputs to inputs.

I had to manually make the consumer Task depend on the producer task. Having a first-party API for single files would be nice. Skip to content. Star New issue. Jump to bottom. Labels a:feature in:core. Copy link. Test coverage and fixes for a bunch of gradle-native issues If the source file doesn't exist, we should do something like: Don't run the task's actions. Set the task's outcome to 'not required' Remove the outputs from previous executions of the task.

Can you do this while configuring your task? That's why I think it would be useful for Gradle to support this with a single file. Custom snapshot API Note that this way, the test is done at initialization. This means: also a second clean will fail if the first clean removed the file.

Unfortunately, putting it to doFirst is also not an option because this is not executed if the file doesn't exist gradle 4. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown. The Overflow Blog. Who owns this outage? Building intelligent escalation chains for modern SRE. Podcast Who is building clouds for the independent developer? Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. By default, the plugin always performs a download even if the destination file already exists. If you want to prevent files from being downloaded again, use the overwrite flag see description below.

As an alternative to the Download task, you may also use the download extension to retrieve a file anywhere in your build script:. If you need to run the plugin with Gradle 1.

Note that this feature depends on the server and whether it supports the If-Modified-Since request header and provides a Last-Modified timestamp in its response. Please note that you have to specify a directory as destination if you download multiple files. Otherwise, the plugin will fail. If you want to download all files from a directory and the server provides a simple directory listing, you can use the following code:.

Please have a look at the examples directory for more code samples. You can also read my blog post about common recipes for gradle-download-task. You may provide Groovy Closures to the src and dest properties to calculate their value at runtime. The plugin also provides a Verify task that can be used to check the integrity of a downloaded file by calculating its checksum and comparing it to a pre-defined value.

The task succeeds if the file's checksum equals the given value and fails if it doesn't. You can configure a proxy server by setting standard JVM system properties. The plugin uses the same system properties as Gradle.



0コメント

  • 1000 / 1000