How to publish without adding dependencies to resultant POM

Hi
Wanting to publish a library I am writing; but I don’t want the POM to include the dependencies.

So far the only way I have found is to duplicate my dependencies - one set as compileOnly and one as testImplementation; but that is pretty hacky. Wondering if there are any switches on the MavenPublication plugin? I can see where pom characteristics can be set (e.g., name, description); but not how to remove / exclude dependencies.
Thanks!

Don’t try to manually change the POM, this would e.g. then be inconsistent with the Gradle Module Metadata unless you disable its publishing.

You can do testImplementation.extendsFrom(compileOnly) to automatically have all compileOnly dependencies on the testImplementation configuration too, or maybe better testCompileClasspath.extendsFrom(CompileOnly).

But the question is, why you should have dependencies that you don’t declare. My guess is, that you have optional features that need optional dependencies. If I assume correctly, you should instead strongly consider to use feature variants. See this blog post for a nice sum-up: Optional dependencies are not optional