You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2023/01/31 21:42:00 UTC

[jira] [Commented] (MSITE-869) Options to preprocess site sources and resources through Maven filtering

    [ https://issues.apache.org/jira/browse/MSITE-869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17682772#comment-17682772 ] 

Michael Osipov commented on MSITE-869:
--------------------------------------

I think this logically duplicates DOXIA-677. WDYT?

> Options to preprocess site sources and resources through Maven filtering
> ------------------------------------------------------------------------
>
>                 Key: MSITE-869
>                 URL: https://issues.apache.org/jira/browse/MSITE-869
>             Project: Maven Site Plugin
>          Issue Type: Improvement
>          Components: property interpolation
>            Reporter: Bertrand Martin
>            Priority: Major
>
> h1. Use Case
> User has source files or resources files where Maven properties like ${project.version} or ${project.name} need to be replaced with their actual value.
> Examples: 
> * a [REST API specification|https://swagger.io/specification/] in *src/site/resource/openapi.yaml*
> * the title of a Markdown document describing the project (like [Maven Site Plugin|https://maven.apache.org/plugins/maven-site-plugin/index.html]'s own documentation)
> h1. Workaround
> Usually, [it is recommended to add the .vm suffix|https://stackoverflow.com/questions/7111000/resource-filtering-with-maven-site-plugin] to the files that need filtering, so that they are processed as a Velocity template.
> But this workaround has several drawbacks:
> * [Velocity and Markdown formats are highly incompatible|https://github.com/apache/maven-archetypes/blob/master/maven-archetype-plugin-site/src/main/resources/archetype-resources/src/site/markdown/markdown-velocity.md.vm] because of the headings format
> * Velocity has 1000 times more features than just filtering, which is great, but also which can unexpectedly conflict with source files and with resource files (which may be from external sources, like JS libraries, YAML, etc.)
> * .vm files are handled as Velocity templates in most code editors (VSCode, etc.), which prevents any other advanced features from working (especially on openapi.yaml, where you can have linting, validation, autosuggest, etc.)
> Basically, Velocity templates is a great feature that needs to stay, but it's overkill for just replacing ${project.version} in a bunch of files.
> h1. Specifications
> Add options to filter site source files and resource files:
> * {{boolean sourceFiltering}} (default: false)
> * {{boolean resourceFiltering}} (default: false)
> * {{List<String> nonFilteredFileExtensions}} (default: jpg, jpeg, gif, bmp, png)
> * {{boolean fileNameFiltering}} (default: false)
> Use Maven's filtering component:
> {code:java}
> 	@Component(role = MavenResourcesFiltering.class, hint = "default")
> 	private MavenResourcesFiltering mavenResourcesFiltering;
> {code}
> .vm files don't need to be filtered. There are therefore 3 cases:
> * no filtering
> * simple filtering (like [Maven Resource Plugin|https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html])
> * advanced templating



--
This message was sent by Atlassian Jira
(v8.20.10#820010)