Maven-publish Publishing to Single Repository?

I’m using the maven-publish plugin

I have two repositories defined. I’m wondering if there is a way to publish to one of the repositories.

Say if I have two repositories defined for publishing, local & release, I would like users to be able to say: publishLocal

or publishRelease

and have it upload all artifacts but only to the repository selected.

The only way I can think of doing it right now is to do a check on which tasks were requested in the section that is setting up repositories and only set up the one requested (or using a variable, same effect), but that seems a rather obtuse way of doing it.

(If I keep setting up both repositories at the same time, I would also want to disable the ‘publish’ task, as I would expect users to only to publish to one at a time).

I believe the maven-publish plugin already accomplishes what you are describing.

Effectively, the plugin creates a task for each publication and each repository. Additionally, an implicit task for publishing to maven local is always added.

I should of specified I’m working with multiple publications. The docs do state that it generates a task for every publication+repository, but I was wondering if there was one for just repository (that would publish every publication for that repository) So instead of

“publish«PUBNAME»PublicationTo«REPONAME»Repository" I’m looking for “publishAllTo«REPONAME»Repository"

Also Local was a bad name to use in relation to maven, I’m not actually looking to publish to the local maven repository, i just picked the name as an example

I’d imagine (if it isn’t currently provided and just hidden), both publishtoAll & publishAllto would be useful extension of the functionality.

No, in that case you would likely have to define your own task that simply depended on the others.

Awesome, thanks for letting me know.