title: How to download a JAR file from a URL using Groovy?
body: <p>I have a JAR artifact in my nexus repository and I want to download it using Groovy script.</p>
  
  <p>I tired this but it doesn't work:</p>
  
  <pre><code>new File("/dir/to/save/app.jar").withOutputStream { out -&gt;
      new URL('http://server.org.com/nexus/repo/1.11/app.jar').eachByte { b -&gt;
          out.write(b)
      }
  </code></pre>
  
  <p>But the same scripts works perfectly when I download something from Maven central repository.</p>
  
  <p>What could be the issue? Is there any SSL certificate issue with my nexus that is causing the download to be broken? Because, when I use <code>curl</code> and download it using <code>-k</code> flag it downloads the file perfectly because it makes the connection <code>insecure.</code></p>
  
  <p>I use <code>curl -k &lt;NEXUS_REPO_PATH_TO_FILE&gt; -O app.jar</code></p>
  
  <p>If there is any SSL issue then how can I suppress it using Groovy?</p>