"library" not adding dependencies to pom.xml for Maven publication
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
generatePomFileForMavenPublicationtask
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+
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.
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. :)
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.