michael-o commented on code in PR #610:
URL: 
https://github.com/apache/maven-doxia-sitetools/pull/610#discussion_r2747048761


##########
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java:
##########
@@ -862,6 +870,37 @@ public void copyResources(SiteRenderingContext 
siteRenderingContext, File output
         }
     }
 
+    private boolean isResourceRelevant(String name, Context velocityContext, 
Map<String, String> resourceConditions) {
+        if (resourceConditions == null || 
!resourceConditions.containsKey(name)) {
+            LOGGER.debug("No condition for resource: " + name);
+        } else {
+            String condition = resourceConditions.get(name);
+            LOGGER.debug("Evaluating condition for resource: " + name + " with 
condition: " + condition);
+            StringWriter writer = new StringWriter();
+            Velocity.evaluate(velocityContext, writer, 
"conditional-resource-evaluation", condition);
+            String result = writer.toString().trim();
+            LOGGER.debug("Condition evaluation result: " + result);
+            if (!Boolean.parseBoolean(result)) {
+                LOGGER.debug("Excluding resource: " + name);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private Map<String, String> createResourceConditionsMap(SkinModel 
skinModel) {
+        Map<String, String> resourceConditions = new HashMap<>();
+        if (skinModel != null && skinModel.getResourceConditions() != null) {

Review Comment:
   How can `skinModel` be empty when `context.put("site", 
siteRenderingContext.getSiteModel());` always works.



##########
doxia-skin-model/src/main/mdo/skin.mdo:
##########
@@ -97,5 +107,32 @@ under the License.
         </field>
       </fields>
     </class>
+    <class java.clone="deep">
+      <name>ResourceCondition</name>
+      <version>2.1.0+</version>
+      <description>Describes the condition for including a specific Skin 
resource.</description>
+      <fields>
+        <field xml.tagName="resource-name">
+          <name>resourceName</name>
+          <version>2.1.0+</version>
+          <type>String</type>
+          <description><![CDATA[
+            The name of the resource to which this condition applies. Refers 
to the path within the JAR (i.e. must always use "/" as separator and must not 
start with a slash).
+            ]]>
+          </description>
+          <required>true</required>
+        </field>
+        <field xml.tagName="vtl-condition">
+          <name>vtlCondition</name>
+          <version>2.1.0+</version>
+          <type>String</type>
+          <description><![CDATA[
+            The Velocity (VTL) expression to be evaluated to decide if the 
resource should be included. Only if the condition evaluates to true, the 
resource will be included.

Review Comment:
   From your understanding the evaluation has to run inside Velocity since the 
required data is available only there? What about JSR 223?



##########
doxia-skin-model/src/main/mdo/skin.mdo:
##########
@@ -97,5 +107,32 @@ under the License.
         </field>
       </fields>
     </class>
+    <class java.clone="deep">
+      <name>ResourceCondition</name>
+      <version>2.1.0+</version>
+      <description>Describes the condition for including a specific Skin 
resource.</description>
+      <fields>
+        <field xml.tagName="resource-name">
+          <name>resourceName</name>
+          <version>2.1.0+</version>
+          <type>String</type>
+          <description><![CDATA[
+            The name of the resource to which this condition applies. Refers 
to the path within the JAR (i.e. must always use "/" as separator and must not 
start with a slash).
+            ]]>
+          </description>
+          <required>true</required>

Review Comment:
   I wonder why just one resource? Our resource in the POM operate on  
collections.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to