Author: cbrisson
Date: Sat Jun 1 16:03:43 2019
New Revision: 1860483
URL: http://svn.apache.org/viewvc?rev=1860483&view=rev
Log:
[engine][VELOCITY-917] Build standard and tailored parsers
Modified:
velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
Modified:
velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml?rev=1860483&r1=1860482&r2=1860483&view=diff
==============================================================================
--- velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
(original)
+++ velocity/engine/branches/parser_experiments/velocity-engine-core/pom.xml
Sat Jun 1 16:03:43 2019
@@ -54,6 +54,7 @@
<build>
<plugins>
+ <!-- resources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
@@ -65,6 +66,8 @@
</delimiters>
</configuration>
</plugin>
+
+ <!-- shading of commons-io -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@@ -96,6 +99,8 @@
</execution>
</executions>
</plugin>
+
+ <!-- tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -154,16 +159,38 @@
</execution>
</executions>
</plugin>
+
+ <!-- parser -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.6</version>
<executions>
+ <!-- build the standard parser -->
<execution>
<id>jjtree-javacc</id>
<goals>
<goal>jjtree-javacc</goal>
</goals>
+ <configuration>
+ <includes>
+ <include>StandardParser.jjt</include>
+ </includes>
+ </configuration>
+ </execution>
+ <!-- build a tailored parser -->
+ <execution>
+ <id>jjtree-javacc-custom</id>
+ <goals>
+ <goal>jjtree-javacc</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>TailoredParser.jjt</include>
+ </includes>
+
<interimDirectory>${project.build.directory}/tailored-parser/jjtree</interimDirectory>
+
<outputDirectory>${project.build.directory}/tailored-parser/javacc</outputDirectory>
+ </configuration>
</execution>
</executions>
<configuration>
@@ -181,10 +208,11 @@
<tokenManagerUsesParser>true</tokenManagerUsesParser>
</configuration>
</plugin>
+
<!--
- patch generated parser and token managers files, so that
- + StandardParserTokenManager implements the ParserTokenManager
interface
- + StandardParser uses the ParserTokenManager interface
+ patch generated parser and token managers files, so that
+ + both token managers implement the ParserTokenManager interface
+ + StandardParser uses the ParserTokenManager interface
-->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
@@ -192,7 +220,7 @@
<version>1.5.3</version>
<executions>
<execution>
- <id>patch-token-manager</id>
+ <id>patch-parser</id>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
@@ -208,15 +236,19 @@
</configuration>
</execution>
<execution>
+ <id>patch-token-manager</id>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
-
<file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParserTokenManager.java</file>
+ <includes>
+
<include>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParserTokenManager.java</include>
+
<include>${project.build.directory}/tailored-parser/javacc/org/apache/velocity/runtime/parser/TailoredParserTokenManager.java</include>
+ </includes>
<replacements>
<replacement>
- <token>class StandardParserTokenManager
implements StandardParserConstants</token>
+ <token>class StandardParserTokenManager
implements StandardParserConstants(?!, ParserTokenManager)</token>
<value>class StandardParserTokenManager
implements StandardParserConstants, ParserTokenManager</value>
</replacement>
</replacements>
@@ -224,28 +256,29 @@
</execution>
</executions>
</plugin>
+
+ <!-- pre-compile both parser token manager classes -->
<plugin>
- <groupId>com.google.code.maven-replacer-plugin</groupId>
- <artifactId>replacer</artifactId>
- <version>1.5.3</version>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <goals>
- <goal>replace</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
-
<file>${project.build.directory}/generated-sources/javacc/org/apache/velocity/runtime/parser/StandardParser.java</file>
- <replacements>
- <replacement>
- <token>(?<!new )StandardParserTokenManager</token>
- <value>ParserTokenManager</value>
- </replacement>
- </replacements>
- </configuration>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>compile-patch-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+
<buildDirectory>${project.build.directory}/tailored-parser/classes</buildDirectory>
+ <includes>
+ <include>**/*TokenManager*.java/</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
+
+ <!-- handle OSGi informations -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -261,8 +294,46 @@
</instructions>
</configuration>
</plugin>
+
+ <!-- remove duplicate javacc files -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>clean-extra-javacc</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ <configuration>
+ <excludeDefaultDirectories>true</excludeDefaultDirectories>
+ <filesets>
+ <fileset>
+
<directory>${project.build.directory}/tailored-parser/javacc</directory>
+ <includes>
+
<include>org/apache/velocity/runtime/parser/Token*.java</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- exclude tailored parser from final archive -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*TailoredParser*.class</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
+
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>