Exposing buildRpm as a publication

taking my first steps. Am working on publishing my rpm artifacts to Artifactory. What I have is the buildRpm plugin task that builds an RPM. The rpm build is configured through the nebula plugin. For uploading I used the artifactory plugin; My implementation is as follows:

// See https://docs.gradle.org/current/userguide/artifact_management.htmland
// section 30.3 "note that the custom archives you are creating as part of your
// build are not automatically assigned to any configuration. You have to
// explicitly do this assignment.[sic]"
configurations {
    rpmConfig
}

// Attach the artifact to the configuration in this closure:
// docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.ArtifactHandler.html
artifacts {
    rpmConfig file(buildRpm.archivePath)
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = "${artifactory_root_dir}"
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = false
            ivy {
                artifactLayout = "${artifactory_team_dir}/[artifact]/build/distributions/[artifact]-[revision](-[classifier])(.[ext])"
                mavenCompatible = false
            }
        }
        defaults {
            // publications('buildRpm') This does not work because buildRpm does not make publications like ivy/groovy
            publishConfigs('rpmConfig')
            publishBuildInfo = false //Publish build-info to Artifactory (true by default)
            publishArtifacts = true //Publish artifacts to Artifactory (true by default)
            publishPom = false //Publish generated POM files to Artifactory (true by default).
            publishIvy = false//Publish generated Ivy descriptor files to Artifactory (true by default).
        }
    }
}

// If we don't specify this artifactoryPublish task fails
artifactoryPublish.dependsOn buildRpm

My questions are

  • Is there a way to leverage the nebula plugin to configure the plugin directly without having the explicit artifact and custom configuration?
  • I kind of ran with the ivy part to specify my artifacts. Is this a bit shoe horned or is this the canonical way to specify my RPM package layout?
1 Like