Maven-publish not outputting dependencies to pom

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?

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

here is the main build script https://github.com/BuiltBrokenModding/VoltzEngine/blob/development/build.gradle here is the script for maven publishing https://github.com/BuiltBrokenModding/BuiltBrokenScripts/blob/buildScripts/scripts/forge/maven.gradle

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

when i added that i get https://www.irccloud.com/pastebin/aroZ2oIU/

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

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

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

It worked thank you very much.

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 http://ci.builtbroken.com/maven/com/builtbroken/minecraftjunit/MinecraftJUnit/1.7.10-0.4.0b6/MinecraftJUnit-1.7.10-0.4.0b6.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(DefaultLenientConfiguration.java:63)

https://github.com/BuiltBrokenModding/VoltzEngine/blob/development/build.gradle is the build.gradle.

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

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:
dev.builtbroken.voltzengine:VoltzEngine:1.7.10-0.12.0b20160407091447
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 https://libraries.minecraft.net/com/builtbroken/minecraftjunit/MinecraftJUnit/maven-metadata.xml.
Could not GET ‘https://libraries.minecraft.net/com/builtbroken/minecraftjunit/MinecraftJUnit/maven-metadata.xml’. Received status code 403 from server: Forbidden
Could not resolve com.builtbroken.minecraftjunit:MinecraftJUnit:1.7.10-0.6.0b4.
Could not parse POM http://box1.dmodoomsirius.me:8081/artifactory/libs-release/com/builtbroken/minecraftjunit/MinecraftJUnit/1.7.10-0.6.0b4/MinecraftJUnit-1.7.10-0.6.0b4.pom
java.lang.NullPointerException (no error message)
`

http://box1.dmodoomsirius.me:8081/artifactory/libs-release/com/builtbroken/minecraftjunit/MinecraftJUnit/1.7.10-0.6.0b4/MinecraftJUnit-1.7.10-0.6.0b4.pom is the pom file.

https://github.com/BuiltBrokenModding/BuiltBrokenScripts/blob/buildScripts/scripts/both/maven.gradle is the maven file.

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: 'com.google.guava', name: 'guava', version: guava_version
	compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: jersey_version
	compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: jersey_version
	compile group: 'org.glassfish.jersey.media', name: 'jersey-media-jaxb', version: jersey_version
	compile group: 'commons-codec', name: 'commons-codec', version: commons_codec_version
}

publishing {
	publications {
		main(MavenPublication) {
			components.java  // 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.

1 Like

The publication configuration should read from components.java instead of just components.java.

Thank you. I was previously using “artifact jar” and messed up when I tried the “components.java” 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.

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.