Skip to content

Commit 38bec18

Browse files
authored
[fj-doc-maven-plugin] goal init, add openliberty flavour #193 (#198)
[fj-doc-playground-quarkus] fix springboot-3 flavour on doc project init
1 parent 9bfb2e8 commit 38bec18

File tree

14 files changed

+299
-4
lines changed

14 files changed

+299
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- [fj-doc-maven-plugin] goal init, added openapi documentation for flavour 'openliberty' #193
13+
14+
### Fixed
15+
16+
- [fj-doc-playground-quarkus] springboot-3 flavour on doc project init
17+
1018
## [8.8.4] - 2024-09-11
1119

1220
### Changed

fj-doc-maven-plugin/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ NOTE: it is possible to set any property from 'add' goal, except 'projectFolder'
103103
|----------------|-----------------------------------------|-------------|-----------------------------------------------------|
104104
| vanilla | basic Venus configuration | | a vanilla maven project will be configured |
105105
| quarkus-latest | project based on quarkus latest version | java >= 17 | currently from the quarkus 3.X branch |
106-
| quarkus-2 | project based on quarkus 2 | java >= 11 | 2.16.12.Final is the latest version for quarkus 2.x |
106+
| quarkus-2 | project based on quarkus 2 | java == 11 | 2.16.12.Final is the latest version for quarkus 2.x |
107107
| quarkus-3 | project based on quarkus 3 | java >= 17 | currently same as quarkus-latest |
108+
| springboot-3 | project based on springboot 3 | java >= 17 | based on SpringBoot 3.x |
109+
| micronaut-4 | project based on micronaut 4 | java >= 17 | based on Micronaut 4.x |
110+
| openliberty | project based on openliberty | java >= 17 | based on OpenLiberty |
108111

109112
## Goal : verify
110113

fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FlavourFacade.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ private FlavourFacade() {}
2929

3030
public static final String FLAVOUR_MICRONAUT_4 = "micronaut-4";
3131

32+
public static final String FLAVOUR_OPENLIBERTY = "openliberty";
33+
3234
public static final String FLAVOUR_SPRINGBOOT_3 = "springboot-3";
3335

34-
public static final Set<String> SUPPORTED_FLAVOURS = Collections.unmodifiableSet( new HashSet<>( Arrays.asList( FLAVOUR_VANILLA, FLAVOUR_QUARKUS_3, FLAVOUR_QUARKUS_2, FLAVOUR_MICRONAUT_4, FLAVOUR_SPRINGBOOT_3 ) ) );
36+
public static final Set<String> SUPPORTED_FLAVOURS = Collections.unmodifiableSet(
37+
new HashSet<>( Arrays.asList( FLAVOUR_VANILLA, FLAVOUR_QUARKUS_3, FLAVOUR_QUARKUS_2,
38+
FLAVOUR_MICRONAUT_4, FLAVOUR_SPRINGBOOT_3, FLAVOUR_OPENLIBERTY ) ) );
3539

