Skip to content

Commit 4b3ab1d

Browse files
committed
doc: make sure libraries version are sync/up-to-date with Maven
1 parent 036f079 commit 4b3ab1d

10 files changed

Lines changed: 115 additions & 24 deletions

File tree

docs/asciidoc/handlers/rate-limit.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rate limit handler using https://github.com/vladimir-bukhtoyarov/bucket4j[Bucket
44

55
Add the dependency to your project:
66

7-
[dependency, artifactId="bucket4j-core"]
7+
[dependency, artifactId="bucket4j-core", version="{bucket4j_core_version}", subs="verbatim,attributes"]
88
.
99

1010
.10 requests per minute

docs/asciidoc/index.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Style guidelines:
1717
////
1818

1919
= Welcome to Jooby!
20-
by Edgar Espina
2120
{joobyVersion}
2221

2322
[discrete]

docs/asciidoc/modules/avaje-inject.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
1) Add Avaje Inject to your project
44

5-
[dependency, groupId="io.jooby", artifactId="jooby-avaje-inject", version="1.1.0"]
5+
[dependency, artifactId="jooby-avaje-inject"]
66
.
77

88
2) Configure annotation processor
99

1010
.Maven
11-
[source, xml, role = "primary"]
11+
[source, xml, role = "primary", subs="verbatim,attributes"]
1212
----
1313
<build>
1414
<plugins>
@@ -21,7 +21,7 @@
2121
<path>
2222
<groupId>io.avaje</groupId>
2323
<artifactId>avaje-inject-generator</artifactId>
24-
<version>10.3</version>
24+
<version>{avaje_inject_version}</version>
2525
</path>
2626
</annotationProcessorPaths>
2727
</configuration>
@@ -31,14 +31,14 @@
3131
----
3232

3333
.Gradle
34-
[source, kotlin, role = "secondary"]
34+
[source, kotlin, role = "secondary", subs="verbatim,attributes"]
3535
----
3636
plugins {
3737
id "org.jetbrains.kotlin.kapt" version "1.9.10"
3838
}
3939
4040
dependencies {
41-
kapt 'io.avaje:avaje-inject-generator:10.0'
41+
kapt 'io.avaje:avaje-inject-generator:{avaje.inject.version}'
4242
}
4343
----
4444

@@ -127,7 +127,7 @@ public class App extends Jooby {
127127
{
128128
install(AvajeInjectModule.of()); <1>
129129
130-
mvc(MyController.class); <2>
130+
mvc(MyController.class); <2>
131131
}
132132
133133
public static void main(String[] args) {
@@ -143,7 +143,7 @@ fun main(args: Array<String>) {
143143
runApp(args) {
144144
install(AvajeInjectModule.of()) <1>
145145
146-
mvc(MyController::class) <2>
146+
mvc(MyController::class) <2>
147147
}
148148
}
149149
----

docs/asciidoc/modules/avaje-validator.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Bean validation via https://avaje.io/validator/[Avaje Validator].
1212
2) Configure annotation processor
1313

1414
.Maven
15-
[source, xml, role = "primary"]
15+
[source, xml, role = "primary", subs="verbatim,attributes"]
1616
----
1717
<build>
1818
<plugins>
@@ -25,7 +25,7 @@ Bean validation via https://avaje.io/validator/[Avaje Validator].
2525
<path>
2626
<groupId>io.avaje</groupId>
2727
<artifactId>avaje-validator-generator</artifactId>
28-
<version>2.1</version>
28+
<version>{avajeValidatorVersion}</version>
2929
</path>
3030
</annotationProcessorPaths>
3131
</configuration>
@@ -35,14 +35,14 @@ Bean validation via https://avaje.io/validator/[Avaje Validator].
3535
----
3636

3737
.Gradle
38-
[source, kotlin, role = "secondary"]
38+
[source, kotlin, role = "secondary", subs="verbatim,attributes"]
3939
----
4040
plugins {
4141
id "org.jetbrains.kotlin.kapt" version "1.9.10"
4242
}
4343
4444
dependencies {
45-
kapt 'io.avaje:avaje-validator-generator:2.1'
45+
kapt 'io.avaje:avaje-validator-generator:{avajeValidatorVersion}'
4646
}
4747
----
4848

@@ -177,6 +177,7 @@ It also supports validating list, array, and map of beans
177177
catches `ConstraintViolationException` and transforms it into the following response:
178178

179179
.JSON:
180+
[source, json]
180181
----
181182
{
182183
"title": "Validation failed",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
== AmazonWebServices
2+
3+
Amazon Web Services module for https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html[aws-sdk-java 2.x]
4+
5+
=== Usage
6+
7+
1) Add the dependency:
8+
9+
[dependency, artifactId="jooby-awssdk-v2", version="{aws_java_sdk_version}", subs="verbatim,attributes"]
10+
.
11+
12+
2) Add required service dependency (S3 here):
13+
14+
[dependency, artifactId="s3"]
15+
.
16+
17+
3) Add the `aws.accessKeyId` and `aws.secretKey` properties:
18+
19+
.application.conf
20+
[source, properties]
21+
----
22+
aws.accessKeyId = "your access key id"
23+
aws.secretKey = "your secret key"
24+
----
25+
26+
This step is optional if you choose one of the https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html[default credentials mechanism].
27+
28+
4) Install
29+
30+
.Java
31+
[source,java,role="primary"]
32+
----
33+
import io.jooby.awssdkv2.AwsModule;
34+
35+
{
36+
install(
37+
new AwsModule() <1>
38+
.setup(credentials -> { <2>
39+
var s3 = S3Client.builder().build();
40+
var s3transfer = S3TransferManager.builder().s3Client(s3).build();
41+
return Stream.of(s3, s3transfer);
42+
})
43+
)
44+
);
45+
}
46+
----
47+
48+
.Kotlin
49+
[source, kt, role="secondary"]
50+
----
51+
import io.jooby.awssdkv2.AwsModule
52+
53+
{
54+
install(
55+
AwsModule() <1>
56+
.setup { credentials -> <2>
57+
val s3 = S3Client.builder().build()
58+
val s3transfer = S3TransferManager.builder().s3Client(s3).build()
59+
return Stream.of(s3, s3transfer)
60+
}
61+
)
62+
);
63+
}
64+
----
65+
66+
<1> Install module
67+
<2> Setup one or more services
68+
69+
Services created from setup function are:
70+
71+
- Registered in the application service registry, for require call usage or DI framework
72+
- Services are shutdown at application shutdown time

