In a previous post we learned about setting the value of options
attribute to nowrap
on listing and literal blocks, so the lines in the block are not wrapped.
In the comments a user suggested another option to disable line wrapping for all listing and literal blocks in the document by using the document attribute prewrap
.
We must negate the document attribute, :prewrap!:
, to disable all wrapping.
If we place this document attribute at the top of our Asciidoctor document it is applied for the whole document.
We can also place it at other places in the document to change the setting for all listing and literal blocks following the prewrap
document attribute.
To enable wrapping again we set :prewrap:
(leaving out the exclamation mark).
In the following example we have markup with a listing, literal and example block and we use the document attribute :prewrap!:
to disable the wrapping for the listing and literal blocks:
Continue reading →
Since Gradle 5 we can easily use a bill of materials (BOM) in our build file to get recommended dependency versions. The dependency versions defined in the BOM are dependency constraints in Gradle. This means the dependencies we define in our build that are part of the BOM don’t need a version, because the version is resolved via the dependency constraint that is defined in the BOM. Also transitive dependency versions are resolved using the BOM if applicable. We use the dependency handler method platform
to define the BOM we want to import. The versions in the BOM are recommendations. We can override the recommendation by specifying the version for a dependency found in the BOM with an explicit version.
Continue reading →
From Maven builds we know the dependencyManagement
section in our POM file. In the section we can describe dependencies with their version and later in the dependencies
section we can refer to the dependency without the version. We can use dependency constraints in Gradle to do the same thing. A dependency constraint can be used to define the version or version range for a dependency defined in our scripts or a transitive dependency. Just like a dependency the dependency constraint is defined for a configuration, so we can fine tune the constraints to the correct configuration.
Using dependency constraints in a multi-project build allows us to define the dependency versions in the root build file and define project dependencies per project without a version. The version will then be used from the dependency constraint we defined in the root build file.
Continue reading →
Since Asciidoctor 2.0.0 we can add the collapsible
option to an example block. When the markup is generated to HTML we get a HTML details
and summary
section. The content of the example block is collapsed (default behaviour because it is in a details
section) and a clickable text is available to open the collapsed block (the summary
section), so we can see the actual content. The text we can click on is by default Details, but we can change that by setting the title of the example block. Then the title is used as the text to click on to open the collapsed content.
Continue reading →
With the release of Asciidoctor 2.0.0 we get nice help on the basic syntax of Asciidoc with the command-line option --help syntax
.
This gives us samples of the syntax in Asciidoc markup.
As mentioned by Dan Allen on Twitter we can pipe the syntax sample to Asciidoctor itself to get a HTML page:
Continue reading →
Micronaut can convert String values defined as a number followed by (case-insensitive) KB/MB/GB
to a number value in certain cases.
The conversion service in Micronaut supports the @ReadableBytes
annotation that we can apply to a method parameter.
Micronaut will then parse the String value and convert it to a number.
The value 1Kb
is converted to 1024
.
We can use this for example in a configuration class or path variable in a controller.
Continue reading →
Micronaut supports the RFC-6570 URI template specification to define URI variables in a path definition.
The path definition can be a value of the @Controller
annotation or any of the routing annotations for example @Get
or @Post
.
We can define a path variable as {?binding*}
to support binding of request parameters to all properties of an object type that is defined as method argument with the name binding
.
We can even use the Bean Validation API (JSR380) to validate the values of the request parameters if we add an implementation of this API to our class path.
Continue reading →
Working with SQL database from Groovy code is very easy using the groovy.sql.Sql
class. The class has several methods to execute a SQL query, but we have to take special care if we use methods from Sql
that take a GString
argument. Groovy will extract all variable expressions and use them as values for placeholders in a PreparedStatement
constructed from the SQL query. If we have variable expressions that should not be extracted as parameters for a PreparedStatement
we must use the Sql.expand
method. This method will make the variable expression a groovy.sql.ExpandedVariable
object. This object is not used as parameter for a PreparedStatement
query, but the value is evaluated as GString
variable expression.
Continue reading →
Spring Boot 2.1 introduced log groups. A log group is a logical name for one or more loggers. We can define log groups in our application configuration. Then we can set the log level for a group, so all loggers in the group will get the same log level. This can be very useful to change a log level for multiple loggers that belong together with one setting. Spring Boot already provides two log groups by default: web and sql. In the following list we see which loggers are part of the default log groups:
- web
-
org.springframework.core.codec
, org.springframework.http
, org.springframework.web
, org.springframework.boot.actuate.endpoint.web
, org.springframework.boot.web.servlet.ServletContextInitializerBeans
- sql
-
org.springframework.jdbc.core
, org.hibernate.SQL
Continue reading →
To get an overview of all Gradle tasks in our project we need to run the tasks
task. Since Gradle 5.1 we can use the --group
option followed by a group name. Gradle will then show all tasks belonging to the group and not the other tasks in the project.
Suppose we have a Gradle Java project and want to show the tasks that belong to the build group:
Continue reading →
In a previous post we learned how to include parts of a document in the generated output.
The included parts are defined using tags.
The start of a tag is defined in a comment with the format tag::_tagName_[]
and the end has the format end::_tagName_[]
.
Next we must use the tags
attribute for the include
macro followed by the tagName.
If we don’t want to include a tag we must prefix it with an exclamation mark (!
).
Continue reading →
Since Java 9 we can specify that the Javadoc output must be generated in HTML 5 instead of the default HTML 4. We need to pass the option -html5
to the javadoc
tool. To do this in Gradle we must add the option to the javadoc
task configuration. We use the addBooleanOption
method of the options
property that is part of the javadoc
task. We set the argument to html5
and the value to true
.
In the following example we reconfigure the javadoc
task to make sure the generated Javadoc output is in HTML 5:
Continue reading →