3640
private static final Properties MAP_FLAVOURS = SafeFunction.get( () -> {
3741
Properties prop = new Properties();
@@ -52,7 +56,8 @@ public static void initProject( FlavourContext context ) throws IOException, Tem
5256

5357
public static void checkFlavour( FlavourContext context, String actualFlavour ) {
5458
int javaVersion = Integer.parseInt( context.getJavaRelease() );
55-
if ( ( FLAVOUR_QUARKUS_3.equals( actualFlavour ) || FLAVOUR_MICRONAUT_4.equals( actualFlavour ) ) && javaVersion < 17 ) {
59+
if ( ( FLAVOUR_QUARKUS_3.equals( actualFlavour ) || FLAVOUR_MICRONAUT_4.equals( actualFlavour )
60+
|| FLAVOUR_SPRINGBOOT_3.equals( actualFlavour ) || FLAVOUR_OPENLIBERTY.equals( actualFlavour ) ) && javaVersion < 17 ) {
5661
throw new ConfigRuntimeException( String.format( "Minimum java version for %s is 17", actualFlavour ) );
5762
} else if ( FLAVOUR_QUARKUS_2.equals( actualFlavour ) && javaVersion != 11 ) {
5863
log.info( "quarkus 2 is a legacy flavour, javaRelease %s will default to '11'", javaVersion );
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile
2+
.dockerignore
3+
src/main/resources/META-INF/microprofile-config.properties
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<#import 'flavour-macro.ftl' as fhm>
2+
---
3+
flavour: openliberty
4+
process:
5+
- from: flavour/openliberty/pom.ftl
6+
to: ${context.projectFolder}/pom.xml
7+
- from: flavour/openliberty/README.ftl
8+
to: ${context.projectFolder}/README.md
9+
- from: flavour/openliberty/gitignore.ftl
10+
to: ${context.projectFolder}/.gitignore
11+
- from: flavour/openliberty/server.ftl
12+
to: ${context.projectFolder}/src/main/liberty/config/server.xml
13+
- from: flavour/openliberty/web.ftl
14+
to: ${context.projectFolder}/src/main/webapp/WEB-INF/web.xml
15+
- from: flavour/openliberty/RestApplication.ftl
16+
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/RestApplication.java
17+
- from: flavour/openliberty/GreetingResource.ftl
18+
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingResource.java
19+
- from: flavour/openliberty/DocResource.ftl
20+
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocResource.java
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<#import '../flavour-macro.ftl' as fhm>
2+
package <@fhm.toProjectPackage context=context/>;
3+
4+
import jakarta.ws.rs.GET;
5+
import jakarta.ws.rs.Path;
6+
import jakarta.ws.rs.Produces;
7+
import jakarta.ws.rs.WebApplicationException;
8+
import jakarta.ws.rs.core.MediaType;
9+
import lombok.extern.slf4j.Slf4j;
10+
import org.fugerit.java.doc.base.config.DocConfig;
11+
import org.fugerit.java.doc.base.process.DocProcessContext;
12+
13+
import java.io.ByteArrayOutputStream;
14+
import java.util.Arrays;
15+
import java.util.List;
16+
17+
import org.eclipse.microprofile.openapi.annotations.Operation;
18+
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
19+
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
20+
import org.eclipse.microprofile.openapi.annotations.tags.Tags;
21+
22+
@Slf4j
23+
@Path("/doc")
24+
public class DocResource {
25+
26+
<@fhm.createDocumentProcess context=context exceptionType='WebApplicationException'/>
27+
28+
<@fhm.createQuarkusPath context=context outputMime="text/markdown" outputExtension="md" outputDescription="Markdown"/>
29+
30+
<@fhm.createQuarkusPath context=context outputMime="text/html" outputExtension="html" outputDescription="HTML"/>
31+
32+
<#if context.modules?seq_contains("fj-doc-mod-fop")>
33+
<@fhm.createQuarkusPath context=context outputMime="application/pdf" outputExtension="pdf" outputDescription="PDF"/>
34+
</#if>
35+
36+
<#if context.modules?seq_contains("fj-doc-mod-poi")>
37+
<@fhm.createQuarkusPath context=context outputMime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" outputExtension="xlsx" outputDescription="Excel"/>
38+
</#if>
39+
40+
<#if context.modules?seq_contains("fj-doc-mod-opencsv")>
41+
<@fhm.createQuarkusPath context=context outputMime="text/csv" outputExtension="csv" outputDescription="CSV"/>
42+
</#if>
43+
44+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<#import '../flavour-macro.ftl' as fhm>
2+
package <@fhm.toProjectPackage context=context/>;
3+
4+
import jakarta.ws.rs.GET;
5+
import jakarta.ws.rs.Path;
6+
import jakarta.ws.rs.Produces;
7+
import jakarta.ws.rs.core.MediaType;
8+
9+
@Path("/hello")
10+
public class GreetingResource {
11+
12+
@GET
13+
@Produces(MediaType.TEXT_PLAIN)
14+
public String hello() {
15+
return "Hello from Open Liberty REST";
16+
}
17+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ${context.artifactId}
2+
3+
## Quickstart
4+
5+
Requirement :
6+
- maven 3.9.x
7+
- java ${context.javaRelease}+
8+
9+
1. Start the app
10+
11+
```shell
12+
mvn clean package liberty:run
13+
```
14+
15+
2. Try the app
16+
17+
Open the [openapi ui](http://localhost:8080/openapi/ui/)
18+
19+
Test available paths (for instance : [/doc/example.md](http://localhost:8080/doc/example.md))
20+
21+
## Overview
22+
23+
This project has been initialized using [fj-doc-maven-plugin init goal](https://venusguides.fugerit.org/src/docs/wizard/fj-doc-maven-plugin_init.html).
24+
25+
The OpenLiberty structure is similar to using [https://openliberty.io/start/](https://openliberty.io/start/)
26+
27+
28+
## OpenLiberty readme
29+
30+
After you generate a starter project, these instructions will help you with what to do next.
31+
32+
The Open Liberty starter gives you a simple, quick way to get the necessary files to start building
33+
an application on Open Liberty. There is no need to search how to find out what to add to your
34+
Maven build files. A simple RestApplication.java file is generated for you to start
35+
creating a REST based application. A server.xml configuration file is provided with the necessary
36+
features for the MicroProfile and Jakarta EE versions that you previously selected.
37+
38+
If you plan on developing and/or deploying your app in a containerized environment, the included
39+
Dockerfile will make it easier to create your application image on top of the Open Liberty Docker
40+
image.
41+
42+
1) Once you download the starter project, unpackage the .zip file on your machine.
43+
2) Open a command line session, navigate to the installation directory, and run `./mvnw liberty:dev` (Linux/Mac) or `mvnw liberty:dev` (Windows).
44+
This will install all required dependencies and start the default server. When complete, you will
45+
see the necessary features installed and the message "server is ready to run a smarter planet."
46+
47+
For information on developing your application in dev mode using Maven, see the
48+
dev mode documentation (https://openliberty.io/docs/latest/development-mode.html).
49+
50+
For further help on getting started actually developing your application, see some of our
51+
MicroProfile guides (https://openliberty.io/guides/?search=microprofile&key=tag) and Jakarta EE
52+
guides (https://openliberty.io/guides/?search=jakarta%20ee&key=tag).
53+
54+
If you have problems building the starter project, make sure the Java SE version on your
55+
machine matches the Java SE version you picked from the Open Liberty starter on the downloads
56+
page (https://openliberty.io/downloads/). You can test this with the command `java -version`.
57+
58+
Open Liberty performs at its best when running using Open J9 which can be obtained via IBM Semeru
59+
(https://developer.ibm.com/languages/java/semeru-runtimes/downloads/). For a full list of supported
60+
Java SE versions and where to obtain them, reference the Java SE support page
61+
(https://openliberty.io/docs/latest/java-se.html).
62+
63+
If you find any issues with the starter project or have recommendations to improve it, open an
64+
issue in the starter GitHub repo (https://github.com/OpenLiberty/start.openliberty.io).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<#import '../flavour-macro.ftl' as fhm>
2+
package <@fhm.toProjectPackage context=context/>;
3+
4+
import jakarta.ws.rs.ApplicationPath;
5+
import jakarta.ws.rs.core.Application;
6+
7+
@ApplicationPath("/")
8+
public class RestApplication extends Application {
9+
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
release.properties
7+
dependency-reduced-pom.xml
8+
buildNumber.properties
9+
.mvn/timing.properties
10+
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
11+
.mvn/wrapper/maven-wrapper.jar

0 commit comments

Comments
 (0)