docs/asciidoc/modules/hibernate-validator.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ It also supports validating list, array, and map of beans
140140
catches `ConstraintViolationException` and transforms it into the following response:
141141

142142
.JSON:
143+
[source, json]
143144
----
144145
{
145146
"title": "Validation failed",

docs/asciidoc/modules/modules.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ configuration properties.
1414
Available modules are listed next.
1515

1616
=== Cloud
17-
* link:/modules/aws[AWS]: Amazon Web Service module.
17+
* link:/modules/awssdkv2[AWS-SDK v2]: Amazon Web Service module SDK 2.
18+
* link:/modules/aws[AWS SDK v1]: Amazon Web Service module SDK 1.
1819

1920
=== Data
2021
* link:/modules/ebean[Ebean]: Ebean ORM module.

docs/src/main/java/io/jooby/adoc/DependencyProcessor.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
package io.jooby.adoc;
77

88
import java.io.IOException;
9-
import java.util.ArrayList;
10-
import java.util.List;
11-
import java.util.Map;
12-
import java.util.Optional;
9+
import java.util.*;
1310
import java.util.function.Consumer;
1411

1512
import org.asciidoctor.ast.StructuralNode;
@@ -28,18 +25,28 @@ public Object process(StructuralNode parent, Reader reader, Map<String, Object>
2825
List<String> lines = new ArrayList<>();
2926
String[] artifactId = ((String) attributes.get("artifactId")).split("\\s*,\\s*");
3027

28+
var groupId = (String) attributes.get("groupId");
29+
var version = (String) attributes.get("version");
30+
if (version== null || version.trim().isEmpty()) {
31+
if (artifactId.length== 1 && !artifactId[0].startsWith("jooby")) {
32+
version = Optional.ofNullable(Dependencies.get(artifactId[0])).map(it -> it.version).orElse(null);
33+
if (version== null) {
34+
throw new IllegalArgumentException("Dependency without version: " + groupId + ":" + Arrays.toString(artifactId));
35+
}
36+
}
37+
}
3138
maven(
32-
(String) attributes.get("groupId"),
39+
groupId,
3340
artifactId,
34-
(String) attributes.get("version"),
41+
version,
3542
lines::add);
3643

3744
lines.add("");
3845

3946
gradle(
40-
(String) attributes.get("groupId"),
47+
groupId,
4148
artifactId,
42-
(String) attributes.get("version"),
49+
version,
4350
lines::add);
4451
lines.add("");
4552

docs/src/main/java/io/jooby/adoc/DocApp.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public class DocApp extends Jooby {
3434

3535
Path site = DocGenerator.basedir().resolve("asciidoc").resolve("site");
3636
assets("/*", site);
37+
38+
onStarted(() ->
39+
getLog().info("Access to maven properties is available from ascii files. If you want to access to `${avaje.inject.version}` uses the `{avaje_inject_version}` syntax and make sure to set the `subs` attribute, like:\n\n" +
40+
"[source, xml, role = \"primary\", subs=\"verbatim,attributes\"]\n" +
41+
" .... {avaje_inject_version}\n")
42+
);
3743
}
3844

3945
public static void main(String[] args) throws Exception {

docs/src/main/java/io/jooby/adoc/DocGenerator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,12 @@ private static Options createOptions(Path basedir, Path outdir, String version,
279279
// versions:
280280
Document pom =
281281
Jsoup.parse(DocGenerator.basedir().getParent().resolve("pom.xml").toFile(), "UTF-8");
282-
pom.select("properties > *").stream()
283-
.forEach(tag -> attributes.setAttribute(toJavaName(tag.tagName()), tag.text().trim()));
282+
pom.select("properties > *").forEach(tag -> {
283+
var tagName = tag.tagName();
284+
var value = tag.text().trim();
285+
Stream.of(tagName, tagName.replaceAll("[.-]", "_"), tagName.replaceAll("[.-]", "-"), toJavaName(tagName))
286+
.forEach(key -> attributes.setAttribute(key, value));
287+
});
284288

285289
attributes.setAttribute("joobyVersion", version);
286290
attributes.setAttribute("date", DateTimeFormatter.ISO_INSTANT.format(Instant.now()));

0 commit comments

Comments
 (0)