kiwiproject / consul-client

A Consul Client for Java
Apache License 2.0
7 stars 1 forks source link

Most compile-time dependencies are not in the POM in Maven Central #214

Closed sleberknight closed 1 year ago

sleberknight commented 1 year ago

Most of the compile-time dependencies in the POM are not in the consul-client-0.5.0.pom in Maven Central.

The ones that are included are org.slf4:slf4j-api and org.immutables:value (as provided). Then there are the test-scope dependencies including all four defined in the POM (commons-codec, logback-classic, testcontainers, and retrofit-mock) as well as all the test-scoped dependencies inherited from the kiwi-parent POM.

So the POM in Maven Central is missing:

Since they are missing, any library trying to use this library will not have the necessary transitive dependencies.

I don't think I have ever seen this happen before, so this is going to be fun debugging the problem... 😢

sleberknight commented 1 year ago

After a bit of debugging, after running mvn install locally, the dependency-reduced-pom.xml does not contain any of the dependencies listed above. They seem to correspond to the "relocations" listed in the configuration of the Maven Shade Plugin, so I commented out the Shade plugin and re-installed. Without the Shade plugin, the resulting POM file contains the expected dependencies.

So, this problem is caused by the Shade plugin, but I am not sure how to fix it so that we can continue to have both shaded and non-shaded JARs as well as ensure that the POM in Maven Central is correct. I will need to do more research on the Shade plugin.

sleberknight commented 1 year ago

There is a configuration property createDependencyReducedPom which:

Flag whether to generate a simplified POM for the shaded artifact. If set to true, dependencies that have been included into the uber JAR will be removed from the section of the generated POM. The reduced POM will be named dependency-reduced-pom.xml and is stored into the same directory as the shaded artifact. Unless you also specify dependencyReducedPomLocation, the plugin will create a temporary file named dependency-reduced-pom.xml in the project basedir.

Setting this to true causes the Shade plugin to install the regular POM. I have not yet attempted to deploy this to Maven Central, but it seems like it would do the same and use the regular POM.

The last sentence in the quote above seems to be incorrect. I removed the dependency-reduced-pom.xml from the project directory, and then ran mvn install. No new dependency-reduced-pom.xml was created (and I do not have the dependencyReducedPomLocation property set).