Skip to content

Commit

Permalink
200 fj doc maven plugin goal init new parameter flavourversion (#201)
Browse files Browse the repository at this point in the history
* [fj-doc-maven-plugin] goal init, flavour quarkus-3, default quarkus version 3.14.3

* - [fj-doc-maven-plugin] goal init, flavour micronaut-4, default micronaut version 4.6.2

* Added flavour default to readme

- [fj-doc-maven-plugin] goal init, flavour quarkus-2, default quarkus version 2.16.12.Final
- [fj-doc-maven-plugin] goal init, flavour springboot-3, default springboot version 3.3.3
- [fj-doc-maven-plugin] goal init, flavour openliberty, default openliberty version 24.0.0.9

* [fj-doc-maven-plugin] goal init, new parameter : flavourVersion #199

[fj-doc-playground-quarkus] doc project init, added flavour version parameter

* Sonar cloud issues #199

* [fj-doc-maven-plugin] goal init, generation of flavour 'vanilla' was bugged

* Fixed sonar issues #199

* Remove codacy issues #199

* Mark down issue #199
  • Loading branch information
fugerit79 authored Sep 13, 2024
1 parent 9a4309e commit 0807df9
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 78 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [fj-doc-maven-plugin] goal init, new parameter : flavourVersion
- [fj-doc-playground-quarkus] doc project init, added flavour version parameter
- [fj-doc-maven-plugin] goal init, flavour quarkus-2, default quarkus version 2.16.12.Final
- [fj-doc-maven-plugin] goal init, flavour springboot-3, default springboot version 3.3.3
- [fj-doc-maven-plugin] goal init, flavour openliberty, default openliberty version 24.0.0.9
- [fj-doc-maven-plugin] goal init, flavour micronaut-4, default micronaut version 4.6.2
- [fj-doc-maven-plugin] goal init, flavour quarkus-3, default quarkus version 3.14.3
- [fj-doc-playground-quarkus] doc project init, default venus version 8.8.5
- [fj-doc-playground-quarkus] quarkus version set to 3.14.3

### Fixed

- [fj-doc-maven-plugin] goal init, generation of flavour 'vanilla' was bugged

## [8.8.5] - 2024-09-12

### Changed
Expand Down
41 changes: 22 additions & 19 deletions fj-doc-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,28 @@ Project folder will be `./${artifactId}/`.

### Init Fugerit Venus, parameters

| parameter | required | default | description |
|----------------|----------|----------------|---------------------------------------------------------|
| groupId | true | | new project group id |
| artifactId | true | | new project group id |
| projectVersion | true | 1.0.0-SNAPSHOT | new project version |
| javaRelease | true | 21 | java release version |
| flavour | true | vanilla | the flavour for the new project (see below for options) |

NOTE: it is possible to set any property from 'add' goal, except 'projectFolder' which is set to `./${artifactId}`.

| flavour | description | constraints | note |
|----------------|-----------------------------------------|-------------|-----------------------------------------------------|
| vanilla | basic Venus configuration | | a vanilla maven project will be configured |
| quarkus-latest | project based on quarkus latest version | java >= 17 | currently from the quarkus 3.X branch |
| quarkus-2 | project based on quarkus 2 | java == 11 | 2.16.12.Final is the latest version for quarkus 2.x |
| quarkus-3 | project based on quarkus 3 | java >= 17 | currently same as quarkus-latest |
| springboot-3 | project based on springboot 3 | java >= 17 | based on SpringBoot 3.x |
| micronaut-4 | project based on micronaut 4 | java >= 17 | based on Micronaut 4.x |
| openliberty | project based on openliberty | java >= 17 | based on OpenLiberty |
| parameter | required | default | description |
|----------------|----------|----------------|----------------------------------------------------------------------------------------|
| groupId | true | | new project group id |
| artifactId | true | | new project artifact id |
| projectVersion | true | 1.0.0-SNAPSHOT | new project version |
| javaRelease | true | 21 | java release version |
| flavour | true | vanilla | the flavour for the new project (see below for options) |
| flavourVersion | false | see below | override default framework version if supported (recommended : leave default or blank) |

NOTE:

- it is possible to set any property from 'add' goal, except 'projectFolder' which is set to `./${artifactId}`.

| flavour | description | constraints | note | default flavourVersion |
|----------------|-----------------------------------------|-------------|-----------------------------------------------------|------------------------|
| vanilla | basic Venus configuration | | a vanilla maven project will be configured | |
| quarkus-latest | project based on quarkus latest version | java >= 17 | currently from the quarkus 3.X branch | as quarkus-3 |
| quarkus-2 | project based on quarkus 2 | java == 11 | 2.16.12.Final is the latest version for quarkus 2.x | 2.16.12.Final |
| quarkus-3 | project based on quarkus 3 | java >= 17 | currently same as quarkus-latest | 3.14.3 |
| springboot-3 | project based on springboot 3 | java >= 17 | based on SpringBoot 3.x | 3.3.3 |
| micronaut-4 | project based on micronaut 4 | java >= 17 | based on Micronaut 4.x | 4.6.2 |
| openliberty | project based on openliberty | java >= 17 | based on OpenLiberty | 20.0.0.9 |

## Goal : verify

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class MojoInit extends MojoAdd {
@Parameter(property = "flavour", defaultValue = "vanilla", required = true)
protected String flavour;

@Parameter(property = "flavourVersion", required = false)
protected String flavourVersion;

public MojoInit() {
this.baseInitFolder = ".";
}
Expand All @@ -56,6 +59,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
FlavourContext context = new FlavourContext( new File( this.projectFolder ), this.groupId, this.artifactId, this.projectVersion, this.javaRelease, this.flavour );
context.setModules( ModuleFacade.toModuleList( this.extensions ) );
context.setAddLombok( this.addLombok );
context.setFlavourVersion( this.flavourVersion );
this.getLog().info( String.format( "flavour context : %s", context ) );
FlavourFacade.initProject( context );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.fugerit.java.doc.project.facade;

import lombok.*;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.util.List;

@Slf4j
@ToString
@RequiredArgsConstructor
public class FlavourContext {
Expand Down Expand Up @@ -33,6 +35,9 @@ public class FlavourContext {
@Getter @Setter
private boolean addLombok;

@Getter @Setter
private String flavourVersion;

private String toClassName( String base, String splitString ) {
StringBuilder buf = new StringBuilder();
String[] split = base.split( splitString );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.io.StreamIO;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.core.util.PropsIO;
import org.fugerit.java.doc.project.facade.flavour.FlavourConfig;
import org.fugerit.java.doc.project.facade.flavour.ProcessEntry;

Expand All @@ -33,6 +35,8 @@ private FlavourFacade() {}

public static final String FLAVOUR_SPRINGBOOT_3 = "springboot-3";

private static final Properties FLAVOURS_DEFAULT_VERSION = PropsIO.loadFromClassLoaderSafe( "config/flavour/flavour_versions_default.properties" );

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, FLAVOUR_OPENLIBERTY ) ) );
Expand Down Expand Up @@ -63,6 +67,18 @@ public static void checkFlavour( FlavourContext context, String actualFlavour )
log.info( "quarkus 2 is a legacy flavour, javaRelease %s will default to '11'", javaVersion );
}
log.info( "checkFlavour {} done", actualFlavour );
checkFlavourVersion( context, actualFlavour );
}

