Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

"library" not adding dependencies to pom.xml for Maven publication #19

Open
Telesphoreo opened this issue Apr 1, 2022 · 3 comments
Open

Comments

@Telesphoreo
Copy link

Telesphoreo commented Apr 1, 2022

So whenever I add something to my plugin as a library, it works fine. However, there's one problem. It won't add them to the pom.xml used for publishing.

To reproduce:

  • Add something as a library
  • Run the generatePomFileForMavenPublication task

If you're interested, my build.gradle file is here: https://github.com/plexusorg/Plex/blob/master/build.gradle

You'll see that it won't add it to the pom.xml. Any idea if we can get a fix for this?

PS: this plugin doesn't work on Gradle 7.4+

@Telesphoreo
Copy link
Author

Our development team ended up fixing both issues ourselves. We updated the plugin to work with Gradle 7.4+

https://github.com/plexusorg/plugin-yml

You can use it by adding this to your settings.gradle file

    repositories {
        maven { url = uri("https://nexus.telesphoreo.me/repository/gradle-plugins-snapshots") }
        gradlePluginPortal()
    }
}

Our version is 0.6.1-SNAPSHOT.

As for adding the dependencies to pom.xml, we've fixed it by adding the following to our build.gradle file:

            pom.withXml {
                def dependenciesNode = asNode().appendNode("dependencies")
                config.getAllDependencies().each { dependency ->
                    dependenciesNode.appendNode("dependency").with {
                        it.appendNode("groupId", dependency.group)
                        it.appendNode("artifactId", dependency.name)
                        it.appendNode("version", dependency.version)
                        it.appendNode("scope", "provided")
                    }
                }
            }

I'll leave this issue open in case anyone runs into the same problems.

@stephan-gh
Copy link
Member

Our development team ended up fixing both issues ourselves. We updated the plugin to work with Gradle 7.4+

This is an open-source project, contributions are welcome. :)

My time for investigating Minecraft-related issues is very limited at the moment (sadly), but I'd be happy to review pull requests or assist anyone brave enough to change code themselves. :)

@56738
Copy link
Contributor

56738 commented Jun 4, 2022

You could do this by creating a libraryApi configuration which library and compileOnlyApi extend from:

val libraryApi = configurations.create("libraryApi")
configurations {
    library.get().extendsFrom(libraryApi)
    compileOnlyApi.get().extendsFrom(libraryApi)
}

The compileOnlyApi configuration is provided by the java-library plugin and automatically included in the published pom file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants