Howto publish custom packages and resolve dependencies with "maven-publish"

(Max Bruchmann) #1

Hi, my custom plugin creates custom artifacts with zip extension and has also a custom configuration that needs to be written to the pom.

I created a custom “Software component” similar to the WebApplication.

and added it in the plugin like this:

ArchivePublishArtifact webbundleArtifact = new ArchivePublishArtifact(assembleWebbundleTask);
project.getComponents().add(new WebbundleComponent(webbundleArtifact))

And configured the publication like this:

project.publishing {
  publications {
    webbundle(MavenPublication) {
      from project.components.webbundle

The publish task seems to work but I have a few problems now: - the pom does not contain any dependencies. - how should I map my custom configuration (“webbundle”) to the a custom pom scope (also “webbundle”). I read something that I need to overwrite this manually with pom.withXML, is this still valid?

  • if I need to write it via “pom.withXML” I don’t understand how then later on gradle is able to resolve these custom dependencies again in another project?

Thanks in advance


ps: a bit of topic but is there any preview option when I create a post/topic?

(Max Bruchmann) #2

never mind the “the pom does not contain any dependencies” question since I copied my component and usage implementation from th WebApplication class which returned an empty collection in the getDependencies method.

The extra mapping is now done via this

The only thing I don’t understand is how gradle then resolve the mapping from scope to configuration again, I thought in the “old” maven plugin conf2ScopeMapping helps with this or is this really only used to map from gradle configuration to maven scope one way and when gradle resolves dependencies in it configuration it just maps the name of the scope directly to the configuration one-to-one?