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
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>${context.groupId}</groupId>
8+
<artifactId>${context.artifactId}</artifactId>
9+
<version>${context.projectVersion}</version>
10+
<packaging>war</packaging>
11+
12+
<properties>
13+
<maven.compiler.source>${context.javaRelease}</maven.compiler.source>
14+
<maven.compiler.target>${context.javaRelease}</maven.compiler.target>
15+
<maven.compiler.release>${context.javaRelease}</maven.compiler.release>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18+
<openliberty-runtime-version>24.0.0.9</openliberty-runtime-version>
19+
<liberty-maven-plugin-version>3.10.3</liberty-maven-plugin-version>
20+
<microprofile-version>6.1</microprofile-version>
21+
<liberty.var.default.http.port>8080</liberty.var.default.http.port>
22+
<liberty.var.default.https.port>8443</liberty.var.default.https.port>
23+
<junit-bom-version>5.11.0</junit-bom-version>
24+
</properties>
25+
26+
<dependencyManagement>
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.junit</groupId>
30+
<artifactId>junit-bom</artifactId>
31+
<version>${r"${junit-bom-version}"}</version>
32+
<type>pom</type>
33+
<scope>import</scope>
34+
</dependency>
35+
</dependencies>
36+
</dependencyManagement>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>io.openliberty</groupId>
41+
<artifactId>openliberty-runtime</artifactId>
42+
<version>${r"${openliberty-runtime-version}"}</version>
43+
<type>zip</type>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.eclipse.microprofile</groupId>
47+
<artifactId>microprofile</artifactId>
48+
<version>${r"${microprofile-version}"}</version>
49+
<type>pom</type>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-api</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.junit.jupiter</groupId>
59+
<artifactId>junit-jupiter-engine</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<finalName>fugerit-openliberty-template</finalName>
66+
<pluginManagement>
67+
<plugins>
68+
<plugin>
69+
<groupId>io.openliberty.tools</groupId>
70+
<artifactId>liberty-maven-plugin</artifactId>
71+
<version>${r"${liberty-maven-plugin-version}"}</version>
72+
</plugin>
73+
</plugins>
74+
</pluginManagement>
75+
<plugins>
76+
<plugin>
77+
<groupId>io.openliberty.tools</groupId>
78+
<artifactId>liberty-maven-plugin</artifactId>
79+
<configuration>
80+
<serverName>libertyServer</serverName>
81+
<runtimeArtifact>
82+
<groupId>io.openliberty</groupId>
83+
<artifactId>openliberty-runtime</artifactId>
84+
<version>${r"${openliberty-runtime-version}"}</version>
85+
<type>zip</type>
86+
</runtimeArtifact>
87+
</configuration>
88+
</plugin>
89+
</plugins>
90+
</build>
91+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<server description="Fugerit Open Liberty server">
2+
<featureManager>
3+
<feature>mpHealth-4.0</feature>
4+
<feature>restfulWS-3.1</feature>
5+
<feature>mpOpenAPI-3.1</feature>
6+
</featureManager>
7+
<httpEndpoint host="*" httpPort="${r"${default.http.port}"}" httpsPort="${r"${default.https.port}"}" id="defaultHttpEndpoint" />
8+
<webApplication location="${context.artifactId}.war" contextRoot="/" />
9+
</server>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
3+
version="3.1">
4+
<display-name>Liberty Project</display-name>
5+
6+
<welcome-file-list>
7+
<welcome-file>index.html</welcome-file>
8+
</welcome-file-list>
9+
</web-app>

fj-doc-playground-quarkus/src/main/react/src/playground/DocProjectInit.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ const DocProjectInit = () => {
217217
<MenuItem value={'quarkus-3'}>Quarkus 3 (Recommended quarkus version)</MenuItem>
218218
<MenuItem value={'quarkus-2'}>Quarkus 2 (Legacy quarkus version)</MenuItem>
219219
<MenuItem value={'micronaut-4'}>Micronaut 4</MenuItem>
220-
<MenuItem value={'micronaut-3'}>SpringBoot 3</MenuItem>
220+
<MenuItem value={'springboot-3'}>SpringBoot 3</MenuItem>
221+
<MenuItem value={'openliberty'}>OpenLiberty</MenuItem>
221222
</Select>
222223
</FormControl>
223224
</Grid>

0 commit comments

Comments
 (0)