Overriding publish conventions

As I said, you don’t tell it to the repository, it is just a repository.
You tell it to the tasks that are created for that repository.
For example like

val repoName = "..."
publishing
    .publications
    .withType<MavenPublication>()
    .configureEach {
        tasks.named("publish${name.replaceFirstChar { it.titlecaseChar() }}PublicationTo${repoName}Repository") {
            enabled = false
        }
    }

or a bit more succinct but a bit less correct:

val repoName = "...".replaceFirstChar { it.titlecaseChar() }
tasks
    .withType<PublishToMavenRepository>()
    .named { it.startsWith("publish") && it.endsWith("PublicationTo${repoName}Repository") }
    .configureEach { enabled = false }

1 Like