diff --git a/.github/workflows/build_fj-doc-native-quarkus_test.yml b/.github/workflows/build_fj-doc-native-quarkus_test.yml index 7114576e0..6aa8659b1 100644 --- a/.github/workflows/build_fj-doc-native-quarkus_test.yml +++ b/.github/workflows/build_fj-doc-native-quarkus_test.yml @@ -17,11 +17,7 @@ on: push: branches: - develop - pull_request: - types: - - opened - - synchronize - - reopened + - branch-deploy # only allow one workflow at time on the give activation concurrency: diff --git a/CHANGELOG.md b/CHANGELOG.md index a8749359e..548cf9431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- [fj-doc-maven-plugin] support add 'direct' goal to maven goal 'init' and 'add' +- [fj-doc-playground-quarkus] project init - add verify and direct plugin options + ## [8.13.5] - 2025-04-25 ### Added diff --git a/fj-doc-guide/src/main/docs/asciidoc/chapters/02_1_maven_plugin_add.adoc b/fj-doc-guide/src/main/docs/asciidoc/chapters/02_1_maven_plugin_add.adoc index c9b5e45fd..ff3da8543 100644 --- a/fj-doc-guide/src/main/docs/asciidoc/chapters/02_1_maven_plugin_add.adoc +++ b/fj-doc-guide/src/main/docs/asciidoc/chapters/02_1_maven_plugin_add.adoc @@ -24,6 +24,7 @@ mvn org.fugerit.java:fj-doc-maven-plugin:add \ | excludeXmlApis | false | false | It will exclude dependency xml-apis:xml-apis | addExclusions | false | | Add comma separated exclusion, for instance : xml-apis:xml-apis,${groupId}:${artificatId} | addVerifyPlugin | true | true | If set to true, it will configure the 'verify' goal on the project +| addDirectPlugin | false | true | If set to true, it will configure the 'direct' goal on the project | addJunit5 | true | true | If set to true, it will add junit5 (test scope) and basic test | addLombok | true | true | If set to true, it will add lombok (provided scope) and slf4j-simple (test scope) | addDependencyOnTop | true | false | If set to true, added dependencies will be added before existing ones diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoAdd.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoAdd.java index 0a0ac1ffa..1a4871c64 100644 --- a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoAdd.java +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoAdd.java @@ -38,6 +38,9 @@ public class MojoAdd extends AbstractMojo { @Parameter(property = "addVerifyPlugin", defaultValue = "true", required = true) protected boolean addVerifyPlugin; + @Parameter(property = "addDirectPlugin", defaultValue = "false", required = true) + protected boolean addDirectPlugin; + @Parameter(property = "addJunit5", defaultValue = "true", required = true) protected boolean addJunit5; @@ -67,6 +70,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { context.setAddExclusions( addExclusions ); context.setExcludeXmlApis( this.excludeXmlApis ); context.setAddVerifyPlugin( this.addVerifyPlugin ); + context.setAddDirectPlugin( this.addDirectPlugin ); context.setAddJunit5( this.addJunit5 ); context.setAddLombok( this.addLombok ); context.setAddDependencyOnTop( this.addDependencyOnTop ); diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoInit.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoInit.java index a00117a23..69c971071 100644 --- a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoInit.java +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoInit.java @@ -64,7 +64,10 @@ public void execute() throws MojoExecutionException, MojoFailureException { context.setVersion( VersionCheck.findVersion( this.version ) ); context.setExtensions( this.extensions ); this.getLog().info( String.format( "flavour context : %s", context ) ); - FlavourFacade.initProject( context ); + String actualVersion = FlavourFacade.initProject( context ); + if ( FlavourFacade.FLAVOUR_DIRECT.equals( actualVersion ) ) { + super.addDirectPlugin = true; + } } ); super.groupIdOverride = this.groupId; super.artifactIdOverride = this.artifactId; diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/BasicVenusFacade.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/BasicVenusFacade.java index d74a8a032..e2ede921b 100644 --- a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/BasicVenusFacade.java +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/BasicVenusFacade.java @@ -2,11 +2,9 @@ import lombok.extern.slf4j.Slf4j; import org.apache.maven.model.*; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.apache.maven.plugins.annotations.LifecyclePhase; import org.fugerit.java.core.cfg.ConfigRuntimeException; import org.fugerit.java.core.io.FileIO; -import org.fugerit.java.core.io.helper.HelperIOException; import org.fugerit.java.core.lang.helpers.StringUtils; import org.maxxq.maven.dependency.ModelIO; @@ -21,9 +19,9 @@ public class BasicVenusFacade { protected BasicVenusFacade() {} - protected static final String GROUP_ID = "org.fugerit.java"; + protected static final String GROUP_ID = VenusConsts.GROUP_ID; - protected static final String KEY_VERSION = "fj-doc-version"; + protected static final String KEY_VERSION = VenusConsts.KEY_VERSION; private static void addOrOverwrite( List deps, Dependency d ) { Iterator it = deps.iterator(); @@ -148,7 +146,8 @@ protected static void addExtensionList( File pomFile, VenusContext context ) thr addJunit5( model, context ); // addLombok parameter addLombok( model, context ); - addPlugin( context, model ); + addDirectPlugin( context, model ); + addVerifyPlugin( context, model ); log.info( "end dependencies size : {}", model.getDependencies().size() ); try (OutputStream pomStream = new FileOutputStream( pomFile ) ) { modelIO.writeModelToStream( model, pomStream ); @@ -221,27 +220,42 @@ protected static void addExtensionGradleList( File gradleFile, VenusContext cont FileIO.writeString( gradleFileContent, gradleFile ); } - private static void addPlugin( VenusContext context, Model model ) throws IOException { + private static void addDirectPlugin(VenusContext context, Model model ) throws IOException { + // addDirectPlugin? + if ( context.isAddDirectPlugin() ) { + if (context.isDirectPluginNotAvailable()) { + log.warn("addDirectPlugin skipped, version {} has been selected, minimum required version is : {}", context.getVersion(), VenusContext.VERSION_NA_DIRECT_PLUGIN); + } else { + FeatureFacade.copyFeatureList( context.getProjectDir(), "direct" ); + log.info("addDirectPlugin true, version {} has been selected, minimum required version is : {}", context.getVersion(), VenusContext.VERSION_NA_DIRECT_PLUGIN); + Plugin plugin = PluginUtils.findOrCreatePLugin( model ); + PluginExecution execution = PluginUtils.createPluginExecution( + "venus-direct", LifecyclePhase.COMPILE.id(), PluginUtils.GOAL_DIRECT ); + plugin.getExecutions().add( execution ); + String xml = "\n" + + " ${project.basedir}/src/main/resources/venus-direct-config/venus-direct-config.yaml\n" + + " true\n" + + " \n" + + " ${project.basedir}\n" + + " \n" + + ""; + execution.setConfiguration( PluginUtils.getPluginConfiguration( xml ) ); + } + } else { + log.info( "addDirectPlugin : false" ); + } + } + + private static void addVerifyPlugin(VenusContext context, Model model ) throws IOException { // addVerifyPlugin? if ( context.isAddVerifyPlugin() ) { if ( context.isVerifyPluginNotAvailable() ) { log.warn( "addVerifyPlugin skipped, version {} has been selected, minimum required version is : {}", context.getVersion(), VenusContext.VERSION_NA_VERIFY_PLUGIN ); } else { log.info( "addVerifyPlugin true, version {} has been selected, minimum required version is : {}", context.getVersion(), VenusContext.VERSION_NA_VERIFY_PLUGIN ); - Build build = model.getBuild(); - if ( build == null ) { - build = new Build(); - model.setBuild( build ); - } - List plugins = model.getBuild().getPlugins(); - Plugin plugin = new Plugin(); - plugin.setGroupId( GROUP_ID ); - plugin.setArtifactId( "fj-doc-maven-plugin" ); - plugin.setVersion( "${"+KEY_VERSION+"}" ); - PluginExecution execution = new PluginExecution(); - execution.setId( "freemarker-verify" ); - execution.setPhase( "compile" ); - execution.addGoal( "verify" ); + Plugin plugin = PluginUtils.findOrCreatePLugin( model ); + PluginExecution execution = PluginUtils.createPluginExecution( + "freemarker-verify", LifecyclePhase.COMPILE.id(), LifecyclePhase.VERIFY.id() ); plugin.getExecutions().add( execution ); String xml = "\n" + " ${project.basedir}/src/main/resources/"+context.getArtificatIdForFolder()+"/template\n" + @@ -249,13 +263,7 @@ private static void addPlugin( VenusContext context, Model model ) throws IOExce " true\n" + " ${project.build.directory}/freemarker-syntax-verify-report\n" + " "; - HelperIOException.apply( () -> { - try ( StringReader sr = new StringReader( xml ) ) { - Xpp3Dom dom = Xpp3DomBuilder.build( sr ); - plugin.setConfiguration( dom ); - } - }); - plugins.add( plugin ); + execution.setConfiguration( PluginUtils.getPluginConfiguration( xml ) ); } } else { log.info( "addVerifyPlugin : false" ); diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FeatureFacade.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FeatureFacade.java new file mode 100644 index 000000000..ca71ed9c1 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FeatureFacade.java @@ -0,0 +1,53 @@ +package org.fugerit.java.doc.project.facade; + +import lombok.extern.slf4j.Slf4j; +import org.fugerit.java.core.function.SafeFunction; +import org.fugerit.java.core.io.StreamIO; +import org.fugerit.java.core.lang.helpers.ClassHelper; + +import java.io.*; + +@Slf4j +public class FeatureFacade { + + private FeatureFacade() {} + + public static void copyFlavourList( File baseFolder, String actualFlavour ) throws IOException { + copyResourcesList( baseFolder, "flavour", actualFlavour ); + } + + public static void copyFeatureList( File baseFolder, String featureId ) throws IOException { + copyResourcesList( baseFolder, "feature", featureId ); + } + + private static void copyResourcesList( File baseFolder, String mode, String id ) throws IOException { + // copy all resources + String listFilePath = String.format( "config/%s/%s-copy.txt", mode, id ); + String baseFlavourPath = String.format( "config/%s/%s/", mode, id ); + log.info( "loading list file {}, base flavour path {}", listFilePath, baseFlavourPath ); + try (BufferedReader reader = new BufferedReader( new InputStreamReader(ClassHelper.loadFromDefaultClassLoader( listFilePath ) ) ) ) { + reader.lines().forEach( s -> copyFile( s, baseFolder, baseFlavourPath ) ); + } + } + + protected static void insureParent( File file ) throws IOException { + File parentFile = file.getParentFile(); + if ( !parentFile.exists() ) { + log.info( "creates parent directory {}, mkdirs:?", parentFile.getCanonicalPath(), parentFile.mkdirs() ); + } + } + + protected static void copyFile(String path, File baseFolder, String basePath ) { + SafeFunction.apply( () -> { + File outputFile = new File( baseFolder, path ); + insureParent( outputFile ); + String fullPath = basePath+path; + log.info( "copy path '{}' to file '{}'", fullPath, outputFile.getCanonicalPath() ); + try (InputStream is = ClassHelper.loadFromDefaultClassLoader( fullPath ); + FileOutputStream os = new FileOutputStream( outputFile ) ) { + StreamIO.pipeStream( is, os, StreamIO.MODE_CLOSE_NONE ); + } + } ); + } + +} diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FlavourFacade.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FlavourFacade.java index 00ee69b5c..12d306247 100644 --- a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FlavourFacade.java +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FlavourFacade.java @@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j; import org.fugerit.java.core.cfg.ConfigRuntimeException; 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.lang.helpers.reflect.MethodHelper; @@ -19,7 +18,6 @@ import java.io.*; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.util.*; @Slf4j @@ -29,6 +27,8 @@ private FlavourFacade() {} public static final String FLAVOUR_VANILLA = "vanilla"; + public static final String FLAVOUR_DIRECT = "direct"; + public static final String FLAVOUR_QUARKUS_3 = "quarkus-3"; public static final String FLAVOUR_QUARKUS_3_GRADLE = "quarkus-3-gradle"; @@ -50,7 +50,7 @@ private FlavourFacade() {} private static final Properties FLAVOURS_DEFAULT_VERSION = PropsIO.loadFromClassLoaderSafe( "config/flavour/flavour_versions_default.properties" ); public static final Set SUPPORTED_FLAVOURS = Collections.unmodifiableSet( - new HashSet<>( Arrays.asList( FLAVOUR_VANILLA, FLAVOUR_QUARKUS_3, FLAVOUR_QUARKUS_3_GRADLE, FLAVOUR_QUARKUS_3_GRADLE_KTS, + new HashSet<>( Arrays.asList( FLAVOUR_VANILLA, FLAVOUR_DIRECT, FLAVOUR_QUARKUS_3, FLAVOUR_QUARKUS_3_GRADLE, FLAVOUR_QUARKUS_3_GRADLE_KTS, FLAVOUR_QUARKUS_3_PROPERTIES, FLAVOUR_QUARKUS_2, FLAVOUR_MICRONAUT_4, FLAVOUR_SPRINGBOOT_3, FLAVOUR_OPENLIBERTY ) ) ); public static boolean isGradleKtsFlavour(String flavour ) { @@ -63,7 +63,7 @@ public static boolean isGradleKtsFlavour(String flavour ) { return prop; }); - public static void initProject( FlavourContext context ) throws IOException, TemplateException { + public static String initProject( FlavourContext context ) throws IOException, TemplateException { log.info( "generate flavour : {}", context.getFlavour() ); String actualFlavour = MAP_FLAVOURS.getProperty( context.getFlavour(), context.getFlavour() ); if ( SUPPORTED_FLAVOURS.contains( actualFlavour ) ) { @@ -72,6 +72,7 @@ public static void initProject( FlavourContext context ) throws IOException, Tem } else { throw new ConfigRuntimeException( String.format( "flavour not supported : %s", context.getFlavour() ) ); } + return actualFlavour; } public static void checkFlavour( FlavourContext context, String actualFlavour ) { @@ -147,12 +148,7 @@ public static Object readField( FlavourContext context, Field field, String fiel private static void initFlavour( FlavourContext context, String actualFlavour ) throws IOException, TemplateException { // copy all resources - String listFilePath = String.format( "config/flavour/%s-copy.txt", actualFlavour ); - String baseFlavourPath = String.format( "config/flavour/%s/", actualFlavour ); - log.info( "loading list file {}, base flavour path {}", listFilePath, baseFlavourPath ); - try (BufferedReader reader = new BufferedReader( new InputStreamReader(ClassHelper.loadFromDefaultClassLoader( listFilePath ) ) ) ) { - reader.lines().forEach( s -> copyFlavourFile( s, context.getProjectFolder(), baseFlavourPath ) ); - } + FeatureFacade.copyFlavourList( context.getProjectFolder(), actualFlavour ); // freemarker resources Map data = new HashMap<>(); data.put( "context", context ); @@ -167,31 +163,11 @@ private static void initFlavour( FlavourContext context, String actualFlavour ) } } - private static void insureParent( File file ) throws IOException { - File parentFile = file.getParentFile(); - if ( !parentFile.exists() ) { - log.info( "creates parent directory {}, mkdirs:?", parentFile.getCanonicalPath(), parentFile.mkdirs() ); - } - } - - private static void copyFlavourFile( String path, File baseFolder, String basePath ) { - SafeFunction.apply( () -> { - File outputFile = new File( baseFolder, path ); - insureParent( outputFile ); - String fullPath = basePath+path; - log.info( "copy path '{}' to file '{}'", fullPath, outputFile.getCanonicalPath() ); - try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( fullPath ); - FileOutputStream os = new FileOutputStream( outputFile ) ) { - StreamIO.pipeStream( is, os, StreamIO.MODE_CLOSE_NONE ); - } - } ); - } - private static void processEntry( ProcessEntry entry, Map data ) { log.info( "process entry : {}", entry ); SafeFunction.apply( () -> { File toFile = new File( entry.getTo() ); - insureParent( toFile ); + FeatureFacade.insureParent( toFile ); FreemarkerTemplateFacade.processFile( entry.getFrom(), toFile, data ); } ); } diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/PluginUtils.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/PluginUtils.java new file mode 100644 index 000000000..f639c0824 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/PluginUtils.java @@ -0,0 +1,65 @@ +package org.fugerit.java.doc.project.facade; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.fugerit.java.core.io.helper.HelperIOException; + +import java.io.IOException; +import java.io.StringReader; +import java.util.Arrays; + +public class PluginUtils { + + public static final String GOAL_DIRECT = "direct"; + + public static final String FJ_DOC_MAVEN_PLUGIN = "fj-doc-maven-plugin"; + + private PluginUtils() {} + + public static Object getPluginConfiguration( String xml ) throws IOException { + return HelperIOException.get( () -> { + try ( StringReader sr = new StringReader( xml ) ) { + return Xpp3DomBuilder.build( sr ); + } + }); + } + + public static Plugin findOrCreatePLugin( Model model ) { + Plugin plugin = null; + Build build = getBuild( model ); + for ( Plugin current : build.getPlugins() ) { + if ( FJ_DOC_MAVEN_PLUGIN.equals( current.getArtifactId() ) ) { + plugin = current; + } + } + if ( plugin == null ) { + plugin = new Plugin(); + plugin.setGroupId( VenusConsts.GROUP_ID ); + plugin.setArtifactId( FJ_DOC_MAVEN_PLUGIN ); + plugin.setVersion( "${"+VenusConsts.KEY_VERSION+"}" ); + build.getPlugins().add( plugin ); + } + return plugin; + } + + public static PluginExecution createPluginExecution(String id, String phase, String... goal ) { + PluginExecution execution = new PluginExecution(); + execution.setId( id ); + execution.setPhase( phase ); + execution.setGoals(Arrays.asList( goal )); + return execution; + } + + public static Build getBuild(Model model) { + Build build = model.getBuild(); + if ( build == null ) { + build = new Build(); + model.setBuild( build ); + } + return build; + } + +} diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusConsts.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusConsts.java new file mode 100644 index 000000000..59e3e6c75 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusConsts.java @@ -0,0 +1,11 @@ +package org.fugerit.java.doc.project.facade; + +public class VenusConsts { + + private VenusConsts() {} + + public static final String GROUP_ID = "org.fugerit.java"; + + public static final String KEY_VERSION = "fj-doc-version"; + +} diff --git a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusContext.java b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusContext.java index bc298e9d5..6a426ae9d 100644 --- a/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusContext.java +++ b/fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusContext.java @@ -35,6 +35,8 @@ public static String toResourcePathFmConfigXml( String artifactId ) { public static final String VERSION_NA_VERIFY_PLUGIN = "8.7.2"; + public static final String VERSION_NA_DIRECT_PLUGIN = "8.13.4"; + public static final String VERSION_NA_FULL_PROCESS = "8.6.2"; public static final String VERSION_NA_FREEMARKER_NATIVE = "8.11.8"; @@ -69,6 +71,9 @@ public static String toResourcePathFmConfigXml( String artifactId ) { @Getter @Setter private boolean addVerifyPlugin; + @Getter @Setter + private boolean addDirectPlugin; + @Getter @Setter private boolean addJunit5; @@ -151,6 +156,10 @@ public boolean isVerifyPluginNotAvailable() { return VersionCheck.isMajorThan( VERSION_NA_VERIFY_PLUGIN, this.getVersion() ); } + public boolean isDirectPluginNotAvailable() { + return VersionCheck.isMajorThan( VERSION_NA_DIRECT_PLUGIN, this.getVersion() ); + } + public boolean isAsciidocFreemarkerHandlerAvailable() { return VersionCheck.isMajorThan( this.getVersion(), VERSION_ASCIIDOC_FREEMARKER_HANDLER ); } diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct-copy.txt b/fj-doc-maven-plugin/src/main/resources/config/feature/direct-copy.txt new file mode 100644 index 000000000..77216a61b --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct-copy.txt @@ -0,0 +1,5 @@ +src/main/resources/venus-direct-config/venus-direct-config.yaml +src/main/resources/venus-direct-config/template/sample-doc.ftl +src/main/resources/venus-direct-config/data-model/sample-model.json +src/main/resources/venus-direct-config/data-model/sample-model.yaml +README_DIRECT.md diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct/README_DIRECT.md b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/README_DIRECT.md new file mode 100644 index 000000000..f5c48c526 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/README_DIRECT.md @@ -0,0 +1,3 @@ +# fj-doc-maven-plugin : 'direct' goal + +this project is configured for 'direct' Venus Docs generation. \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.json b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.json new file mode 100644 index 000000000..5f8e583c6 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.json @@ -0,0 +1,7 @@ +{ + "docTitle": "Venus Direct Extension - Sample Doc - JSON", + "listPeople": [ + { "name":"Luthien", "surname":"Tinuviel", "title":"Queen" }, + { "name":"Thorin", "surname":"Oakshield", "title":"King" } + ] +} \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.yaml b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.yaml new file mode 100644 index 000000000..1141c874c --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/data-model/sample-model.yaml @@ -0,0 +1,9 @@ +--- +docTitle: 'Venus Direct Extension - Sample Doc - YAML' +listPeople: + - name: "Luthien" + surname: "Tinuviel" + title: "Queen" + - name: "Thorin" + surname: "Oakshield" + title: "King" \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/template/sample-doc.ftl b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/template/sample-doc.ftl new file mode 100644 index 000000000..e7f174aad --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/template/sample-doc.ftl @@ -0,0 +1,48 @@ +<#ftl output_format="XML"> + + + + <#-- + Sample template, see documentation at https://venusdocs.fugerit.org/ + --> + + + + + 10;10;10;30 + + + excel-table=print + 450 + + excel-table + + + + ${r"${currentPage}"} / ${r"${pageCount}"} + + + + + + ${dataModel.docTitle} + + + Name + Surname + Title + + <#list dataModel.listPeople as current> + + ${current.name} + ${current.surname} + ${current.title} + + +
+ + +
\ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/venus-direct-config.yaml b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/venus-direct-config.yaml new file mode 100644 index 000000000..c40f8d14f --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/feature/direct/src/main/resources/venus-direct-config/venus-direct-config.yaml @@ -0,0 +1,39 @@ +--- +configId: 'venus-direct-config-sample' +templatePath: '${projectBasedir}/src/main/resources/venus-direct-config/template/' +templateMode: 'folder' +createParentDirectory: true +handlerList: + - type: org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8 + - type: org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandlerNoCommentsUTF8 + - type: org.fugerit.java.doc.freemarker.asciidoc.FreeMarkerAsciidocTypeHandlerUTF8 +chainList: # a template named ${chainId}.ftl or ${useChainId}.ftl must exist in 'templatePath' folder + - chainId: 'sample-doc' + dataModel: # inline data model definition + docTitle: 'Venus Direct Extension - Test Doc' + listPeople: + - name: "Luthien" + surname: "Tinuviel" + title: "Queen" + - name: "Thorin" + surname: "Oakshield" + title: "King" + - chainId: 'sample-doc-json-data-model' + useChainId: 'sample-doc' + dataModelJson: '${projectBasedir}/src/main/resources/venus-direct-config/data-model/sample-model.json' # JSON file data model + - chainId: 'sample-doc-yaml-data-model' + useChainId: 'sample-doc' + dataModelYaml: '${projectBasedir}/src/main/resources/venus-direct-config/data-model/sample-model.yaml' # YAML file data model +outputList: + - outputId: 'sample-doc-html' + chainId: 'sample-doc' + handlerId: 'html' # a valid handler for this output type should be defined (i.e. org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8) + file: '${projectBasedir}/target/sample-doc.html' + - outputId: 'sample-doc-md' + chainId: 'sample-doc-json-data-model' + handlerId: 'md' + file: '${projectBasedir}/target/sample-doc.md' + - outputId: 'sample-doc-adoc' + chainId: 'sample-doc-yaml-data-model' + handlerId: 'adoc' + file: '${projectBasedir}/target/sample-doc.adoc' \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/flavour-extra-config/direct-config.yml b/fj-doc-maven-plugin/src/main/resources/config/flavour-extra-config/direct-config.yml new file mode 100644 index 000000000..2174240d5 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/flavour-extra-config/direct-config.yml @@ -0,0 +1,8 @@ +--- +paramConfig: + addLombok: + acceptOnly: + - true + addDirectPlugin: + acceptOnly: + - true \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/flavour/direct-copy.txt b/fj-doc-maven-plugin/src/main/resources/config/flavour/direct-copy.txt new file mode 100644 index 000000000..e69de29bb diff --git a/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct-fm-yml.ftl b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct-fm-yml.ftl new file mode 100644 index 000000000..c5a12734e --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct-fm-yml.ftl @@ -0,0 +1,10 @@ +<#import 'flavour-macro.ftl' as fhm> +--- +flavour: ${context.flavour} +process: + - from: flavour/${context.flavour}/pom.ftl + to: ${context.projectFolder}/pom.xml + - from: flavour/${context.flavour}/README.ftl + to: ${context.projectFolder}/README.md + - from: flavour/${context.flavour}/gitignore.ftl + to: ${context.projectFolder}/.gitignore \ No newline at end of file diff --git a/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/README.ftl b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/README.ftl new file mode 100644 index 000000000..65ed0e99e --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/README.ftl @@ -0,0 +1,4 @@ +# ${context.artifactId} + +This is a sample project configured using [fj-doc-maven-plugin init plugin](https://venusdocs.fugerit.org/guide/#maven-plugin-goal-init). + diff --git a/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/gitignore.ftl b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/gitignore.ftl new file mode 100644 index 000000000..91a800a18 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/gitignore.ftl @@ -0,0 +1,45 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties +.flattened-pom.xml + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Local environment +.env + +# Plugin directory +/.quarkus/cli/plugins/ +# TLS Certificates +.certs/ diff --git a/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/pom.ftl b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/pom.ftl new file mode 100644 index 000000000..0c9636069 --- /dev/null +++ b/fj-doc-maven-plugin/src/main/resources/config/template/flavour/direct/pom.ftl @@ -0,0 +1,13 @@ + + + 4.0.0 + ${context.groupId} + ${context.artifactId} + ${context.projectVersion} + + + ${context.javaRelease} + UTF-8 + + + diff --git a/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestAddVenusFacade.java b/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestAddVenusFacade.java index e592a9b16..40873aa9f 100644 --- a/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestAddVenusFacade.java +++ b/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestAddVenusFacade.java @@ -61,6 +61,7 @@ void testAddVenus() throws IOException { context.setExcludeXmlApis( excludeXmlApis ); context.setAddDocFacace( addFacade ); context.setAddVerifyPlugin( addVerifyPlugin ); + context.setAddDirectPlugin( Boolean.TRUE ); context.setAddJunit5( addJunit5 ); context.setAddLombok( addLombok ); context.setAddDependencyOnTop( addDependencyOnTop ); diff --git a/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestInit.java b/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestInit.java index eb8f4641e..d204bf806 100644 --- a/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestInit.java +++ b/fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestInit.java @@ -22,6 +22,8 @@ class TestInit { private static final String FREEMARKER_NATIVE_AVAILABLE = "8.11.9"; + private static final String DIRECT_PLUGIN_AVAILABLE = "8.13.5"; + private String getVersion() { return "8.10.9"; } @@ -41,7 +43,11 @@ public void execute() throws MojoExecutionException, MojoFailureException { this.groupId = "org.fugerit.java.test.gradle"; this.artifactId = "fugerit-test-"+currentFlavour; this.javaRelease = "21"; - this.version = getVersion(); + if ( FlavourFacade.FLAVOUR_DIRECT.equals( currentFlavour ) ) { + this.version = DIRECT_PLUGIN_AVAILABLE; + } else { + this.version = getVersion(); + } this.extensions = "fj-doc-base,fj-doc-base-json,fj-doc-base-yaml,fj-doc-base-kotlin,fj-doc-freemarker,fj-doc-mod-fop,fj-doc-mod-poi,fj-doc-mod-opencsv"; this.addDocFacade = true; this.force = true; diff --git a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectInitInput.java b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectInitInput.java index 78caed42d..65433768e 100644 --- a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectInitInput.java +++ b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectInitInput.java @@ -50,4 +50,12 @@ public class ProjectInitInput { @Setter private List extensionList; + @Getter + @Setter + private boolean addVerifyPlugin; + + @Getter + @Setter + private boolean addDirectPlugin; + } diff --git a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectRest.java b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectRest.java index c08ddfccd..bc653e556 100644 --- a/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectRest.java +++ b/fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/init/ProjectRest.java @@ -77,6 +77,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { this.addLombok = true; this.flavour = data.getFlavour(); this.flavourVersion = data.getFlavourVersion(); + this.addVerifyPlugin = data.isAddVerifyPlugin(); + this.addDirectPlugin = data.isAddDirectPlugin(); super.execute(); } }; diff --git a/fj-doc-playground-quarkus/src/main/react/src/playground/DocProjectInit.jsx b/fj-doc-playground-quarkus/src/main/react/src/playground/DocProjectInit.jsx index 62918cbc3..f5750513e 100644 --- a/fj-doc-playground-quarkus/src/main/react/src/playground/DocProjectInit.jsx +++ b/fj-doc-playground-quarkus/src/main/react/src/playground/DocProjectInit.jsx @@ -3,6 +3,10 @@ import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import InputLabel from '@mui/material/InputLabel'; import FormControl from '@mui/material/FormControl'; +import FormLabel from '@mui/material/FormLabel'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import RadioGroup from '@mui/material/RadioGroup'; +import Radio from '@mui/material/Radio'; import TextField from '@mui/material/TextField'; import CircularProgress from '@mui/material/CircularProgress'; import Button from '@mui/material/Button'; @@ -32,6 +36,8 @@ const DocProjectInit = ({setHelpContent}) => { 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 + const [addVerifyPlugin, setAddVerifyPlugin] = useState(true); // State to handle addVerifyPlugin selection + const [addDirectPlugin, setAddDirectPlugin] = useState(false); // State to handle addDirectPlugin selection // useEffect to fetch data from the API when the component mounts useEffect(() => { @@ -105,6 +111,8 @@ const DocProjectInit = ({setHelpContent}) => { javaVersion, venusVersion, flavour, + addVerifyPlugin, + addDirectPlugin, extensionList: selectedExtensions, }; try { @@ -228,9 +236,38 @@ const DocProjectInit = ({setHelpContent}) => { Micronaut 4 SpringBoot 3 OpenLiberty + Direct (Doc Maven Plugin, 'direct' goal) + + {/* Text field for addVerifyPlugin */} + + Add verify plugin + setAddVerifyPlugin(e.target.value === 'true')} + > + } label="true" /> + } label="false" /> + + + + + {/* Text field for addDirectPlugin */} + + Add direct plugin + setAddDirectPlugin(e.target.value === 'true')} + > + } label="true" /> + } label="false" /> + + + {/* Text field for flavourVersion */}