Skip to content

Commit

Permalink
docs: Improve gradle docs by adding kotlin snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Malandril committed Jan 6, 2025
1 parent 825bcb8 commit 019dd43
Show file tree
Hide file tree
Showing 12 changed files with 485 additions and 27 deletions.
20 changes: 20 additions & 0 deletions docs/src/main/asciidoc/aws-lambda.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ for your lambda deployment.

Example Gradle dependencies:

[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
dependencies {
Expand All @@ -297,6 +300,23 @@ dependencies {
testImplementation 'io.rest-assured:rest-assured'
}
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("io.quarkus:quarkus-resteasy")
implementation("io.quarkus:quarkus-amazon-lambda")
testImplementation("io.quarkus:quarkus-junit5")
testImplementation("io.rest-assured:rest-assured")
}
----
****


== Live Coding and Unit/Integration Testing
Expand Down
166 changes: 152 additions & 14 deletions docs/src/main/asciidoc/building-my-first-extension.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -404,31 +404,66 @@ As mentioned before, an extension is composed of two modules:
* `runtime`
* `deployment`

We are going to create a Gradle multi-module project with those two modules. Here is a simple `settings.gradle` example file:
We are going to create a Gradle multi-module project with those two modules.

[source, groovy]
Here is a simple `settings.gradle` example file:

[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy,subs=attributes+]
----
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
plugins {
id 'io.quarkus.extension' version "${quarkus.version}" <1>
id 'io.quarkus.extension' version "{quarkus-version}" <1>
}
}
include 'runtime', 'deployment' <2>
rootProject.name = 'greeting-extension'
----
****

<1> Configure the quarkus extension plugin version
<2> Include both `runtime` and `deployment` modules

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin,subs=attributes+]
----
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
plugins {
id("io.quarkus.extension") version "{quarkus-version}" <1>
}
}
include("runtime", "deployment") <2>
rootProject.name = "greeting-extension"
----
****

<1> Configure the quarkus extension plugin version
<2> Include both `runtime` and `deployment` modules

NOTE: For kotlin add the `.kts` extension the build files, for example: `settings.gradle.kts`

Here is a sample of a root `build.gradle` file:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
subprojects {
apply plugin: 'java-library' <1>
Expand All @@ -438,6 +473,26 @@ subprojects {
version '1.0-SNAPSHOT'
}
----
****

<1> Apply the `java-library` plugin for all sub-modules
<2> Apply the `maven-publish` plugin used to publish our artifacts
<3> Globally set the group id used for publication

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
subprojects {
apply(plugin = "java-library") // <1>
apply(plugin = "maven-publish") // <2>
group = "org.acme" <3>
version = "1.0-SNAPSHOT"
}
----
****

<1> Apply the `java-library` plugin for all sub-modules
<2> Apply the `maven-publish` plugin used to publish our artifacts
Expand All @@ -449,24 +504,44 @@ The plugin will *only* be applied to the `runtime` module.
==== The deployment module

The deployment module does not require any specific plugin.
Here is an example of a minimal `build.gradle` file for the `deployment` module:
Here is an example of a minimal gradle build file for the `deployment` module:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy,subs=attributes+]
----
name = 'greeting-extension-deployment' <1>
dependencies {
implementation project(':runtime') <2>
implementation platform("io.quarkus:quarkus-bom:${quarkus.version}")
implementation 'io.quarkus:quarkus-arc-deployment'
implementation platform("{quarkus-platform-groupid}:quarkus-bom:{quarkus-version}")
testImplementation 'io.quarkus:quarkus-junit5-internal'
}
----
****

<1> By convention, the deployment module has the `-deployment` suffix (`greeting-extension-deployment`).
<2> The deployment module *must* depend on the `runtime` module.

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin,subs=attributes+]
----
dependencies {
implementation(project(":runtime")) <1>
implementation("io.quarkus:quarkus-arc-deployment")
implementation(platform("{quarkus-platform-groupid}:quarkus-bom:{quarkus-version}"))
testImplementation("io.quarkus:quarkus-junit5-internal")
}
----
****

<1> The deployment module *must* depend on the `runtime` module.

==== The runtime module

The runtime module applies the `io.quarkus.extension` plugin. This will:
Expand All @@ -476,7 +551,10 @@ The runtime module applies the `io.quarkus.extension` plugin. This will:

