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

plugins

(vespasien) #1

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


(John Scancella) #2

Can’t you just disable it? See https://docs.gradle.org/current/userguide/more_about_tasks.html#N11326

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


(Christoph Obexer) #3

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.


(Aver Mimas) #4

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.

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?


(Aver Mimas) #5

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

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.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:

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

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

(Adrian Baker) #6

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.


(James Justinic) #7

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:

tasks.withType(Tar) {
    enabled = false
}

(James Justinic) #8

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.


(Aver Mimas) #9

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


(Aver Mimas) #10

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

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.