Skip to content

Commit

Permalink
Merge pull request #41744 from cescoffier/jbang-qute-doc-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoffier authored Jul 7, 2024
2 parents b8fbbed + 17dccdd commit 7e98e77
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions docs/src/main/asciidoc/scripting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,29 @@ With that in place running `jbang quarkusapp.java` will log and render as expect

== Configuring Application

You can use `//Q:CONFIG <property>=<value>` to set up static configuration for your application.
To configure the application you can use the `application.properties` file as usual, but you need to _add_ it to the script:

I.e. if you wanted to add the `smallrye-openapi` and `swagger-ui` extensions and have the Swagger UI always show up you would add the following:
[source,java]
----
//FILES application.properties
[source,java,subs=attributes+]
// ...
@ConfigProperty(name = "prefix", defaultValue = "WG -")
String prefix;
----

This will make the `application.properties` file available to the script, and process the configuration as usual.

You can also use the `application.yaml` file.
For this, you need to _add_ it to the `application.yaml` file to the script and include the `quarkus-config-yaml` dependency:

[source,java]
----
//DEPS io.quarkus:quarkus-smallrye-openapi:{quarkus-version}
//DEPS io.quarkus:quarkus-swagger-ui:{quarkus-version}
//Q:CONFIG quarkus.swagger-ui.always-include=true
//DEPS io.quarkus:quarkus-config-yaml
//FILES application.yaml
----

Now during build the `quarkus.swagger-ui.always-include` will be generated into the resulting jar and `http://0.0.0.0:8080/q/swagger-ui` will be available when run.
NOTE: The path to the `application.properties` and `application.yaml` files are relative to the script file.

== Running as a native application

Expand Down Expand Up @@ -440,6 +451,23 @@ __ ____ __ _____ ___ __ ____ ______
2023-03-22 09:38:45,450 INFO [io.quarkus] (main) Installed features: [cdi, rest, smallrye-context-propagation, vertx]
----

=== Using Qute

You can use the xref:./qute.adoc[Qute templating engine] in your JBang script by adding the `quarkus-qute` dependency.
You also need to include the `templates` directory in the script:
[source,java]
----
//DEPS io.quarkus:quarkus-qute
//FILES templates/=templates/*
// ...
@Inject
Template template; // Locate and load the `templates/template.html` file
----

If your `templates` directory includes sub-directories, use `templates/=templates/**/*` instead.

=== Conclusion

If you want to get started with Quarkus or write something quickly, Quarkus Scripting with jbang lets you do that. No Maven, no Gradle - just a Java file. In this guide we outlined the very basics on using Quarkus with JBang; if you want to learn more about what JBang can do, go see https://jbang.dev.

0 comments on commit 7e98e77

Please sign in to comment.