public static void checkFlavourVersion( FlavourContext context, String actualFlavour ) {
// additional flavour config
if ( StringUtils.isEmpty( context.getFlavourVersion() ) ) {
String flavourVersionDefault = FLAVOURS_DEFAULT_VERSION.getProperty( actualFlavour );
log.info( "using default flavourVersion : {} for flavour : {}", flavourVersionDefault, actualFlavour );
context.setFlavourVersion( flavourVersionDefault );
} else {
log.info( "overriding default flavourVersion : {} for flavour : {}", context.getFlavourVersion(), actualFlavour );
}
}

private static void initFlavour( FlavourContext context, String actualFlavour ) throws IOException, TemplateException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# default flavour versions
quarkus-3=3.14.3
quarkus-2=2.16.12.Final
micronaut-4=4.6.2
springboot-3=3.3.3
openliberty=20.0.0.9
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: micronaut-4
flavour: ${context.flavour}
process:
- from: flavour/micronaut-4/pom.ftl
- from: flavour/${context.flavour}/pom.ftl
to: ${context.projectFolder}/pom.xml
- from: flavour/micronaut-4/README.ftl
- from: flavour/${context.flavour}/README.ftl
to: ${context.projectFolder}/README.md
- from: flavour/micronaut-4/gitignore.ftl
- from: flavour/${context.flavour}/gitignore.ftl
to: ${context.projectFolder}/.gitignore
- from: flavour/micronaut-4/MicronautController.ftl
- from: flavour/${context.flavour}/MicronautController.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/${context.artifactIdAsClassName}Controller.java
- from: flavour/micronaut-4/DocController.ftl
- from: flavour/${context.flavour}/DocController.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocController.java
- from: flavour/micronaut-4/Application.ftl
- from: flavour/${context.flavour}/Application.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/Application.java
- from: flavour/micronaut-4/MicronautTest.ftl
- from: flavour/${context.flavour}/MicronautTest.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/${context.artifactIdAsClassName}Test.java
- from: flavour/micronaut-4/application_yml.ftl
- from: flavour/${context.flavour}/application_yml.ftl
to: ${context.projectFolder}/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>io.micronaut.platform</groupId>
<artifactId>micronaut-parent</artifactId>
<version>4.5.0</version>
<version>${context.flavourVersion}</version>
</parent>
<properties>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: openliberty
flavour: ${context.flavour}
process:
- from: flavour/openliberty/pom.ftl
- from: flavour/${context.flavour}/pom.ftl
to: ${context.projectFolder}/pom.xml
- from: flavour/openliberty/README.ftl
- from: flavour/${context.flavour}/README.ftl
to: ${context.projectFolder}/README.md
- from: flavour/openliberty/gitignore.ftl
- from: flavour/${context.flavour}/gitignore.ftl
to: ${context.projectFolder}/.gitignore
- from: flavour/openliberty/server.ftl
- from: flavour/${context.flavour}/server.ftl
to: ${context.projectFolder}/src/main/liberty/config/server.xml
- from: flavour/openliberty/web.ftl
- from: flavour/${context.flavour}/web.ftl
to: ${context.projectFolder}/src/main/webapp/WEB-INF/web.xml
- from: flavour/openliberty/RestApplication.ftl
- from: flavour/${context.flavour}/RestApplication.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/RestApplication.java
- from: flavour/openliberty/GreetingResource.ftl
- from: flavour/${context.flavour}/GreetingResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingResource.java
- from: flavour/openliberty/DocResource.ftl
- from: flavour/${context.flavour}/DocResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.release>${context.javaRelease}</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<openliberty-runtime-version>24.0.0.9</openliberty-runtime-version>
<openliberty-runtime-version>${context.flavourVersion}</openliberty-runtime-version>
<liberty-maven-plugin-version>3.10.3</liberty-maven-plugin-version>
<microprofile-version>6.1</microprofile-version>
<liberty.var.default.http.port>8080</liberty.var.default.http.port>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: quarkus-2
flavour: ${context.flavour}
process:
- from: flavour/quarkus-2/pom.ftl
- from: flavour/${context.flavour}/pom.ftl
to: ${context.projectFolder}/pom.xml
- from: flavour/quarkus-2/README.ftl
- from: flavour/${context.flavour}/README.ftl
to: ${context.projectFolder}/README.md
- from: flavour/quarkus-2/gitignore.ftl
- from: flavour/${context.flavour}/gitignore.ftl
to: ${context.projectFolder}/.gitignore
- from: flavour/quarkus-2/GreetingConfig.ftl
- from: flavour/${context.flavour}/GreetingConfig.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingConfig.java
- from: flavour/quarkus-2/GreetingResource.ftl
- from: flavour/${context.flavour}/GreetingResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingResource.java
- from: flavour/quarkus-2/GreetingResourceTest.ftl
- from: flavour/${context.flavour}/GreetingResourceTest.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/GreetingResourceTest.java
- from: flavour/quarkus-2/GreetingResourceIT.ftl
- from: flavour/${context.flavour}/GreetingResourceIT.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/GreetingResourceIT.java
- from: flavour/quarkus-2/DocResource.ftl
- from: flavour/${context.flavour}/DocResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocResource.java
- from: flavour/quarkus-2/DocResourceTest.ftl
- from: flavour/${context.flavour}/DocResourceTest.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/DocResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>2.16.12.Final</quarkus.platform.version>
<quarkus.platform.version>${context.flavourVersion}</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.3.1</surefire-plugin.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: quarkus-3
flavour: ${context.flavour}
process:
- from: flavour/quarkus-3/pom.ftl
- from: flavour/${context.flavour}/pom.ftl
to: ${context.projectFolder}/pom.xml
- from: flavour/quarkus-3/README.ftl
- from: flavour/${context.flavour}/README.ftl
to: ${context.projectFolder}/README.md
- from: flavour/quarkus-3/gitignore.ftl
- from: flavour/${context.flavour}/gitignore.ftl
to: ${context.projectFolder}/.gitignore
- from: flavour/quarkus-3/GreetingConfig.ftl
- from: flavour/${context.flavour}/GreetingConfig.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingConfig.java
- from: flavour/quarkus-3/GreetingResource.ftl
- from: flavour/${context.flavour}/GreetingResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/GreetingResource.java
- from: flavour/quarkus-3/GreetingResourceTest.ftl
- from: flavour/${context.flavour}/GreetingResourceTest.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/GreetingResourceTest.java
- from: flavour/quarkus-3/GreetingResourceIT.ftl
- from: flavour/${context.flavour}/GreetingResourceIT.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/GreetingResourceIT.java
- from: flavour/quarkus-3/DocResource.ftl
- from: flavour/${context.flavour}/DocResource.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocResource.java
- from: flavour/quarkus-3/DocResourceTest.ftl
- from: flavour/${context.flavour}/DocResourceTest.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/DocResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.14.2</quarkus.platform.version>
<quarkus.platform.version>${context.flavourVersion}</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.3.1</surefire-plugin.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: springboot-3
flavour: ${context.flavour}
process:
- from: flavour/springboot-3/pom.ftl
- from: flavour/${context.flavour}/pom.ftl
to: ${context.projectFolder}/pom.xml
- from: flavour/springboot-3/README.ftl
- from: flavour/${context.flavour}/README.ftl
to: ${context.projectFolder}/README.md
- from: flavour/springboot-3/gitignore.ftl
- from: flavour/${context.flavour}/gitignore.ftl
to: ${context.projectFolder}/.gitignore
- from: flavour/springboot-3/SpringbootApplication.ftl
- from: flavour/${context.flavour}/SpringbootApplication.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/${context.artifactIdAsClassName}Application.java
- from: flavour/springboot-3/DocController.ftl
- from: flavour/${context.flavour}/DocController.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/DocController.java
- from: flavour/springboot-3/SpringbootApplication.ftl
- from: flavour/${context.flavour}/SpringbootApplication.ftl
to: ${context.projectFolder}/src/main/java/<@fhm.toProjectPackageFolder context=context/>/${context.artifactIdAsClassName}Application.java
- from: flavour/springboot-3/SpringbootApplicationTests.ftl
- from: flavour/${context.flavour}/SpringbootApplicationTests.ftl
to: ${context.projectFolder}/src/test/java/test/<@fhm.toProjectPackageFolder context=context/>/${context.artifactIdAsClassName}ApplicationTests.java
- from: flavour/springboot-3/application.ftl
- from: flavour/${context.flavour}/application.ftl
to: ${context.projectFolder}/src/main/resources/application.yaml
Loading

0 comments on commit 0807df9

Please sign in to comment.