Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- fj-doc-maven-plugin, init goal, 'addFormatting' <https://github.com/fugerit-org/fj-doc/issues/541>

### Changed

- quarkus-version set to 3.28.3 across all the modules <https://github.com/fugerit-org/fj-doc/issues/539>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Whereas the link:https://github.com/fugerit-org/fj-doc/blob/main/CHANGELOG.md[CH
[#doc-release-notes-unreleased]
==== Unreleased

- fj-doc-maven-plugin, init goal, 'addFormatting' parameter link:https://github.com/fugerit-org/fj-doc/issues/541[#541]

[#doc-release-notes-8-16-9]
==== Version 8.16.9 [2025-10-06]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ Project folder will be `./${artifactId}/`.
| 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)
| addJacoco | false | false | add jacoco coverage support
| addJacoco (*) | false | false | add jacoco coverage support
| addFormatting (*) | false | false | add maven plugin formatter with rules from link:https://github.com/fugerit-org/fugerit-code-rules[fugerit-code-rules]
|====================================================================================================================================

(*) Currently not working on gradle flavours

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

[#flavour-list]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class MojoInit extends MojoAdd {
@Parameter(property = "addJacoco", defaultValue = "false", required = false)
protected boolean addJacoco;

@Parameter(property = "addFormatting", defaultValue = "false", required = false)
protected boolean addFormatting;

public MojoInit() {
this.baseInitFolder = ".";
}
Expand Down Expand Up @@ -68,6 +71,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
context.setExtensions( this.extensions );
context.setBasePackage( this.basePackage );
context.setAddJacoco( this.addJacoco );
context.setAddFormatting( this.addFormatting );
this.getLog().info( String.format( "flavour context : %s", context ) );
String actualVersion = FlavourFacade.initProject( context );
if ( FlavourFacade.FLAVOUR_DIRECT.equals( actualVersion ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static boolean addVenusToMavenProject( File pomFile, VenusContext context
} else {
log.info( "Generation complete:\n{}\n* For usage open the example main() : {} *\n{}", LINE, context.getDocConfigPackage()+"."+context.getDocConfigClass()+"Example", LINE );
}
log.info( "for documentation refer to https://github.com/fugerit-org/fj-doc/blob/main/fj-doc-maven-plugin/README.md" );
log.info( "for documentation refer to https://venusdocs.fugerit.org/guide/#maven-plugin-entry" );
}
return true;
} );
Expand Down Expand Up @@ -202,14 +202,17 @@ public void generateBody() {
this.println( " * " );
this.println( " * Consider using a @ApplicationScoped or Singleton approach." );
this.println( " */" );
this.println( " private FreemarkerDocProcessConfig docProcessConfig = FreemarkerDocProcessConfigFacade.loadConfigSafe( \"cl://"+this.context.getResourcePathFmConfigXml()+"\" );" );
this.println( " private final FreemarkerDocProcessConfig docProcessConfig = FreemarkerDocProcessConfigFacade" );
this.println( " .loadConfigSafe(\"cl://"+this.context.getResourcePathFmConfigXml()+"\");" );
this.println();
this.println( " /**" );
this.println( " * Accessor for FreemarkerDocProcessConfig configuration." );
this.println( " *" );
this.println( " * @return the FreemarkerDocProcessConfig instance associated with this helper." );
this.println( " */" );
this.println( " public FreemarkerDocProcessConfig getDocProcessConfig() { return this.docProcessConfig; }" );
this.println( " public FreemarkerDocProcessConfig getDocProcessConfig() {" );
this.println( " return this.docProcessConfig;" );
this.println( " }" );
this.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,25 @@ public class FlavourContext {
@Getter @Setter
private boolean addJacoco;

@Getter @Setter
private boolean addFormatting;

public String getDefaultJacocoVersion() {
return FlavourFacade.getFlavourDefaultVersion().getProperty( "jacoco-plugin-version" );
}

public String getDefaultFormatterPluginVersion() {
return FlavourFacade.getFlavourDefaultVersion().getProperty( "mvn-formatter-plugin-version" );
}

public String getDefaultFugeritCodeRulesVersion() {
return FlavourFacade.getFlavourDefaultVersion().getProperty( "fugerit-code-rules-version" );
}

public String getDefaultFormatSkip() {
return FlavourFacade.getFlavourDefaultVersion().getProperty( "format.skip" );
}

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 @@ -9,4 +9,11 @@ springboot-3=3.5.6
openliberty=25.0.0.9

# other general properties
jacoco-plugin-version=0.8.13

# coverage
jacoco-plugin-version=0.8.13

# formatting
mvn-formatter-plugin-version=2.29.0
fugerit-code-rules-version=0.1.1
format.skip=false
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,39 @@ public class DocHelper {
public FreemarkerDocProcessConfig getDocProcessConfig() { return this.docProcessConfig; }

}
</#macro>

<#macro addFormattingPomProperties context>
<!-- formatter plugin -->
<mvn-formatter-plugin-version>${context.defaultFormatterPluginVersion}</mvn-formatter-plugin-version>
<fugerit-code-rules-version>${context.defaultFugeritCodeRulesVersion}</fugerit-code-rules-version>
<format.skip>${context.defaultFormatSkip}</format.skip>
</#macro>

<#macro addFormattingPomPlugin context>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${r"${mvn-formatter-plugin-version}"}</version>
<dependencies>
<dependency>
<groupId>org.fugerit.java</groupId>
<artifactId>fugerit-code-rules</artifactId>
<version>${r"${fugerit-code-rules-version}"}</version>
</dependency>
</dependencies>
<configuration>
<configFile>org/fugerit/java/coderules/eclipse-format.xml</configFile>
<skip>${r"${format.skip}"}</skip>
</configuration>
<executions>
<execution>
<id>format-sources</id>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
</#macro>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<exec.mainClass><@fhm.toProjectPackage context=context/>.Application</exec.mainClass>
<#if context.addJacoco >
<jacoco-plugin-version>${context.defaultJacocoVersion}</jacoco-plugin-version>
</#if>
<#if context.addFormatting >
<@fhm.addFormattingPomProperties context=context/>
</#if>
</properties>

Expand Down Expand Up @@ -166,6 +169,10 @@
</plugin>
</#if>

<#if context.addFormatting >
<@fhm.addFormattingPomPlugin context=context/>
</#if>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<#import '../flavour-macro.ftl' as fhm><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${context.groupId}</groupId>
Expand All @@ -16,6 +16,9 @@
<skipITs>true</skipITs>
<surefire-plugin.version>3.3.1</surefire-plugin.version>
<freemarker-native-version>1.0.0</freemarker-native-version>
<#if context.addFormatting >
<@fhm.addFormattingPomProperties context=context/>
</#if>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -128,6 +131,9 @@
</systemPropertyVariables>
</configuration>
</plugin>
<#if context.addFormatting >
<@fhm.addFormattingPomPlugin context=context/>
</#if>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<#import '../flavour-macro.ftl' as fhm><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${context.groupId}</groupId>
Expand All @@ -16,6 +16,9 @@
<skipITs>true</skipITs>
<surefire-plugin.version>3.3.1</surefire-plugin.version>
<freemarker-native-version>1.0.0</freemarker-native-version>
<#if context.addFormatting >
<@fhm.addFormattingPomProperties context=context/>
</#if>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -132,6 +135,9 @@
</systemPropertyVariables>
</configuration>
</plugin>
<#if context.addFormatting >
<@fhm.addFormattingPomPlugin context=context/>
</#if>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<#import '../flavour-macro.ftl' as fhm><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand All @@ -17,6 +17,9 @@
<java.version>${context.javaRelease}</java.version>
<springdoc-openapi-ui-version>2.8.13</springdoc-openapi-ui-version>
<junit-jupiter.version>5.11.3</junit-jupiter.version>
<#if context.addFormatting >
<@fhm.addFormattingPomProperties context=context/>
</#if>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -66,6 +69,9 @@
</excludes>
</configuration>
</plugin>
<#if context.addFormatting >
<@fhm.addFormattingPomPlugin context=context/>
</#if>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<#import '../flavour-macro.ftl' as fhm><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${context.groupId}</groupId>
Expand All @@ -10,33 +10,39 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<#if context.addJacoco >
<jacoco-plugin-version>${context.defaultJacocoVersion}</jacoco-plugin-version>
</#if>
<#if context.addFormatting >
<@fhm.addFormattingPomProperties context=context/>
</#if>
</properties>

<#if context.addJacoco >
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${r"${jacoco-plugin-version}"}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</#if>
<build>
<plugins>
<#if context.addJacoco >
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${r"${jacoco-plugin-version}"}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</#if>
<#if context.addFormatting >
<@fhm.addFormattingPomPlugin context=context/>
</#if>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,35 @@
* https://github.com/fugerit-org/fj-doc
*
* NOTE: This is a 'Hello World' style example, adapt it to your scenario, especially :<#if !context.addLombok >
* - remove system out and system err with your logging system</#if>
* - change the doc handler and the output mode (here a ByteArrayOutputStream buffer is used)
* - remove system out and system err with your logging system</#if>
* - change the doc handler and the output mode (here a ByteArrayOutputStream buffer is used)
*/
</#macro>

<#macro createExampleBody context junit className>
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
// creates the doc helper
DocHelper docHelper = new DocHelper();
// create custom data for the fremarker template 'document.ftl'
List<People> listPeople = Arrays.asList( new People( "Luthien", "Tinuviel", "Queen" ), new People( "Thorin", "Oakshield", "King" ) );
<#if context.modules?seq_contains("fj-doc-base-json")>// json source supported, if you want to try it, use the chainId "document-json"</#if>
<#if context.modules?seq_contains("fj-doc-base-yaml")>// yaml source supported, if you want to try it, use the chainId "document-yaml"</#if>
List<People> listPeople = Arrays.asList(
new People("Luthien", "Tinuviel", "Queen"), new People("Thorin", "Oakshield", "King"));
<#if context.modules?seq_contains("fj-doc-base-json")>// json source supported, if you want to try it, use the chainId "document-json"</#if><#if context.modules?seq_contains("fj-doc-base-yaml")>// yaml source supported, if you want to try it, use the chainId "document-yaml"</#if>
String chainId = "document";
<#if context.preVersion862 >
// find the handler for the output :
DocTypeHandler docTypeHandler = docHelper.getDocProcessConfig().getFacade().findHandler(DocConfig.TYPE_MD);
// output generation
docHelper.getDocProcessConfig().fullProcess( chainId, DocProcessContext.newContext( "listPeople", listPeople ), docTypeHandler, DocOutput.newOutput( baos ) );
docHelper.getDocProcessConfig().fullProcess(chainId,
DocProcessContext.newContext("listPeople", listPeople), docTypeHandler, DocOutput.newOutput(baos));
<#else>
// handler id
String handlerId = DocConfig.TYPE_MD;
// output generation
docHelper.getDocProcessConfig().fullProcess( chainId, DocProcessContext.newContext( "listPeople", listPeople ), handlerId, baos );
docHelper.getDocProcessConfig().fullProcess(chainId,
DocProcessContext.newContext("listPeople", listPeople), handlerId, baos);
</#if>
// print the output
<#if context.addLombok >log.info( "{} output : \n{}", handlerId, new String( baos.toByteArray(), StandardCharsets.UTF_8 ) );<#else>System.out.println( handlerId+" output : \n"+ new String( baos.toByteArray(), StandardCharsets.UTF_8 ) );</#if>
<#if junit >Assertions.assertNotEquals( 0, baos.size() );</#if>
<#if context.addLombok >log.info("{} output : \n{}", handlerId, new String(baos.toByteArray(), StandardCharsets.UTF_8));<#else>System.out.println(handlerId+" output : \n"+ new String(baos.toByteArray(), StandardCharsets.UTF_8));</#if>
<#if junit >Assertions.assertNotEquals(0, baos.size());</#if>
}
</#macro>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
this.addJunit5 = true;
this.addLombok = true;
this.addJacoco = true;
this.addFormatting = true;
this.flavour = currentFlavour;
if ( FlavourFacade.FLAVOUR_QUARKUS_3.equals( currentFlavour ) ) {
this.basePackage = "org.fugerit.java.basepack";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ public class ProjectInitInput {
@Setter
private boolean addJacoco;

@Getter
@Setter
private boolean addFormatting;

}
Loading