vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

Update Doc relate to additional formats or move implementations to core-lib META-INF/services #145

Open riojano0 opened 2 years ago

riojano0 commented 2 years ago

Case

When a fat-jar is created with maven following the current documentation and using multiple additional formats causes errors relate with that maven take only the first META-INF.services declared from the dependencies.

eg:

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-config-yaml</artifactId>
            <version>${vertx.version}</version>
        </dependency>

The io.vertx.config.spi.ConfigProcessor will be from the verxt-config ignoring the implementations from the yaml-lib

Two suggestions:

-A. Update readme relate to far-jars to acknowledge the user that uses maven with maven-shaded-plugin that needs to use the ServicesResourceTransformer to merge all the ServicesResource -B. Instead of each vertx-confi-{type} have their own io.vertx.config.spi.ConfigProcessor/ConfigStoreFactory update the core with all the Implementations.

A. Update Doc

Update https://vertx.io/docs/vertx-config/java/ telling to the user that when is create a fat-jar with maven-shade-plugin and additionals formats is needed to be define an extra transformer

  <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

Otherwise they only with keep with the last service that can have missing some Implementation given to the user errors like java.lang.IllegalArgumentException: unknown configuration format: yaml (supported formats are: [json, raw, properties]

B. Move implementations declarations to core-lib

The vertx-config keeps all the implementations on her own META-INF and remove from the others additional-formats

eg

[...]
# Bases
io.vertx.config.impl.spi.JsonProcessor
io.vertx.config.impl.spi.RawProcessor
io.vertx.config.impl.spi.PropertiesConfigProcessor
# Extended
io.vertx.config.git.GitConfigStoreFactory
io.vertx.config.yaml.YamlProcessor
[...etc]

The previous suggestion is the "correct" one, but this other provides to the user an easy error to follow

ERROR i.v.c.i.l.c.VertxIsolatedDeployer - Failed in deploying verticle java.util.ServiceConfigurationError: io.vertx.config.spi.ConfigProcessor: Provider {reference} not found
ERROR i.v.c.i.l.c.VertxIsolatedDeployer - Failed in deploying verticle java.util.ServiceConfigurationError: io.vertx.config.spi.ConfigStoreFactory: Provider {reference} not found
gaol commented 2 years ago

I prefer the option A, to mention that in the doc, would you like contribute ? :smile:

BTW, if you use https://start.vertx.io/, it has <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> defined to produce the fat jar.

riojano0 commented 2 years ago

Something like this?, https://github.com/vert-x3/vertx-config/pull/146 Please check my English is not the best

I missed checking the one created by the starter application, but nice that already have it