From 9034df9b1dcba300c19181e1d10743a11e4ed1e3 Mon Sep 17 00:00:00 2001 From: Pablo Gonzalez Granados Date: Tue, 3 Oct 2023 17:16:51 +0200 Subject: [PATCH] Add Java checkstyle and and polish maven dep references --- .gitignore | 4 +- README.md | 5 +- checkstyle.xml | 14 +++ .../test/smallrye/PriceConverter.java | 4 +- .../test/smallrye/PriceGenerator.java | 4 +- .../test/smallrye/PriceResource.java | 8 +- .../test/smallrye/PriceResourceTest.java | 10 +-- integration-tests/kitchensink/pom.xml | 39 ++------ .../hivemqclient/GreetingResource.java | 12 ++- pom.xml | 90 +++++++++++++++++++ runtime/pom.xml | 20 +---- .../smallrye/reactive/HiveMQClients.java | 4 +- .../reactive/HiveMQMqttConnector.java | 16 ++-- 13 files changed, 155 insertions(+), 75 deletions(-) create mode 100644 checkstyle.xml diff --git a/.gitignore b/.gitignore index a556d94..134f893 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,6 @@ target/ pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup -release.properties \ No newline at end of file +release.properties +/*/.cache/ +/*/*/.cache/ diff --git a/README.md b/README.md index 0d7c7c8..434c2fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Quarkus - Hivemq Client -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-) ## Introduction @@ -32,6 +32,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
masini

💻 🚧 + +
pjgg

