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 ‘https://nexus.company.com:8443/repository/gradle-distributions/com/company/company-gradle-distribution/1/company-gradle-distribution-1.zip’. Received status code 403 from server: Forbidden
It should publish it directly under https://nexus.company.com:8443/repository/gradle-distributions, and no group or version in the path.
build.gradle
import com.company.gradle.distribution.DownloadGradle
plugins {
id 'base'
id 'maven-publish'
}
group = 'com.company'
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 = downloadGradle.gradleVersion.map { gradleVersion ->
"gradle-${gradleVersion}-${project.version}-bin.zip"
}
from zipTree(downloadGradle.destinationFile)
from('src/init.d') {
into "${downloadGradle.distributionNameBase.get()}/init.d"
}
from('gradle.properties') {
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}-bin.zip" http://nexus.company.com:8443/repository/gradle-distributions