Here is an example of `build.gradle` file for the `runtime` module:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy,subs=attributes+]
----
plugins {
id 'io.quarkus.extension' <1>
Expand All @@ -486,13 +564,33 @@ name = 'greeting-extension' <2>
description = 'Greeting extension'
dependencies {
implementation platform("io.quarkus:quarkus-bom:${quarkus.version}")
implementation platform("{quarkus-platform-groupid}:quarkus-bom:{quarkus-version}")
}
----
****

<1> Apply the `io.quarkus.extension` plugin.
<2> By convention, the runtime module doesn't have a suffix (and thus is named `greeting-extension`) as it is the artifact exposed to the end user.

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin,subs=attributes+]
----
plugins {
id("io.quarkus.extension") // <1>
}
description = "Greeting extension"
dependencies {
implementation(platform("{quarkus-platform-groupid}:quarkus-bom:{quarkus-version}"))
}
----
****

<1> Apply the `io.quarkus.extension` plugin.

== Basic version of the Sample Greeting extension

=== Implementing the Greeting feature
Expand All @@ -515,10 +613,23 @@ All we need to do is add `quarkus-undertow` as dependency to our `./greeting-ext

For Gradle, add the dependency in `./greeting-extension/runtime/build.gradle` file:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
implementation 'io.quarkus:quarkus-undertow'
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
implementation("io.quarkus:quarkus-undertow")
----
****

NOTE: The dependency on `quarkus-arc` generated by the `create-extension` mojo can now be removed since
`quarkus-undertow` already depends on it.
Expand Down Expand Up @@ -620,10 +731,23 @@ NOTE: The dependency on `quarkus-arc-deployment` generated by the `create-extens

For Gradle, add the dependency in `./greeting-extension/deployment/build.gradle` file:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
implementation 'io.quarkus:quarkus-undertow-deployment'
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
implementation("io.quarkus:quarkus-undertow-deployment")
----
****

We can now update `org.acme.greeting.extension.deployment.GreetingExtensionProcessor`:

Expand Down Expand Up @@ -683,11 +807,25 @@ Let's add the `rest-assured` dependency into the `./greeting-extension/deployme

For Gradle, add the dependency in `./greeting-extension/deployment/build.gradle` file:

[source, groovy]
[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
...
testImplementation 'io.rest-assured:rest-assured'
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
...
testImplementation("io.rest-assured:rest-assured")
----
****


The `create-extension` Maven Mojo can create the test and integration-test structure (drop the `-DwithoutTests`). Here, we'll create it ourselves:
Expand Down
13 changes: 13 additions & 0 deletions docs/src/main/asciidoc/cassandra.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,23 @@ by modifying the compiler plugin configuration in the project's `pom.xml` file a

With Gradle, this is done by adding the following line to the `build.gradle` file:

[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
annotationProcessor "com.datastax.oss.quarkus:cassandra-quarkus-mapper-processor:${cassandra-quarkus.version}"
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
annotationProcessor("com.datastax.oss.quarkus:cassandra-quarkus-mapper-processor:${cassandra-quarkus.version}")
----
****

IMPORTANT: Verify that you are enabling the right annotation processor! The Cassandra driver ships
with its Object Mapper annotation processor, called `java-driver-mapper-processor`. But the
Expand Down
15 changes: 15 additions & 0 deletions docs/src/main/asciidoc/grpc-service-implementation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,27 @@ Having it, you can run the dev mode with: `mvn quarkus:dev -Pdevelopment`.

If you use Gradle, you can simply add a dependency for the `quarkusDev` task:

[role="primary asciidoc-tabs-sync-groovy"]
.Groovy DSL
****
[source,groovy]
----
dependencies {
quarkusDev 'io.quarkus:quarkus-vertx-http'
}
----
****

[role="secondary asciidoc-tabs-sync-kotlin"]
.Kotlin DSL
****
[source,kotlin]
----
dependencies {
quarkusDev("io.quarkus:quarkus-vertx-http")
}
----
****

== gRPC Server metrics

Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/asciidoc/infinispan-client-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ This command adds the following dependency to your build file:
</dependency>
----

[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle",subs=attributes+]
.build.gradle
----
implementation 'io.quarkus:quarkus-infinispan-client'
annotationProcessor 'org.infinispan.protostream:protostream-processor:{infinispan-protostream-version}' <1>
implementation("io.quarkus:quarkus-infinispan-client")
annotationProcessor("org.infinispan.protostream:protostream-processor:{infinispan-protostream-version}") <1>
----
<1> Mandatory in the Gradle build to enable the generation of the files in the annotation based serialization

Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/infinispan-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ This will add the following to your build file:
</dependency>
----

[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle",subs=attributes+]
.build.gradle
----
implementation("io.quarkus:quarkus-infinispan-client")
annotationProcessor 'org.infinispan.protostream:protostream-processor:4.6.1.Final' <1>
annotationProcessor("org.infinispan.protostream:protostream-processor:{infinispan-protostream-version}") <1>
----
<1> Mandatory in the Gradle build to enable the generation of the files in the annotation based serialization

Expand Down
Loading

0 comments on commit 019dd43

Please sign in to comment.