Customizing distZip layout

I’m trying to start gradle as a replacement to maven.
But I still have much to learn.

One of my many is question is, how to customize the zip or tar created by distZip and distTar.
Currently if the project is called myzip-1.2.3.zip contains a folder myzip-1.2.3 and there is
the bin and lib folder. I would like to get rid of the myzip-1.2.3 folder and put the bin/lib directly
into the root folder.

Another question: How can I create instead or in addition a tar.gz folder?

Thanks,
Dieter

I would like to get rid of the myzip-1.2.3

I strongly advice not to do that.
Many people will “extract here”, polluting the current directory with the contents of the archive,
either because they didn’t think this could happen, or by accident, or because most programs distributed as an archive have such a top-level folder in them.

If you really want to do it, you should be able to use something like:

distributions {
    main {
        contents {
            into("..")
        }
    }
}

But again, I strongly advice not to do that.

folder and put the bin/lib directly into the root folder.

For bin - which I also quite dislike - you can easily configure it using

application {
    executableDir = ""
}

For lib it is not so easy.
Again, I would strongly advice against doing that, from a user’s perspective.
Additionally, Gradle like convention over configuration but provides the power to do what you want.
In the case of lib, this is pretty hard-wired and would need a feature request to be easily configurable.
Currently you would need a significant amount of configuration to change it.

I think you would need to create a completely separate distribution besides the main created by the distribution plugin and configured by the application plugin, then configure it according to your intended layout, and additionally post-process the generated start scripts where the lib is hard-wired in the generator code and is currently not configurable. Uncommon for Gradle, but well, here it is like that.

Another question: How can I create instead or in addition a tar.gz folder?

Not sure what you mean by “tar.gz folder”, do you mean:

tasks.distTar {
    compression = Compression.GZIP
}

?