jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.44k stars 159 forks source link

Quarkus config properties not taken into account when dev mode is enabled #846

Open lburgazzoli opened 3 years ago

lburgazzoli commented 3 years ago

I've create a script with:

$ jbang init scripts/q.java
$ jbang edit --open=code scripts/q.java

With the following code:

///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 11+

//DEPS io.quarkus:quarkus-universe-bom:1.13.3.Final@pom
//DEPS org.apache.camel.quarkus:camel-quarkus-timer
//DEPS org.apache.camel.quarkus:camel-quarkus-log

//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager

//Q:CONFIG quarkus.banner.enabled=false
//Q:CONFIG quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n

import org.apache.camel.builder.RouteBuilder;
import io.quarkus.runtime.Quarkus;

public class q extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("timer:tick")
            .setBody().constant("Hello!")
            .to("log:info");            
    }

    public static void main(String... args) throws Exception {
        Quarkus.run(args);
    }
}

When I execute the script with quarkus dev mode enabled:

$ jbang --fresh -Dquarkus.dev scripts/q.java

The output is:

[jbang] Resolving dependencies...
[jbang] Loading MavenCoordinate [io.quarkus:quarkus-universe-bom:pom:1.13.3.Final]
[jbang]     Resolving org.apache.camel.quarkus:camel-quarkus-timer...Done
[jbang]     Resolving org.apache.camel.quarkus:camel-quarkus-log...Done
[jbang] Dependencies resolved
[jbang] Building jar...
warning: unknown enum constant XmlAccessType.PROPERTY
  reason: class file for javax.xml.bind.annotation.XmlAccessType not found
