Maven-publish not outputting dependencies to pom


(Dmodoomsirius) #1

Is maven-publish plugin supposed to have the dependencies in the pom i found Using the maven-publish plugin = no dependencies in pom.xml but in gradle 2.5 It is not. any sugguestions?

(Mark Vieira) #2

Can you please post an example of a build script which results in an POM with no dependencies?

(Dmodoomsirius) #3

here is the main build script here is the script for maven publishing

(Mark Vieira) #4

Here is your problem. You’ll need to place from outside pom.withXml { }.

(Dmodoomsirius) #5

when i added that i get

(Mark Vieira) #6

My intention wasn’t to literally add the text “outside”. It should look something like this:

myPublication(MavenPublication) {
    pom.withXml {
        asNode().appendNode('description', 'Created on ' + getDate())

(Dmodoomsirius) #7

I would like to say thank you for your help in advance! testing now.

(Dmodoomsirius) #8

It worked thank you very much.

(Dmodoomsirius) #9

My next issue is Could not resolve com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.4.0b6.

00:39:34.627 [ERROR] [org.gradle.BuildExceptionReporter] > Could not parse POM
00:39:34.627 [ERROR] [org.gradle.BuildExceptionReporter] > java.lang.NullPointerException (no error message) 00:39:34.628 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
00:39:34.630 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ‘:runtime’.
00:39:34.630 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure( is the build.gradle.

(Dmodoomsirius) #10

How can i exclude certain dependencies from appearing in the pom file?

(Dmodoomsirius) #11

when putting dependencies into the pom file I get the error

`* What went wrong:
Could not resolve all dependencies for configuration ‘:apiCompileClasspath’.

Could not resolve com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.+.
Required by:
Could not resolve com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.+.
Failed to list versions for com.builtbroken.minecraftjunit:MinecraftJUnit.
Unable to load Maven meta-data from
Could not GET ‘’. Received status code 403 from server: Forbidden
Could not resolve com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.6.0b4.
Could not parse POM
java.lang.NullPointerException (no error message)
` is the pom file. is the maven file.

(Scott Palmer) #12

I am having the same problem with Gradle 2.14.1. maven-publish doesn’t put dependencies into the generated POM. I have a multi-project build where one project depends on another as well as several other jars from a repository

dependencies {
	testCompile group: 'junit', name: 'junit', version: junit_version
	compile project(':MyProjectModel')
	compile group: 'commons-lang', name: 'commons-lang', version: commons_lang_version
	compile group: 'commons-io', name: 'commons-io', version: commons_io_version
	compile group: '', name: 'guava', version: guava_version
	compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: jersey_version
	compile group: '', name: 'jersey-media-multipart', version: jersey_version
	compile group: '', name: 'jersey-media-jaxb', version: jersey_version
	compile group: 'commons-codec', name: 'commons-codec', version: commons_codec_version

publishing {
	publications {
		main(MavenPublication) {  // I tried this and the line below - POM wasn't affected
			//artifact jar
			artifact javadocJar
			artifact sourcesJar

The generated POM doesn’t contain a dependency section at all.

(Mark Vieira) #13

The publication configuration should read from instead of just

(Scott Palmer) #14

Thank you. I was previously using “artifact jar” and messed up when I tried the “” way. Using “artifacts jar” loses the dependency information. But I think that makes sense. Indeed when I added the “from” the dependency information was there.

(Mark Vieira) #15

This is correct. An artifact is exactly that, just some file. No dependency information included. A component however includes metadata about dependencies that we can include in the POM.