xref: /aosp_15_r20/external/apache-velocity-engine/velocity-custom-parser-example/pom.xml (revision 6626518d3d1a3a4cd21045b7974855fd6a3e2103)
1*6626518dSAndrew Vuong<?xml version="1.0" encoding="UTF-8"?>
2*6626518dSAndrew Vuong<!--
3*6626518dSAndrew Vuong
4*6626518dSAndrew Vuong    Licensed to the Apache Software Foundation (ASF) under one
5*6626518dSAndrew Vuong    or more contributor license agreements.  See the NOTICE file
6*6626518dSAndrew Vuong    distributed with this work for additional information
7*6626518dSAndrew Vuong    regarding copyright ownership.  The ASF licenses this file
8*6626518dSAndrew Vuong    to you under the Apache License, Version 2.0 (the
9*6626518dSAndrew Vuong    "License"); you may not use this file except in compliance
10*6626518dSAndrew Vuong    with the License.  You may obtain a copy of the License at
11*6626518dSAndrew Vuong
12*6626518dSAndrew Vuong      http://www.apache.org/licenses/LICENSE-2.0
13*6626518dSAndrew Vuong
14*6626518dSAndrew Vuong    Unless required by applicable law or agreed to in writing,
15*6626518dSAndrew Vuong    software distributed under the License is distributed on an
16*6626518dSAndrew Vuong    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*6626518dSAndrew Vuong    KIND, either express or implied.  See the License for the
18*6626518dSAndrew Vuong    specific language governing permissions and limitations
19*6626518dSAndrew Vuong    under the License.
20*6626518dSAndrew Vuong
21*6626518dSAndrew Vuong-->
22*6626518dSAndrew Vuong<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">
23*6626518dSAndrew Vuong    <modelVersion>4.0.0</modelVersion>
24*6626518dSAndrew Vuong    <parent>
25*6626518dSAndrew Vuong        <groupId>org.apache.velocity</groupId>
26*6626518dSAndrew Vuong        <artifactId>velocity-engine-parent</artifactId>
27*6626518dSAndrew Vuong        <version>2.4-SNAPSHOT</version>
28*6626518dSAndrew Vuong    </parent>
29*6626518dSAndrew Vuong
30*6626518dSAndrew Vuong    <artifactId>velocity-custom-parser-example</artifactId>
31*6626518dSAndrew Vuong    <name>Apache Velocity Custom Parser Example</name>
32*6626518dSAndrew Vuong    <description>Custom Parser Example for Apache Velocity</description>
33*6626518dSAndrew Vuong
34*6626518dSAndrew Vuong    <packaging>pom</packaging>
35*6626518dSAndrew Vuong
36*6626518dSAndrew Vuong    <!--
37*6626518dSAndrew Vuong      This module demonstrates how to build a custom Velocity parser.
38*6626518dSAndrew Vuong      The proposed custom parser replaces '#' with '@' and '@' with '%'
39*6626518dSAndrew Vuong      so that it's suitable to use with Markdown template files, for instance.
40*6626518dSAndrew Vuong
41*6626518dSAndrew Vuong      The generated parser class is ${parser.package}.${parser.basename}Parser,
42*6626518dSAndrew Vuong      and must be specified at runtime using the Velocity property parser.class:
43*6626518dSAndrew Vuong        parser.class = foo.bar.MyCustomParser
44*6626518dSAndrew Vuong
45*6626518dSAndrew Vuong      Please note that all configurable chars (*, @, $, #) must be specified, even when similar to default ones.
46*6626518dSAndrew Vuong    -->
47*6626518dSAndrew Vuong
48*6626518dSAndrew Vuong    <properties>
49*6626518dSAndrew Vuong        <!-- whether to display debug logs while parsing -->
50*6626518dSAndrew Vuong        <parser.debug>false</parser.debug>
51*6626518dSAndrew Vuong        <!-- parser basename -->
52*6626518dSAndrew Vuong        <parser.basename>Custom</parser.basename>
53*6626518dSAndrew Vuong        <!-- parser package -->
54*6626518dSAndrew Vuong        <parser.package>org.apache.velocity.runtime.parser.custom</parser.package>
55*6626518dSAndrew Vuong        <!-- character to substitute to '*' -->
56*6626518dSAndrew Vuong        <parser.char.asterisk>*</parser.char.asterisk>
57*6626518dSAndrew Vuong        <!-- character to substitute to '@' -->
58*6626518dSAndrew Vuong        <parser.char.at>%</parser.char.at>
59*6626518dSAndrew Vuong        <!-- character to substitute to '$' -->
60*6626518dSAndrew Vuong        <parser.char.dollar>$</parser.char.dollar>
61*6626518dSAndrew Vuong        <!-- character to substitute to '#' -->
62*6626518dSAndrew Vuong        <parser.char.hash>@</parser.char.hash>
63*6626518dSAndrew Vuong    </properties>
64*6626518dSAndrew Vuong
65*6626518dSAndrew Vuong    <dependencies>
66*6626518dSAndrew Vuong        <dependency>
67*6626518dSAndrew Vuong            <groupId>org.apache.velocity</groupId>
68*6626518dSAndrew Vuong            <artifactId>velocity-engine-core</artifactId>
69*6626518dSAndrew Vuong            <version>${project.version}</version>
70*6626518dSAndrew Vuong        </dependency>
71*6626518dSAndrew Vuong        <dependency>
72*6626518dSAndrew Vuong            <groupId>junit</groupId>
73*6626518dSAndrew Vuong            <artifactId>junit</artifactId>
74*6626518dSAndrew Vuong            <version>${junit.version}</version>
75*6626518dSAndrew Vuong            <scope>test</scope>
76*6626518dSAndrew Vuong        </dependency>
77*6626518dSAndrew Vuong        <dependency>
78*6626518dSAndrew Vuong            <groupId>org.slf4j</groupId>
79*6626518dSAndrew Vuong            <artifactId>slf4j-simple</artifactId>
80*6626518dSAndrew Vuong            <version>${slf4j.version}</version>
81*6626518dSAndrew Vuong            <scope>test</scope>
82*6626518dSAndrew Vuong        </dependency>
83*6626518dSAndrew Vuong        <dependency>
84*6626518dSAndrew Vuong            <groupId>commons-io</groupId>
85*6626518dSAndrew Vuong            <artifactId>commons-io</artifactId>
86*6626518dSAndrew Vuong            <version>2.8.0</version>
87*6626518dSAndrew Vuong        </dependency>
88*6626518dSAndrew Vuong    </dependencies>
89*6626518dSAndrew Vuong
90*6626518dSAndrew Vuong    <build>
91*6626518dSAndrew Vuong        <plugins>
92*6626518dSAndrew Vuong            <!-- generate manifest file -->
93*6626518dSAndrew Vuong            <plugin>
94*6626518dSAndrew Vuong                <groupId>org.apache.felix</groupId>
95*6626518dSAndrew Vuong                <artifactId>maven-bundle-plugin</artifactId>
96*6626518dSAndrew Vuong            </plugin>
97*6626518dSAndrew Vuong
98*6626518dSAndrew Vuong            <!-- extract raw parser grammar from velocity jar -->
99*6626518dSAndrew Vuong            <plugin>
100*6626518dSAndrew Vuong                <groupId>org.apache.maven.plugins</groupId>
101*6626518dSAndrew Vuong                <artifactId>maven-dependency-plugin</artifactId>
102*6626518dSAndrew Vuong                <executions>
103*6626518dSAndrew Vuong                    <execution>
104*6626518dSAndrew Vuong                        <id>fetch-grammar-file</id>
105*6626518dSAndrew Vuong                        <phase>initialize</phase>
106*6626518dSAndrew Vuong                        <goals>
107*6626518dSAndrew Vuong                            <goal>unpack</goal>
108*6626518dSAndrew Vuong                        </goals>
109*6626518dSAndrew Vuong                        <configuration>
110*6626518dSAndrew Vuong                            <artifact>org.apache.velocity:velocity-engine-core:${project.version}</artifact>
111*6626518dSAndrew Vuong                            <includes>org/apache/velocity/runtime/parser/Parser.jjt</includes>
112*6626518dSAndrew Vuong                            <outputDirectory>${project.build.directory}/grammar</outputDirectory>
113*6626518dSAndrew Vuong                        </configuration>
114*6626518dSAndrew Vuong                    </execution>
115*6626518dSAndrew Vuong                </executions>
116*6626518dSAndrew Vuong            </plugin>
117*6626518dSAndrew Vuong
118*6626518dSAndrew Vuong            <!-- generate custom grammar file -->
119*6626518dSAndrew Vuong            <plugin>
120*6626518dSAndrew Vuong                <groupId>org.apache.maven.plugins</groupId>
121*6626518dSAndrew Vuong                <artifactId>maven-resources-plugin</artifactId>
122*6626518dSAndrew Vuong                <executions>
123*6626518dSAndrew Vuong                    <execution>
124*6626518dSAndrew Vuong                        <id>generate-parser-grammar</id>
125*6626518dSAndrew Vuong                        <phase>generate-sources</phase>
126*6626518dSAndrew Vuong                        <goals>
127*6626518dSAndrew Vuong                            <goal>copy-resources</goal>
128*6626518dSAndrew Vuong                        </goals>
129*6626518dSAndrew Vuong                        <configuration>
130*6626518dSAndrew Vuong                            <useDefaultDelimiters>false</useDefaultDelimiters>
131*6626518dSAndrew Vuong                            <delimiters>
132*6626518dSAndrew Vuong                                <delimiter>${*}</delimiter>
133*6626518dSAndrew Vuong                            </delimiters>
134*6626518dSAndrew Vuong                            <resources>
135*6626518dSAndrew Vuong                                <resource>
136*6626518dSAndrew Vuong                                    <directory>${project.build.directory}/grammar</directory>
137*6626518dSAndrew Vuong                                    <filtering>true</filtering>
138*6626518dSAndrew Vuong                                </resource>
139*6626518dSAndrew Vuong                            </resources>
140*6626518dSAndrew Vuong                            <outputDirectory>${project.build.directory}/parser</outputDirectory>
141*6626518dSAndrew Vuong                        </configuration>
142*6626518dSAndrew Vuong                    </execution>
143*6626518dSAndrew Vuong                </executions>
144*6626518dSAndrew Vuong            </plugin>
145*6626518dSAndrew Vuong
146*6626518dSAndrew Vuong            <!-- run javacc -->
147*6626518dSAndrew Vuong            <plugin>
148*6626518dSAndrew Vuong                <groupId>org.codehaus.mojo</groupId>
149*6626518dSAndrew Vuong                <artifactId>javacc-maven-plugin</artifactId>
150*6626518dSAndrew Vuong                <version>2.6</version>
151*6626518dSAndrew Vuong                <configuration>
152*6626518dSAndrew Vuong                    <isStatic>false</isStatic>
153*6626518dSAndrew Vuong                    <buildParser>true</buildParser>
154*6626518dSAndrew Vuong                    <buildNodeFiles>false</buildNodeFiles>
155*6626518dSAndrew Vuong                    <multi>true</multi>
156*6626518dSAndrew Vuong                    <debugParser>${parser.debug}</debugParser>
157*6626518dSAndrew Vuong                    <debugLookAhead>${parser.debug}</debugLookAhead>
158*6626518dSAndrew Vuong                    <debugTokenManager>${parser.debug}</debugTokenManager>
159*6626518dSAndrew Vuong                    <jdkVersion>${maven.compiler.target}</jdkVersion>
160*6626518dSAndrew Vuong                    <nodeUsesParser>true</nodeUsesParser>
161*6626518dSAndrew Vuong                    <nodePackage>${parser.package}.node</nodePackage>
162*6626518dSAndrew Vuong                    <sourceDirectory>${project.build.directory}/parser/org/apache/velocity/runtime/parser</sourceDirectory>
163*6626518dSAndrew Vuong                    <tokenManagerUsesParser>true</tokenManagerUsesParser>
164*6626518dSAndrew Vuong                </configuration>
165*6626518dSAndrew Vuong                <executions>
166*6626518dSAndrew Vuong                    <execution>
167*6626518dSAndrew Vuong                        <id>jjtree-javacc</id>
168*6626518dSAndrew Vuong                        <phase>generate-sources</phase>
169*6626518dSAndrew Vuong                        <goals>
170*6626518dSAndrew Vuong                            <goal>jjtree-javacc</goal>
171*6626518dSAndrew Vuong                        </goals>
172*6626518dSAndrew Vuong                        <configuration>
173*6626518dSAndrew Vuong                            <includes>
174*6626518dSAndrew Vuong                                <include>Parser.jjt</include>
175*6626518dSAndrew Vuong                            </includes>
176*6626518dSAndrew Vuong                        </configuration>
177*6626518dSAndrew Vuong                    </execution>
178*6626518dSAndrew Vuong                </executions>
179*6626518dSAndrew Vuong            </plugin>
180*6626518dSAndrew Vuong
181*6626518dSAndrew Vuong            <!-- Remove extra generated files we don't want -->
182*6626518dSAndrew Vuong            <plugin>
183*6626518dSAndrew Vuong                <groupId>org.apache.maven.plugins</groupId>
184*6626518dSAndrew Vuong                <artifactId>maven-clean-plugin</artifactId>
185*6626518dSAndrew Vuong                <executions>
186*6626518dSAndrew Vuong                    <execution>
187*6626518dSAndrew Vuong                        <id>clean-extra-javacc</id>
188*6626518dSAndrew Vuong                        <phase>process-sources</phase>
189*6626518dSAndrew Vuong                        <goals>
190*6626518dSAndrew Vuong                            <goal>clean</goal>
191*6626518dSAndrew Vuong                        </goals>
192*6626518dSAndrew Vuong                        <configuration>
193*6626518dSAndrew Vuong                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
194*6626518dSAndrew Vuong                            <filesets>
195*6626518dSAndrew Vuong                                <fileset>
196*6626518dSAndrew Vuong                                    <directory>${project.build.directory}/generated-sources/javacc/</directory>
197*6626518dSAndrew Vuong                                    <includes>
198*6626518dSAndrew Vuong                                        <include>**/*.java</include>
199*6626518dSAndrew Vuong                                    </includes>
200*6626518dSAndrew Vuong                                    <excludes>
201*6626518dSAndrew Vuong                                        <exclude>**/*${parser.basename}*.java</exclude>
202*6626518dSAndrew Vuong                                    </excludes>
203*6626518dSAndrew Vuong                                </fileset>
204*6626518dSAndrew Vuong                                <fileset>
205*6626518dSAndrew Vuong                                    <directory>${project.build.directory}/generated-sources/jjtree/</directory>
206*6626518dSAndrew Vuong                                    <includes>
207*6626518dSAndrew Vuong                                        <include>**/node/*.java</include>
208*6626518dSAndrew Vuong                                    </includes>
209*6626518dSAndrew Vuong                                    <excludes>
210*6626518dSAndrew Vuong                                        <exclude>**/node/*${parser.basename}*.java</exclude>
211*6626518dSAndrew Vuong                                    </excludes>
212*6626518dSAndrew Vuong                                </fileset>
213*6626518dSAndrew Vuong                            </filesets>
214*6626518dSAndrew Vuong                        </configuration>
215*6626518dSAndrew Vuong                    </execution>
216*6626518dSAndrew Vuong                </executions>
217*6626518dSAndrew Vuong            </plugin>
218*6626518dSAndrew Vuong
219*6626518dSAndrew Vuong            <!-- add missing imports to some parser generated files -->
220*6626518dSAndrew Vuong            <plugin>
221*6626518dSAndrew Vuong                <groupId>com.google.code.maven-replacer-plugin</groupId>
222*6626518dSAndrew Vuong                <artifactId>replacer</artifactId>
223*6626518dSAndrew Vuong                <executions>
224*6626518dSAndrew Vuong                    <execution>
225*6626518dSAndrew Vuong                        <id>patch-parser-files</id>
226*6626518dSAndrew Vuong                        <phase>process-sources</phase>
227*6626518dSAndrew Vuong                        <goals>
228*6626518dSAndrew Vuong                            <goal>replace</goal>
229*6626518dSAndrew Vuong                        </goals>
230*6626518dSAndrew Vuong                        <configuration>
231*6626518dSAndrew Vuong                            <includes>
232*6626518dSAndrew Vuong                                <include>${project.build.directory}/generated-sources/jjtree/**/JJT${parser.basename}ParserState.java</include>
233*6626518dSAndrew Vuong                                <include>${project.build.directory}/generated-sources/jjtree/**/${parser.basename}ParserVisitor.java</include>
234*6626518dSAndrew Vuong                            </includes>
235*6626518dSAndrew Vuong                            <replacements>
236*6626518dSAndrew Vuong                                <replacement>
237*6626518dSAndrew Vuong                                    <token>import ${parser.package}.*;</token>
238*6626518dSAndrew Vuong                                    <value>import ${parser.package}.*;
239*6626518dSAndrew Vuongimport org.apache.velocity.runtime.parser.node.*;</value>
240*6626518dSAndrew Vuong                                </replacement>
241*6626518dSAndrew Vuong                            </replacements>
242*6626518dSAndrew Vuong                        </configuration>
243*6626518dSAndrew Vuong                    </execution>
244*6626518dSAndrew Vuong                </executions>
245*6626518dSAndrew Vuong            </plugin>
246*6626518dSAndrew Vuong
247*6626518dSAndrew Vuong            <!-- tests -->
248*6626518dSAndrew Vuong            <plugin>
249*6626518dSAndrew Vuong                <groupId>org.apache.maven.plugins</groupId>
250*6626518dSAndrew Vuong                <artifactId>maven-surefire-plugin</artifactId>
251*6626518dSAndrew Vuong                <version>${surefire.plugin.version}</version>
252*6626518dSAndrew Vuong                <configuration>
253*6626518dSAndrew Vuong                    <skip>${maven.test.skip}</skip>
254*6626518dSAndrew Vuong                    <systemProperties>
255*6626518dSAndrew Vuong                        <property>
256*6626518dSAndrew Vuong                            <name>test</name>
257*6626518dSAndrew Vuong                            <value>${test}</value>
258*6626518dSAndrew Vuong                        </property>
259*6626518dSAndrew Vuong                        <property>
260*6626518dSAndrew Vuong                            <name>test.templates.dir</name>
261*6626518dSAndrew Vuong                            <value>${project.build.testOutputDirectory}/templates</value>
262*6626518dSAndrew Vuong                        </property>
263*6626518dSAndrew Vuong                        <property>
264*6626518dSAndrew Vuong                            <name>test.results.dir</name>
265*6626518dSAndrew Vuong                            <value>${project.build.directory}/results</value>
266*6626518dSAndrew Vuong                        </property>
267*6626518dSAndrew Vuong                        <property>
268*6626518dSAndrew Vuong                            <name>test.reference.dir</name>
269*6626518dSAndrew Vuong                            <value>${project.build.testOutputDirectory}/reference</value>
270*6626518dSAndrew Vuong                        </property>
271*6626518dSAndrew Vuong                        <property>
272*6626518dSAndrew Vuong                            <name>org.slf4j.simpleLogger.defaultLogLevel</name>
273*6626518dSAndrew Vuong                            <value>warn</value>
274*6626518dSAndrew Vuong                        </property>
275*6626518dSAndrew Vuong                        <property>
276*6626518dSAndrew Vuong                            <name>org.slf4j.simpleLogger.logFile</name>
277*6626518dSAndrew Vuong                            <value>${project.build.directory}/velocity.log</value>
278*6626518dSAndrew Vuong                        </property>
279*6626518dSAndrew Vuong                    </systemProperties>
280*6626518dSAndrew Vuong                </configuration>
281*6626518dSAndrew Vuong            </plugin>
282*6626518dSAndrew Vuong        </plugins>
283*6626518dSAndrew Vuong    </build>
284*6626518dSAndrew Vuong</project>
285