Skip to content

Commit

Permalink
[fj-doc-maven-plugin] goal init, new parameter : flavourVersion #199
Browse files Browse the repository at this point in the history
[fj-doc-playground-quarkus] doc project init, added flavour version parameter
  • Loading branch information
fugerit79 committed Sep 13, 2024
1 parent 0da53fb commit e989a64
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 60 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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
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,13 @@
package org.fugerit.java.doc.project.facade;

import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.fugerit.java.core.lang.helpers.StringUtils;

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

@Slf4j
@ToString
@RequiredArgsConstructor
public class FlavourContext {
Expand Down Expand Up @@ -33,6 +36,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,7 @@
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.doc.project.facade.flavour.FlavourConfig;
import org.fugerit.java.doc.project.facade.flavour.ProcessEntry;

Expand All @@ -33,6 +34,16 @@ private FlavourFacade() {}

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

private static final Properties FLAVOURS_DEFAULT_VERSION = SafeFunction.get( () -> {
Properties versions = new Properties();
versions.setProperty( FLAVOUR_QUARKUS_3, "3.14.3" );
versions.setProperty( FLAVOUR_QUARKUS_2, "2.16.12.Final" );
versions.setProperty( FLAVOUR_MICRONAUT_4, "4.6.2" );
versions.setProperty( FLAVOUR_SPRINGBOOT_3, "3.3.3" );
versions.setProperty( FLAVOUR_OPENLIBERTY, "20.0.0.9" );
return versions;
} );

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 +74,14 @@ 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 );
// additional flavour config
if ( StringUtils.isEmpty( context.getFlavourVersion() ) ) {
String flavourVersionDefault = FLAVOURS_DEFAULT_VERSION.getProperty( context.getFlavour() );
log.info( "using default flavourVersion : {} for flavour : {}", flavourVersionDefault, context.getFlavour() );
context.setFlavourVersion( flavourVersionDefault );
} else {
log.info( "overriding default flavourVersion : {} for flavour : {}", context.getFlavourVersion(), context.getFlavour() );
}
}

private static void initFlavour( FlavourContext context, String actualFlavour ) throws IOException, TemplateException {
Expand Down
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.6.2</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.3</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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<version>${context.flavourVersion}</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>${context.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<#import 'flavour-macro.ftl' as fhm>
---
flavour: vanilla
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void testFlavourContext() {
Assert.assertThrows( ConfigRuntimeException.class, () -> FlavourFacade.checkFlavour( context, FlavourFacade.FLAVOUR_QUARKUS_3 ) );
FlavourFacade.checkFlavour( context, FlavourFacade.FLAVOUR_QUARKUS_2 );
FlavourFacade.checkFlavour( new FlavourContext( testFile, "group-id5", "artifact-id5", "3.0.0-SNAPSHOT", "11", "unsupported" ), FlavourFacade.FLAVOUR_QUARKUS_2 );
context.setFlavourVersion( "test" );
Assert.assertEquals( "test", context.getFlavourVersion() );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class ProjectInitInput {
@Pattern( regexp = "[A-Za-z0-9- ]+", flags = Pattern.Flag.DOTALL )
@Getter @Setter private String flavour;

@Pattern( regexp = "[A-Za-z0-9-\\.]+", flags = Pattern.Flag.DOTALL )
@Getter @Setter private String flavourVersion;

@Getter @Setter private List<String> extensionList;

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
this.addJunit5 = true;
this.addLombok = true;
this.flavour = data.getFlavour();
this.flavourVersion = data.getFlavourVersion();
super.execute();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TextField from '@mui/material/TextField';
import CircularProgress from '@mui/material/CircularProgress';
import Button from '@mui/material/Button';
import Box from '@mui/material/Box';
import { Grid, Typography } from '@mui/material';
import { Grid, Typography, Paper } from '@mui/material';
import Alert from '@mui/material/Alert';
import appService from '../common/app-service';

Expand All @@ -22,8 +22,9 @@ const DocProjectInit = () => {
const [artifactId, setArtifactId] = useState('fugerit-doc-demo'); // State to handle artifactId input
const [projectVersion, setProjectVersion] = useState('1.0.0-SNAPSHOT'); // State to handle projectVersion input
const [javaVersion, setJavaVersion] = useState('21'); // State to handle javaVersion selection
const [venusVersion, setVenusVersion] = useState(availableVersions[0]); // State to handle javaVersion selection
const [flavour, setFlavour] = useState('vanilla'); // State to handle javaVersion selection
const [venusVersion, setVenusVersion] = useState(availableVersions[0]); // State to handle venusVersion selection
const [flavour, setFlavour] = useState('vanilla'); // State to handle flavour selection
const [flavourVersion, setFlavourVersion] = useState(''); // State to handle flavourVersion selection
const [isSubmitting, setIsSubmitting] = useState(false); // State to manage submit button loading state
const [serverMessage, setServerMessage] = useState(''); // State to store the message from the server response
const [serverContent, setServerContent] = useState(''); // State to store the base64 encoded content from the server
Expand Down Expand Up @@ -80,11 +81,16 @@ const DocProjectInit = () => {
setVenusVersion(event.target.value);
};

// Handle change event for venusVersion select
// Handle change event for flavour select
const handleFlavourChange = (event) => {
setFlavour(event.target.value);
};

// Handle change event for flavourVersion select
const handleFlavourVersionChange = (event) => {
setFlavourVersion(event.target.value);
};

// Handle the submit button click
const handleSubmit = async () => {
setIsSubmitting(true); // Set loading state to true when submission starts
Expand Down Expand Up @@ -217,6 +223,17 @@ const DocProjectInit = () => {
</Select>
</FormControl>
</Grid>
<Grid item xs={12} sm={12}>
{/* Text field for flavourVersion */}
<TextField
label="Flavour version, recommended : leave default (blank)"
variant="outlined"
fullWidth
margin="normal"
value={flavourVersion}
onChange={handleFlavourVersionChange}
/>
</Grid>
<Grid item xs={12} sm={12}>
{loading ? (
<CircularProgress /> // Show loading spinner while data is being fetched
Expand Down

0 comments on commit e989a64

Please sign in to comment.