warning: unknown enum constant XmlAccessType.NONE
warning: unknown enum constant XmlAccessType.FIELD
warning: unknown enum constant XmlAccessType.PROPERTY
4 warnings
[jbang] Post build with io.quarkus.launcher.JBangIntegration
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-04-29 13:56:56,485 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (Quarkus Main Thread) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
2021-04-29 13:56:56,575 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Routes startup summary (total:1 started:1)
2021-04-29 13:56:56,575 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread)     Started route1 (timer://tick)
2021-04-29 13:56:56,575 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Quarkus Main Thread) Apache Camel 3.9.0 (camel-1) started in 43ms (build:0ms init:32ms start:11ms)
2021-04-29 13:56:56,577 INFO  [io.quarkus] (Quarkus Main Thread) Quarkus 1.13.3.Final on JVM started in 0.956s. 
2021-04-29 13:56:56,577 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-04-29 13:56:56,578 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [camel-core, camel-log, camel-support-common, camel-timer, cdi]
2021-04-29 13:56:57,583 INFO  [info] (Camel (camel-1) thread #0 - timer://tick) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello!]
2021-04-29 13:56:58,575 INFO  [info] (Camel (camel-1) thread #0 - timer://tick) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello!]
^C2021-04-29 13:56:58,859 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Shutdown thread) Apache Camel 3.9.0 (camel-1) shutting down
2021-04-29 13:56:58,864 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Shutdown thread) Routes shutdown summary (total:1 stopped:1)
2021-04-29 13:56:58,865 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Shutdown thread)     Stopped route1 (timer://tick)
2021-04-29 13:56:58,867 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (Shutdown thread) Apache Camel 3.9.0 (camel-1) shutdown in 8ms (uptime:2s303ms)
2021-04-29 13:56:58,869 INFO  [io.quarkus] (Shutdown thread) Quarkus stopped in 0.012s

Which does not match my setup as the banner should be suppressed and the log format is not the configured one.

Verbose output:

[jbang] jbang version 0.70.0
[jbang] System Java version detected as 11
[jbang] System Java version matches requested version 11
[jbang] Resolving dependencies...
[jbang] Loading MavenCoordinate [io.quarkus:quarkus-universe-bom:pom:1.13.3.Final]
[jbang]     Resolving org.apache.camel.quarkus:camel-quarkus-timer...Done
[jbang]     Resolving org.apache.camel.quarkus:camel-quarkus-log...Done
[jbang] Dependencies resolved
[jbang] Building jar...
[jbang] compile: /home/luca/.local/sfw/tools/sdkman/candidates/java/current/bin/javac -parameters -classpath /home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-timer/1.8.1/camel-quarkus-timer-1.8.1.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-core/1.8.1/camel-quarkus-core-1.8.1.jar:/home/luca/.m2/repository/io/quarkus/quarkus-core/1.13.3.Final/quarkus-core-1.13.3.Final.jar:/home/luca/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/home/luca/.m2/repository/jakarta/enterprise/jakarta.enterprise.cdi-api/2.0.2/jakarta.enterprise.cdi-api-2.0.2.jar:/home/luca/.m2/repository/jakarta/el/jakarta.el-api/3.0.3/jakarta.el-api-3.0.3.jar:/home/luca/.m2/repository/jakarta/interceptor/jakarta.interceptor-api/1.2.5/jakarta.interceptor-api-1.2.5.jar:/home/luca/.m2/repository/jakarta/inject/jakarta.inject-api/1.0/jakarta.inject-api-1.0.jar:/home/luca/.m2/repository/io/quarkus/quarkus-ide-launcher/1.13.3.Final/quarkus-ide-launcher-1.13.3.Final.jar:/home/luca/.m2/repository/io/smallrye/config/smallrye-config/1.11.1/smallrye-config-1.11.1.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-annotation/1.5.0/smallrye-common-annotation-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-expression/1.5.0/smallrye-common-expression-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-function/1.5.0/smallrye-common-function-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-constraint/1.5.0/smallrye-common-constraint-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-classloader/1.5.0/smallrye-common-classloader-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/config/smallrye-config-common/1.11.1/smallrye-config-common-1.11.1.jar:/home/luca/.m2/repository/org/jboss/logging/jboss-logging/3.4.1.Final/jboss-logging-3.4.1.Final.jar:/home/luca/.m2/repository/org/jboss/logmanager/jboss-logmanager-embedded/1.0.9/jboss-logmanager-embedded-1.0.9.jar:/home/luca/.m2/repository/org/jboss/logging/jboss-logging-annotations/2.2.0.Final/jboss-logging-annotations-2.2.0.Final.jar:/home/luca/.m2/repository/org/jboss/threads/jboss-threads/3.2.0.Final/jboss-threads-3.2.0.Final.jar:/home/luca/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/home/luca/.m2/repository/org/jboss/slf4j/slf4j-jboss-logmanager/1.1.0.Final/slf4j-jboss-logmanager-1.1.0.Final.jar:/home/luca/.m2/repository/org/graalvm/sdk/graal-sdk/21.0.0/graal-sdk-21.0.0.jar:/home/luca/.m2/repository/org/wildfly/common/wildfly-common/1.5.4.Final-format-001/wildfly-common-1.5.4.Final-format-001.jar:/home/luca/.m2/repository/io/quarkus/quarkus-bootstrap-runner/1.13.3.Final/quarkus-bootstrap-runner-1.13.3.Final.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-io/1.5.0/smallrye-common-io-1.5.0.jar:/home/luca/.m2/repository/io/quarkus/quarkus-arc/1.13.3.Final/quarkus-arc-1.13.3.Final.jar:/home/luca/.m2/repository/io/quarkus/arc/arc/1.13.3.Final/arc-1.13.3.Final.jar:/home/luca/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/home/luca/.m2/repository/org/eclipse/microprofile/context-propagation/microprofile-context-propagation-api/1.0.1/microprofile-context-propagation-api-1.0.1.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-support-common/1.8.1/camel-quarkus-support-common-1.8.1.jar:/home/luca/.m2/repository/io/quarkus/quarkus-development-mode-spi/1.13.3.Final/quarkus-development-mode-spi-1.13.3.Final.jar:/home/luca/.m2/repository/org/apache/camel/camel-base/3.9.0/camel-base-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-api/3.9.0/camel-api-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-management-api/3.9.0/camel-management-api-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-util/3.9.0/camel-util-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-componentdsl/3.9.0/camel-componentdsl-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-catalog/3.9.0/camel-core-catalog-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-tooling-model/3.9.0/camel-tooling-model-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-util-json/3.9.0/camel-util-json-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-engine/3.9.0/camel-core-engine-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-base-engine/3.9.0/camel-base-engine-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-reifier/3.9.0/camel-core-reifier-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-model/3.9.0/camel-core-model-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-languages/3.9.0/camel-core-languages-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-processor/3.9.0/camel-core-processor-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-endpointdsl/3.9.0/camel-endpointdsl-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-main/3.9.0/camel-main-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-microprofile-config/3.9.0/camel-microprofile-config-3.9.0.jar:/home/luca/.m2/repository/org/eclipse/microprofile/config/microprofile-config-api/1.4/microprofile-config-api-1.4.jar:/home/luca/.m2/repository/org/apache/camel/camel-timer/3.9.0/camel-timer-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-support/3.9.0/camel-support-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-log/1.8.1/camel-quarkus-log-1.8.1.jar:/home/luca/.m2/repository/org/apache/camel/camel-log/3.9.0/camel-log-3.9.0.jar -d /home/luca/.jbang/cache/jars/q.java.c1b6d94f167d9eb83b35a084a926bd4d23ad863ab94e9ec0780d387d11a1ee25.jar.tmp /home/luca/tmp/scripts/q.java
warning: unknown enum constant XmlAccessType.PROPERTY
  reason: class file for javax.xml.bind.annotation.XmlAccessType not found
warning: unknown enum constant XmlAccessType.NONE
warning: unknown enum constant XmlAccessType.FIELD
warning: unknown enum constant XmlAccessType.PROPERTY
4 warnings
[jbang] Post build with io.quarkus.launcher.JBangIntegration
[jbang] Deleting folder /home/luca/.jbang/cache/jars/q.java.c1b6d94f167d9eb83b35a084a926bd4d23ad863ab94e9ec0780d387d11a1ee25.jar.tmp
[jbang] System Java version matches requested version 11
[jbang] run: /home/luca/.local/sfw/tools/sdkman/candidates/java/current/bin/java -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.dev=true -classpath /home/luca/.jbang/cache/jars/q.java.c1b6d94f167d9eb83b35a084a926bd4d23ad863ab94e9ec0780d387d11a1ee25.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-timer/1.8.1/camel-quarkus-timer-1.8.1.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-core/1.8.1/camel-quarkus-core-1.8.1.jar:/home/luca/.m2/repository/io/quarkus/quarkus-core/1.13.3.Final/quarkus-core-1.13.3.Final.jar:/home/luca/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/home/luca/.m2/repository/jakarta/enterprise/jakarta.enterprise.cdi-api/2.0.2/jakarta.enterprise.cdi-api-2.0.2.jar:/home/luca/.m2/repository/jakarta/el/jakarta.el-api/3.0.3/jakarta.el-api-3.0.3.jar:/home/luca/.m2/repository/jakarta/interceptor/jakarta.interceptor-api/1.2.5/jakarta.interceptor-api-1.2.5.jar:/home/luca/.m2/repository/jakarta/inject/jakarta.inject-api/1.0/jakarta.inject-api-1.0.jar:/home/luca/.m2/repository/io/quarkus/quarkus-ide-launcher/1.13.3.Final/quarkus-ide-launcher-1.13.3.Final.jar:/home/luca/.m2/repository/io/smallrye/config/smallrye-config/1.11.1/smallrye-config-1.11.1.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-annotation/1.5.0/smallrye-common-annotation-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-expression/1.5.0/smallrye-common-expression-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-function/1.5.0/smallrye-common-function-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-constraint/1.5.0/smallrye-common-constraint-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-classloader/1.5.0/smallrye-common-classloader-1.5.0.jar:/home/luca/.m2/repository/io/smallrye/config/smallrye-config-common/1.11.1/smallrye-config-common-1.11.1.jar:/home/luca/.m2/repository/org/jboss/logging/jboss-logging/3.4.1.Final/jboss-logging-3.4.1.Final.jar:/home/luca/.m2/repository/org/jboss/logmanager/jboss-logmanager-embedded/1.0.9/jboss-logmanager-embedded-1.0.9.jar:/home/luca/.m2/repository/org/jboss/logging/jboss-logging-annotations/2.2.0.Final/jboss-logging-annotations-2.2.0.Final.jar:/home/luca/.m2/repository/org/jboss/threads/jboss-threads/3.2.0.Final/jboss-threads-3.2.0.Final.jar:/home/luca/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:/home/luca/.m2/repository/org/jboss/slf4j/slf4j-jboss-logmanager/1.1.0.Final/slf4j-jboss-logmanager-1.1.0.Final.jar:/home/luca/.m2/repository/org/graalvm/sdk/graal-sdk/21.0.0/graal-sdk-21.0.0.jar:/home/luca/.m2/repository/org/wildfly/common/wildfly-common/1.5.4.Final-format-001/wildfly-common-1.5.4.Final-format-001.jar:/home/luca/.m2/repository/io/quarkus/quarkus-bootstrap-runner/1.13.3.Final/quarkus-bootstrap-runner-1.13.3.Final.jar:/home/luca/.m2/repository/io/smallrye/common/smallrye-common-io/1.5.0/smallrye-common-io-1.5.0.jar:/home/luca/.m2/repository/io/quarkus/quarkus-arc/1.13.3.Final/quarkus-arc-1.13.3.Final.jar:/home/luca/.m2/repository/io/quarkus/arc/arc/1.13.3.Final/arc-1.13.3.Final.jar:/home/luca/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/home/luca/.m2/repository/org/eclipse/microprofile/context-propagation/microprofile-context-propagation-api/1.0.1/microprofile-context-propagation-api-1.0.1.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-support-common/1.8.1/camel-quarkus-support-common-1.8.1.jar:/home/luca/.m2/repository/io/quarkus/quarkus-development-mode-spi/1.13.3.Final/quarkus-development-mode-spi-1.13.3.Final.jar:/home/luca/.m2/repository/org/apache/camel/camel-base/3.9.0/camel-base-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-api/3.9.0/camel-api-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-management-api/3.9.0/camel-management-api-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-util/3.9.0/camel-util-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-componentdsl/3.9.0/camel-componentdsl-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-catalog/3.9.0/camel-core-catalog-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-tooling-model/3.9.0/camel-tooling-model-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-util-json/3.9.0/camel-util-json-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-engine/3.9.0/camel-core-engine-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-base-engine/3.9.0/camel-base-engine-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-reifier/3.9.0/camel-core-reifier-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-model/3.9.0/camel-core-model-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-languages/3.9.0/camel-core-languages-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-core-processor/3.9.0/camel-core-processor-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-endpointdsl/3.9.0/camel-endpointdsl-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-main/3.9.0/camel-main-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-microprofile-config/3.9.0/camel-microprofile-config-3.9.0.jar:/home/luca/.m2/repository/org/eclipse/microprofile/config/microprofile-config-api/1.4/microprofile-config-api-1.4.jar:/home/luca/.m2/repository/org/apache/camel/camel-timer/3.9.0/camel-timer-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/camel-support/3.9.0/camel-support-3.9.0.jar:/home/luca/.m2/repository/org/apache/camel/quarkus/camel-quarkus-log/1.8.1/camel-quarkus-log-1.8.1.jar:/home/luca/.m2/repository/org/apache/camel/camel-log/3.9.0/camel-log-3.9.0.jar io.quarkus.launcher.JBangDevModeLauncher
lburgazzoli commented 3 years ago

When running without dev mode, I get the expected behavior

maxandersen commented 3 years ago

This is most likely a quarkus bug not jbang.

Did it work in previous quarkus or jbang versions ?

lburgazzoli commented 3 years ago

I've create a project with:

mvn io.quarkus:quarkus-maven-plugin:1.13.3.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -Dextensions=camel-quarkus-log,camel-quarkus-timer

Amended the generated code to include the camel route and the application.properties file to use the same properties:

quarkus.banner.enabled=false
quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n

And it seems to work as expected:

➜ mvn quarkus:dev
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- quarkus-maven-plugin:1.13.3.Final:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
06:18:17 INFO  [or.ap.ca.qu.co.CamelBootstrapRecorder] (Quarkus Main Thread) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
06:18:17 INFO  [or.ap.ca.im.en.AbstractCamelContext] (Quarkus Main Thread) Routes startup summary (total:1 started:1)
06:18:17 INFO  [or.ap.ca.im.en.AbstractCamelContext] (Quarkus Main Thread)     Started route1 (timer://tick)
06:18:17 INFO  [or.ap.ca.im.en.AbstractCamelContext] (Quarkus Main Thread) Apache Camel 3.9.0 (camel-1) started in 41ms (build:0ms init:32ms start:9ms)
maxandersen commented 3 years ago

yes, but when you do it that way you aren't triggering quarkus parsing of Q:CONFIG :)

i'll give it a go - still think the issue is on quarkus jbang integration side but let me verify.