How can I publish a custom POM produced by a custom task?

The Griffon project can consume specialized BOM files that define plugin dependencies, thus a Griffon plugin must generate such BOM files. We currently have a custom task that performs such work given the particular conventions of Griffon plugin dependencies

https://github.com/griffon/griffon/blob/development/subprojects/gradle-griffon-build-plugin/src/main/groovy/org/codehaus/griffon/gradle/tasks/GenerateBomTask.groovy

The problem now is to find a way to publish this BOM to Bintray, preferably using the maven-publish and bintray plugins. How then should we configure the ‘publications’ block so that the BOM file created by there ‘generateBom’ task is uploaded?

TIA Andres

For the moment I’m forcing the MAvenPublication to have no artifacts, then overwrite the generated default pom with my own BOM, like this

publishing {
    publications {
        mavenBom(MavenPublication) {
            artifacts = []
        }
    }
}
  publishToMavenLocal.dependsOn generateBom
  gradle.taskGraph.whenReady { g ->
    Task generatePom = gradle.taskGraph.allTasks.find { it.name == 'generatePomFileForMavenBomPublication' }
    generatePom.doLast {
        copy {
            into project.file("${buildDir}/publications/mavenBom")
            from generateBom.outputDir
            rename generateBom.outputFile.name, 'pom-default.xml'
        }
    }
}

I wonder if there’s an easier way to do this.

Unfortunately, there’s nothing much nicer. I’d probably use:

tasks.withType(GenerateMavenPom) { Task generatePom ->
    generatePom.doLast {
        ...
    }
}