The tar might be corrupted or it is compressed in an unexpected way
<p>I am trying to unpack <code>tar.xz</code> file using gradle. First I download it and then unpack using tasks</p>

<pre><code>def rootDir = project(":").projectDir

task downloadGHC(type: Download) {
    src "$ghcDownloadLink"
    dest new File("$rootDir/applications/install", "ghc-8.0.1-x86_64-unknown-mingw32.tar.xz")
    onlyIfNewer true
}

task unpackGHC(dependsOn: downloadGHC, type: Copy) {
    from tarTree(downloadGHC.dest)
    into "$rootDir/applications/ghc"
}
</code></pre>

<p>But I get this error</p>

<pre><code>Unable to expand TAR 'L:\...\applications\install\ghc-8.0.1-x86_64-unknown-mingw32.tar.xz'
  The tar might be corrupted or it is compressed in an unexpected way.
  By default the tar tree tries to guess the compression based on the file extension.
  If you need to specify the compression explicitly please refer to the DSL reference.
&gt; Error detected parsing the header
</code></pre>

<p>I am able to open the file so it is not corrupted. How to unpack it?</p>