Publish Custom Gradle Distribution Zip to Raw Nexus Repository

Is it possible, and how can I publish my custom gradle distribution to Nexus Repository?
I am using Nexus to store gradle distributions in a raw repository.
I have created a project to build a custom gradle distribution, and I want to publish it there.

However I do not want to use MavenPublication

Execution failed for task ‘:publishGradlePublicationToMavenRepository’.

Failed to publish publication ‘gradle’ to repository ‘maven’
Could not PUT ‘’. Received status code 403 from server: Forbidden

It should publish it directly under, and no group or version in the path.



plugins {
    id 'base'
    id 'maven-publish'

group = ''
version = '1'
description = 'Create Custom Gradle Distribution for Company'

task downloadGradle(type: DownloadGradle) {
    description = 'Downloads the Gradle distribution with a given version.'
    gradleVersion = '5.6.2'

task createCustomGradleDistribution(type: Zip) {
    description = 'Builds custom Gradle distribution and bundles initialization scripts.'

    dependsOn downloadGradle

    archiveFileName = { gradleVersion ->

    from zipTree(downloadGradle.destinationFile)

    from('src/init.d') {
        into "${downloadGradle.distributionNameBase.get()}/init.d"

    from('') {
        into "${downloadGradle.distributionNameBase.get()}"

artifacts {
    archives createCustomGradleDistribution

publishing {
    repositories {
        maven {
            url nexusUrl + "/gradle-distributions"
            credentials {
                username = nexusUsername
                password = nexusPassword

    publications {
        gradle(MavenPublication) {
            artifact createCustomGradleDistribution

If not possible with the maven-publish plugin, (or any other plugin?), I could always just use Nexus REST API for uploading files
curl -v --user 'admin:admin123' --upload-file "gradle-${gradleVersion}-${project.version}"