This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b299b11 Add an IT for Velocity tools and custom tools from 
site-tools.xml
1b299b11 is described below

commit 1b299b11df1af5db9f6c98f89181fb9fdff5e33e
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Oct 26 15:35:16 2026 +0000

    Add an IT for Velocity tools and custom tools from site-tools.xml
    
    Checks the output of the generic tools and of custom tools configured
    through META-INF/maven/site-tools.xml: a SafeConfig tool reading its
    property and the context, a setter-configured tool, and a property
    override of the date tool, as the Reflow skin uses.
---
 src/it/projects/velocity-tools/invoker.properties  | 18 ++++++
 src/it/projects/velocity-tools/pom.xml             | 71 ++++++++++++++++++++++
 .../plugins/site/it/ConfiguredVelocityTool.java    | 50 +++++++++++++++
 .../maven/plugins/site/it/SetterVelocityTool.java  | 38 ++++++++++++
 .../main/resources/META-INF/maven/site-tools.xml   | 28 +++++++++
 .../velocity-tools/src/site/apt/tools.apt.vm       | 41 +++++++++++++
 src/it/projects/velocity-tools/verify.groovy       | 31 ++++++++++
 7 files changed, 277 insertions(+)

diff --git a/src/it/projects/velocity-tools/invoker.properties 
b/src/it/projects/velocity-tools/invoker.properties
new file mode 100644
index 00000000..2e27904f
--- /dev/null
+++ b/src/it/projects/velocity-tools/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals = package site
diff --git a/src/it/projects/velocity-tools/pom.xml 
b/src/it/projects/velocity-tools/pom.xml
new file mode 100644
index 00000000..c8598e8c
--- /dev/null
+++ b/src/it/projects/velocity-tools/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.site.its</groupId>
+  <artifactId>velocity-tools</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>Velocity tools</name>
+  <description>Velocity generic tools and custom tools from 
META-INF/maven/site-tools.xml in Velocity-processed documents.</description>
+
+  <properties>
+    
<project.build.outputTimestamp>@project.build.outputTimestamp@</project.build.outputTimestamp>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.velocity.tools</groupId>
+      <artifactId>velocity-tools-generic</artifactId>
+      <version>3.1</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <generateReports>false</generateReports>
+            <saveProcessedContent>true</saveProcessedContent>
+          </configuration>
+          <dependencies>
+            <dependency><!-- the custom tools and their site-tools.xml, see 
MSITE-782 -->
+              <groupId>${project.groupId}</groupId>
+              <artifactId>${project.artifactId}</artifactId>
+              <version>${project.version}</version>
+            </dependency>
+          </dependencies>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git 
a/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/ConfiguredVelocityTool.java
 
b/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/ConfiguredVelocityTool.java
new file mode 100644
index 00000000..3fa97fc5
--- /dev/null
+++ 
b/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/ConfiguredVelocityTool.java
@@ -0,0 +1,50 @@
+package org.apache.maven.plugins.site.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.velocity.context.Context;
+import org.apache.velocity.tools.config.DefaultKey;
+import org.apache.velocity.tools.generic.SafeConfig;
+import org.apache.velocity.tools.generic.ValueParser;
+
+/**
+ * A tool shaped like the Reflow skin's: configured through {@link 
SafeConfig}, reading its property and the
+ * Velocity context.
+ */
+@DefaultKey( "configured" )
+public class ConfiguredVelocityTool
+    extends SafeConfig
+{
+    private Context context;
+
+    private String greeting;
+
+    @Override
+    protected void configure( ValueParser values )
+    {
+        context = (Context) values.get( "velocityContext" );
+        greeting = values.getString( "greeting" );
+    }
+
+    public String hello()
+    {
+        return greeting + " " + context.get( "currentFileName" );
+    }
+}
diff --git 
a/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/SetterVelocityTool.java
 
b/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/SetterVelocityTool.java
new file mode 100644
index 00000000..3fd8650e
--- /dev/null
+++ 
b/src/it/projects/velocity-tools/src/main/java/org/apache/maven/plugins/site/it/SetterVelocityTool.java
@@ -0,0 +1,38 @@
+package org.apache.maven.plugins.site.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A tool configured through a setter only.
+ */
+public class SetterVelocityTool
+{
+    private int depth;
+
+    public void setDepth( int depth )
+    {
+        this.depth = depth;
+    }
+
+    public int getDepth()
+    {
+        return depth;
+    }
+}
diff --git 
a/src/it/projects/velocity-tools/src/main/resources/META-INF/maven/site-tools.xml
 
b/src/it/projects/velocity-tools/src/main/resources/META-INF/maven/site-tools.xml
new file mode 100644
index 00000000..13fbe416
--- /dev/null
+++ 
b/src/it/projects/velocity-tools/src/main/resources/META-INF/maven/site-tools.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<tools>
+  <toolbox scope="application">
+    <tool class="org.apache.maven.plugins.site.it.ConfiguredVelocityTool" 
greeting="Hello" />
+    <tool key="setter" 
class="org.apache.maven.plugins.site.it.SetterVelocityTool" depth="5" />
+    <tool key="date" format="dd/MM/yyyy" />
+  </toolbox>
+</tools>
diff --git a/src/it/projects/velocity-tools/src/site/apt/tools.apt.vm 
b/src/it/projects/velocity-tools/src/site/apt/tools.apt.vm
new file mode 100644
index 00000000..46d3fa63
--- /dev/null
+++ b/src/it/projects/velocity-tools/src/site/apt/tools.apt.vm
@@ -0,0 +1,41 @@
+ -----
+ Velocity tools
+ -----
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~   http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+Velocity tools
+
+ configured=$configured.hello()
+
+ setter=$setter.depth
+
+ date=$date.format( $date.toDate( 'yyyy-MM-dd', '2026-10-26' ) )
+
+ render=$render.eval( '#if( true )$esc.html( "<b>" )#end' )
+
+ esc=$esc.xml( "a'b" )
+
+ sorter=#foreach( $key in $sorter.sort( ['b', 'c', 'a'] ) )$key#end
+
+
+ convert=$convert.toBoolean( 'true' )
+
+ text=$text.get( 'template.version' )
+
+ context=$context.contains( 'configured' )
diff --git a/src/it/projects/velocity-tools/verify.groovy 
b/src/it/projects/velocity-tools/verify.groovy
new file mode 100644
index 00000000..2da8a4d9
--- /dev/null
+++ b/src/it/projects/velocity-tools/verify.groovy
@@ -0,0 +1,31 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def content = new File( basedir, 'target/generated-site/processed/tools.apt' 
).text
+
+assert content.contains( 'configured=Hello tools.html' ) : 'custom SafeConfig 
tool must get its property and the context'
+assert content.contains( 'setter=5' ) : 'custom tool must be configured 
through its setter'
+assert content.contains( 'date=26/10/2026' ) : 'site-tools.xml must override 
the format of the date tool'
+assert content.contains( 'render=&lt;b&gt;' ) : 'render.eval must see the 
other tools'
+assert content.contains( 'esc=a&apos;b' )
+assert content.contains( 'sorter=abc' )
+assert content.contains( 'convert=true' )
+assert content.contains( 'text=Version' )
+assert content.contains( 'context=true' )

Reply via email to