How to handle exception in a Gradle task

Hi
In my build, I have a task that is dedicated to uploading files to our Nexus Repository. In some cases, these files may already be present and this leads to HTTP errors. These errors cause the build to fail.
My need is to have a build which do not fail in this case, but continues its execution.
How can I acheive that? If the catch of the exception is the only way, how to do that in build scripts written in Kotlin?

Thanks in advance
Éric

Hi
In my case, the plugin I’m using (Gradle Download Task from M. KREMER) provides an extension with a run method which can be called like this:

task myTask {
    doLast {
        // do something ...
        // ... then download a file
        download.run {
            src 'http://www.example.com/index.html'
            dest buildDir
            overwrite false
        }
        // ... do something else
    }
}

Then my problem has been solved surrounding this use with a try ... catch block:

    doLast {
        try {
            // (...)
            download.run {
              src 'http://www.example.com/index.html'
              dest buildDir
              overwrite false
            }
          } catch ( e:Exception ) {
            throw StopExecutionException( e.message!! )
          }
      }

Hope this helps :wink:
Éric