# Distribution plugin : generate only a tar (or avoid generate zip)

**URL:** <https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [June 19, 2016, 2:33pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124 "2016-06-19T14:33:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vespasien](https://avatars.discourse-cdn.com/v4/letter/v/6a8cbe/32.png) [@vespasien](https://discuss.gradle.org/u/vespasien)\
**Post date:** [June 19, 2016, 2:33pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/1 "2016-06-19T14:33:50Z")

</div>

Hi All,

I am using the distribution plugin, it works file and generate the archive with the right content. My only problem is that I want to generate only a tar when I run the install or assemble tasks instead of the 2 distributions. Is there a way to configure the plugin in that way ?

Thanks,

Will

---

<div class="post-metadata">

**Author:** ![johnscancella](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@johnscancella](https://discuss.gradle.org/u/johnscancella)\
**Post date:** [June 23, 2016, 6:37pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/2 "2016-06-23T18:37:49Z")

</div>

Can’t you just disable it? See [https://docs.gradle.org/current/userguide/more\_about\_tasks.html#N11326](https://docs.gradle.org/current/userguide/more_about_tasks.html#N11326)

so you would add this to your build.gradle:  
`tasks.distZip.enabled = false`

---

<div class="post-metadata">

**Author:** ![cobexer](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/cobexer/32/10563_2.png) [@cobexer](https://discuss.gradle.org/u/cobexer)\
**Post date:** [May 11, 2017, 11:09am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/3 "2017-05-11T11:09:18Z")

</div>

I have the same problem, disabling the task suppresses the generation of the zip, however artifactoryPublish still wants to upload the missing archive and fails.

How does one properly disable the tar/zip archive?

I use Gradle 3.3 if that matters.

---

<div class="post-metadata">

**Author:** ![Aver\_Mimas](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Aver\_Mimas](https://discuss.gradle.org/u/Aver_Mimas)\
**Post date:** [February 18, 2018, 5:57pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/4 "2018-02-18T17:57:25Z")

</div>

I can’t seem to get this to work. I tried both of the following in my `build.gradle`; one at a time. But I always end up with both zip and tar archives. I only want the zip archive but can’t seem to get the `distTar` task to stop running.

```gradle
tasks.distZip.enabled = false
tasks.distTar.enabled = false

```

I must be doing something wrong. I tried Gradle versions 4.5.1 to 4.3 but same result every time. Why can’t I disable one of the archive tasks?

---

<div class="post-metadata">

**Author:** ![Aver\_Mimas](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Aver\_Mimas](https://discuss.gradle.org/u/Aver_Mimas)\
**Post date:** [February 20, 2018, 2:04am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/5 "2018-02-20T02:04:42Z")

</div>

I realized why tar files were still being generated. After applying distribution plugin, I defined several custom distribution name. For example:

```gradle
distributions {
  dist1 {
    ...
  }
  dist2 {
    ...
  }
  dist3 {
    ...
  }
}

```

Each of those distributions are assigned a task to produce a tar file and a zip file. So, in order to skip tar file OR zip file creation, they have to be specifically disabled. A good way of doing that would be to use the task graph. For example:

```gradle
gradle.taskGraph.whenReady { graph ->
    graph.allTasks.findAll { it.name ==~ /.+DistTar/ }*.enabled = false
}

```

While this works, it’d be really nice if the `Distribution` plugin provides a configuration for this. It could be something like this:

```gradle
distribution {
  disableDistZip = true | false
  disableDistTar = true | false

  dist1 { ... }
  dist2 { ... }
}

```

---

<div class="post-metadata">

**Author:** ![adrian-baker](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@adrian-baker](https://discuss.gradle.org/u/adrian-baker)\
**Post date:** [February 20, 2018, 5:04am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/6 "2018-02-20T05:04:09Z")

</div>

It seems a slightly odd default to generate BOTH the tar and the zip, I too ended up adding the opimization to only generate the one we actually used.

I can’t think it’s very often that both files are needed, it’s a pity the default isn’t either one or the other, with the option to switch to output both.

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [February 20, 2018, 6:45am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/7 "2018-02-20T06:45:44Z")

</div>

> [@Aver\_Mimas](#):
>
> So, in order to skip tar file OR zip file creation, they have to be specifically disabled. A good way of doing that would be to use the task graph.

Unless you have an inconsistent need for tar files in some places, but just not distributions, it would be more conventional to just disable the `Tar` tasks:

```groovy
tasks.withType(Tar) {
    enabled = false
}

```

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [February 20, 2018, 7:21am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/8 "2018-02-20T07:21:59Z")

</div>

> [@adrian-baker](#):
>
> It seems a slightly odd default to generate BOTH the tar and the zip

The plugin was designed to easily create distributions of an application for end users. Application downloads of this type often offer ZIP for Windows and a TAR for the Linux/Unix-like platforms, even if they have the same contents.

---

<div class="post-metadata">

**Author:** ![Aver\_Mimas](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Aver\_Mimas](https://discuss.gradle.org/u/Aver_Mimas)\
**Post date:** [February 20, 2018, 3:57pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/9 "2018-02-20T15:57:02Z")

</div>

> [@jjustinic](#):
>
> > [@Aver\_Mimas](#):
> >
> > So, in order to skip tar file OR zip file creation, they have to be specifically disabled. A good way of doing that would be to use the task graph.
> 
> Unless you have an inconsistent need for tar files in some places, but just not distributions, it would be more conventional to just disable the `Tar` tasks:
> 
> ```groovy
> tasks.withType(Tar) {
> enabled = false
> }
> 
> ```

That’s a nicer approach thank going through the task graph. Thanks James for the suggestion.

---

<div class="post-metadata">

**Author:** ![Aver\_Mimas](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Aver\_Mimas](https://discuss.gradle.org/u/Aver_Mimas)\
**Post date:** [February 20, 2018, 4:04pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/10 "2018-02-20T16:04:32Z")

</div>

> [@jjustinic](#):
>
> > [@adrian-baker](#):
> >
> > It seems a slightly odd default to generate BOTH the tar and the zip
> 
> The plugin was designed to easily create distributions of an application for end users. Application downloads of this type often offer ZIP for Windows and a TAR for the Linux/Unix-like platforms, even if they have the same contents.

If this plugin was designed for distributing “an application”, then I think it makes sense but I haven’t actually seen any example that demonstrate this. All the example/usage of this plugin I have seen so far simply shows creating an archive with some files that are automatically picked up from a path as part of the plugin’s convention (i.e. `src/$distribution.name/dist`) or add files from custom path. The User Guide of this plugin doesn’t really have a lot of examples.

[https://docs.gradle.org/current/userguide/distribution\_plugin.html](https://docs.gradle.org/current/userguide/distribution_plugin.html)

Do you happen to have an example on how this plugin is supposed to be used? For example, build and application and bundle it using this plugin for distribution.

---

<div class="post-metadata">

**Author:** ![glasser](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/glasser/32/7414_2.png) [@glasser](https://discuss.gradle.org/u/glasser)\
**Post date:** [January 4, 2019, 6:10pm UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/11 "2019-01-04T18:10:38Z")

</div>

I wonder if this (disabling tar and zip) is worth documenting in the application plugin. We use the application plugin in our project solely to create a command-line tool usable by developers of our project, not to actually create a distribution, so the default of adding the slow distZip and distTar tasks to ‘build -\> assemble’ isn’t great (and neither is the default of _not_ having installDist be a dependency of ‘build’). It might be nice to have a section in the docs that says something like: if you’re using the application plugin just to create a tool to use in dev, not to distribution, you’ll want to add

```gradle
tasks.distZip.enabled = false
tasks.distTar.enabled = false
build.dependsOn installDist

```

Unless I’m missing something and there’s another mechanism recommended for this use case!

---

<div class="post-metadata">

**Author:** ![xylix](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/xylix/32/8227_2.png) [@xylix](https://discuss.gradle.org/u/xylix)\
**Post date:** [December 27, 2019, 10:09am UTC](https://discuss.gradle.org/t/distribution-plugin-generate-only-a-tar-or-avoid-generate-zip/18124/12 "2019-12-27T10:09:36Z")

</div>

I absolutely agree. I’ve had some use for this in multiple projects in the last 6 months and this is the first time I’ve found a nice gradley solution. Before I’ve used solutions where I scripted unpacking of the tar as part of the build because I couldn’t find these documented anywhere.
