Gradle-generated pom.xml marks all dependencies as runtime

(Martin Vysny) #1

Good day,
I would like to discuss this particular forum topic: Maven-publish plugin generated pom making dependency scope runtime
The topic is quite old, yet the issue is still valid. I have several compile-type dependencies in build.gradle, which are transferred as runtime-scoped dependencies in the generated pom.xml, when using the new maven-publish plugin. compile-type gradle dependencies are transitive, yet runtime-scoped dependencies are not. When the produced artifact is used by a Maven project, that project need to add all dependencies by hand, which defeats the purpose of transitive dependencies. I believe that this bug can be fixed simply and with no side effects, simply by producing compile-scoped dependencies for compile gradle deps, runtime-scoped deps for runtime gradle deps.
Thank you

Compile dependencies published to maven as runtime scope
(Lance Java) #2

Whilst it doesn’t solve your problem, the source code for the extra-configurations-plugin might be a useful starting point.

(Eduard Dudar) #3

I still use the fix provided in that discussion. I’ve just put it into my own plugin along with some additional convenience things to avoid copying boilerplate pieces from script to script.

I’m not sure that Gradle is consistent with runtime dependencies being non-transitive. I have a project A that depends on B that depends on C. Both B and C are published with maven-publish by 3rd-party so their POM files have all dependencies as runtime. My build.gradle says that B is compile dependency and somehow Gradle + IDEA show that all dependencies (B and C and further) are included into compile scope. I can use classes from that libs and both IDEA and Gradle compile them perfectly…

(Roi Ezra) #4

So looks like the runTime scope of the generated scope in the maven-publish plugin is not a real issue?