💻 🚧 + diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..d707dc0 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceConverter.java b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceConverter.java index a519b40..350f0da 100644 --- a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceConverter.java +++ b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceConverter.java @@ -1,13 +1,13 @@ package io.quarkiverse.hivemqclient.test.smallrye; -import javax.enterprise.context.ApplicationScoped; - import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.Outgoing; import org.jboss.logging.Logger; import io.smallrye.reactive.messaging.annotations.Broadcast; +import javax.enterprise.context.ApplicationScoped; + /** * A bean consuming data from the "prices" MQTT topic and applying some conversion. * The result is pushed to the "my-data-stream" stream which is an in-memory stream. diff --git a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceGenerator.java b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceGenerator.java index 940e99a..ae8cf24 100644 --- a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceGenerator.java +++ b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceGenerator.java @@ -3,13 +3,13 @@ import java.time.Duration; import java.util.Random; -import javax.enterprise.context.ApplicationScoped; - import org.eclipse.microprofile.reactive.messaging.Outgoing; import org.jboss.logging.Logger; import io.smallrye.mutiny.Multi; +import javax.enterprise.context.ApplicationScoped; + /** * A bean producing random prices every second. * The prices are written to a MQTT topic (prices). The MQTT configuration is specified in the application configuration. diff --git a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResource.java b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResource.java index 1e9da7b..2bb8078 100644 --- a/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResource.java +++ b/integration-tests/hivemq-client-smallrye/src/main/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResource.java @@ -1,15 +1,15 @@ package io.quarkiverse.hivemqclient.test.smallrye; +import org.eclipse.microprofile.reactive.messaging.Channel; + +import io.smallrye.mutiny.Multi; + import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.eclipse.microprofile.reactive.messaging.Channel; - -import io.smallrye.mutiny.Multi; - /** * A simple resource retrieving the "in-memory" "my-data-stream" and sending the items to a server sent event. */ diff --git a/integration-tests/hivemq-client-smallrye/src/test/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResourceTest.java b/integration-tests/hivemq-client-smallrye/src/test/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResourceTest.java index f2b8fb2..542acef 100644 --- a/integration-tests/hivemq-client-smallrye/src/test/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResourceTest.java +++ b/integration-tests/hivemq-client-smallrye/src/test/java/io/quarkiverse/hivemqclient/test/smallrye/PriceResourceTest.java @@ -7,11 +7,6 @@ import java.net.URI; import java.util.concurrent.atomic.AtomicInteger; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.sse.SseEventSource; - import org.jboss.logging.Logger; import org.junit.jupiter.api.Test; @@ -19,6 +14,11 @@ import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.sse.SseEventSource; + @TestProfile(HivemqDefaultProfile.class) @QuarkusTest public class PriceResourceTest { diff --git a/integration-tests/kitchensink/pom.xml b/integration-tests/kitchensink/pom.xml index 4da9cd0..1bd37e5 100644 --- a/integration-tests/kitchensink/pom.xml +++ b/integration-tests/kitchensink/pom.xml @@ -7,36 +7,13 @@ 1.0.1-SNAPSHOT quarkus-hivemq-client-kitchensink - Quarkus - HiveMQ Client - Kitchen Sink - - 3.8.1 - true - 11 - 11 - 11 - UTF-8 - UTF-8 - 2.16.1.Final - quarkus-bom - io.quarkus - 2.16.1.Final - 3.1.2 - 1.18.30 - - - - - ${quarkus.platform.group-id} - ${quarkus.platform.artifact-id} - ${quarkus.platform.version} - pom - import - - - + Quarkus - HiveMQ Client - Integration Tests Kitchen Sink + + 3.1.2 + 1.18.30 + - - + org.projectlombok lombok ${lombok.version} @@ -46,7 +23,7 @@ io.quarkiverse.hivemqclient quarkus-hivemq-client - 1.0.1-SNAPSHOT + ${project.version} io.quarkus @@ -76,7 +53,7 @@ io.quarkus quarkus-maven-plugin - ${quarkus-plugin.version} + ${quarkus.version} true diff --git a/integration-tests/kitchensink/src/main/java/io/quarkiverse/hivemqclient/GreetingResource.java b/integration-tests/kitchensink/src/main/java/io/quarkiverse/hivemqclient/GreetingResource.java index 20e1f5f..14a2bd7 100644 --- a/integration-tests/kitchensink/src/main/java/io/quarkiverse/hivemqclient/GreetingResource.java +++ b/integration-tests/kitchensink/src/main/java/io/quarkiverse/hivemqclient/GreetingResource.java @@ -1,15 +1,19 @@ package io.quarkiverse.hivemqclient; -import javax.inject.Inject; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; - import org.eclipse.microprofile.reactive.messaging.Channel; import org.eclipse.microprofile.reactive.messaging.Emitter; import org.eclipse.microprofile.reactive.messaging.Incoming; import org.eclipse.microprofile.reactive.messaging.OnOverflow; import io.smallrye.reactive.messaging.mqtt.MqttMessage; + +import javax.inject.Inject; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; diff --git a/pom.xml b/pom.xml index 8af3706..3ad72f3 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,16 @@ UTF-8 UTF-8 4.10.1 + 3.0 + 5.0.1 + 1.8.0 + 2.21.0 + 3.2.1 + format + sort + 1.9.0 + 1.3.3 + 10.10.0 2.16.10.Final 2.22.2 @@ -58,6 +68,73 @@ + + + net.revelc.code + impsort-maven-plugin + ${impsort-maven-plugin.version} + + + .cache + java.,jakarta.,org.,com.,io. + * + true + + + + + ${src.sort.goal} + + + + + + net.revelc.code.formatter + formatter-maven-plugin + ${formatter-maven-plugin.version} + + + + ${src.format.goal} + + + + + eclipse-format.xml + LF + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + checkstyle.xml + + ${project.build.sourceDirectory} + true + true + true + true + + + + validate + validate + + check + + + + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + @@ -72,5 +149,18 @@ integration-tests + + validate-format + + + validate-format + + + + validate + check + xml-check + + diff --git a/runtime/pom.xml b/runtime/pom.xml index eb700b7..edc2ee3 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -8,15 +8,12 @@ quarkus-hivemq-client Quarkus - HiveMQ Client - Runtime - - 3.0 - 1.10.0 - + com.hivemq hivemq-mqtt-client - 1.3.3 + ${hivemq.client.version} io.smallrye.reactive @@ -26,12 +23,11 @@ io.smallrye.reactive mutiny - ${mutiny.version} + ${mutiny-rxjava.version} io.smallrye.reactive mutiny-rxjava - ${mutiny.version} org.eclipse.microprofile.reactive-streams-operators @@ -41,7 +37,7 @@ org.eclipse.microprofile.metrics microprofile-metrics-api - 5.0.1 + ${microprofile-metrics-api.version} io.quarkus @@ -107,14 +103,6 @@ 3.0.3 - diff --git a/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQClients.java b/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQClients.java index 2ebfead..8af9b3b 100644 --- a/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQClients.java +++ b/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQClients.java @@ -16,8 +16,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import javax.net.ssl.TrustManagerFactory; - import com.hivemq.client.mqtt.MqttClientSslConfigBuilder; import com.hivemq.client.mqtt.mqtt3.Mqtt3BlockingClient; import com.hivemq.client.mqtt.mqtt3.Mqtt3Client; @@ -29,6 +27,8 @@ import io.smallrye.mutiny.converters.uni.UniRxConverters; import io.smallrye.reactive.messaging.health.HealthReport; +import javax.net.ssl.TrustManagerFactory; + public class HiveMQClients { private static final Map clients = new ConcurrentHashMap<>(); diff --git a/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQMqttConnector.java b/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQMqttConnector.java index 2317f4c..b85661e 100644 --- a/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQMqttConnector.java +++ b/runtime/src/main/java/io/quarkiverse/hivemqclient/smallrye/reactive/HiveMQMqttConnector.java @@ -1,16 +1,12 @@ package io.quarkiverse.hivemqclient.smallrye.reactive; -import static io.smallrye.reactive.messaging.annotations.ConnectorAttribute.Direction.*; +import static io.smallrye.reactive.messaging.annotations.ConnectorAttribute.Direction.INCOMING; +import static io.smallrye.reactive.messaging.annotations.ConnectorAttribute.Direction.INCOMING_AND_OUTGOING; +import static io.smallrye.reactive.messaging.annotations.ConnectorAttribute.Direction.OUTGOING; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Destroyed; -import javax.enterprise.event.Observes; -import javax.inject.Inject; - import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.reactive.messaging.Message; import org.eclipse.microprofile.reactive.messaging.spi.Connector; @@ -25,6 +21,12 @@ import io.smallrye.reactive.messaging.providers.connectors.ExecutionHolder; import io.vertx.mutiny.core.Vertx; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.Destroyed; +import javax.enterprise.event.Observes; +import javax.inject.Inject; + @ApplicationScoped @Connector(HiveMQMqttConnector.CONNECTOR_NAME) @ConnectorAttribute(name = "client-id", type = "string", direction = INCOMING_AND_OUTGOING, description = "Set the client identifier")