Author: cbrisson
Date: Wed Apr 25 11:08:51 2012
New Revision: 1330192
URL: http://svn.apache.org/viewvc?rev=1330192&view=rev
Log:
applying Jarkko patch for javacc & maven (tests are fine) - issue VELOCITY-819
Removed:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/JJTParserState.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserConstants.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTreeConstants.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Token.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TokenMgrError.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/build.sh
Modified:
velocity/engine/trunk/velocity-engine-core/pom.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/BUILD_README.txt
Modified: velocity/engine/trunk/velocity-engine-core/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/pom.xml?rev=1330192&r1=1330191&r2=1330192&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-core/pom.xml Wed Apr 25 11:08:51 2012
@@ -11,6 +11,14 @@
<version>2.0.0-SNAPSHOT</version>
<name>Apache Velocity - Engine</name>
+ <properties>
+ <!-- command line switch -Dparser.create=true generates the parser
files -->
+ <parser.create>false</parser.create>
+
+ <!-- command line switch -Dparser.nodefiles=true generates AST Node
classes (new structures added to parser) -->
+ <parser.nodefiles>false</parser.nodefiles>
+ </properties>
+
<build>
<plugins>
<plugin>
@@ -69,7 +77,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <skip>${maven.test.skip}</skip>
<systemProperties>
<property>
<name>test</name>
@@ -98,6 +106,91 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javacc-maven-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>jjtree-javacc</id>
+ <goals>
+ <goal>jjtree-javacc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <isStatic>false</isStatic>
+ <buildParser>true</buildParser>
+ <buildNodeFiles>${parser.nodefiles}</buildNodeFiles>
+ <multi>true</multi>
+ <debugParser>false</debugParser>
+ <jdkVersion>1.4</jdkVersion>
+ <nodeUsesParser>true</nodeUsesParser>
+
<nodePackage>org.apache.velocity.runtime.parser</nodePackage>
+
<sourceDirectory>${basedir}/src/main/parser</sourceDirectory>
+
<interimDirectory>${basedir}/src/main/java</interimDirectory>
+ <outputDirectory>${basedir}/src/main/java</outputDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>parser-init</id>
+ <phase>initialize</phase>
+ <configuration>
+ <target if="${parser.create}">
+ <delete quiet="true" verbose="false">
+ <fileset
dir="${basedir}/src/main/java/org/apache/velocity/runtime/parser"
+
includes="AST*.java,Parser*.java,Token*.java"/>
+ </delete>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>parser-cleanup</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <target>
+ <!-- delete
unnecessary files generated by JavaCC -->
+ <delete quiet="true" verbose="false">
+ <fileset
dir="${basedir}/src/main/java/org/apache/velocity/runtime/parser"
+
includes="Node.java,ParserVisitor.java,SimpleNode.java"/>
+ </delete>
+ <!-- fix
JJTParserState class to use our custom Node class -->
+ <replace
file="${basedir}/src/main/java/org/apache/velocity/runtime/parser/JJTParserState.java">
+
<replacetoken>import
org.apache.velocity.runtime.parser.node.Node;</replacetoken>
+ <replacevalue></replacevalue>
+ </replace>
+ <replace
file="${basedir}/src/main/java/org/apache/velocity/runtime/parser/JJTParserState.java">
+
<replacetoken>package org.apache.velocity.runtime.parser;</replacetoken>
+ <replacevalue>package
org.apache.velocity.runtime.parser; import
org.apache.velocity.runtime.parser.node.Node;</replacevalue>
+ </replace>
+ <!-- if we just
generated AST Node classes by JavaCC, end the build here and give instructions
-->
+ <condition
property="stop"><istrue value="${parser.nodefiles}"/></condition>
+ <fail
if="stop"><![CDATA[-
+-------------------------------------------------------------------------------
+Velocity AST Node classes created to
src/main/java/org/apache/velocity/runtime/parser
+
+1. Delete already existing AST Node classes from this directory
+2. Move the new generated AST Node class(es) to
src/main/java/org/apache/velocity/runtime/parser/node
+3. Change the package name of the new AST Node(s) in the source code file
+4. Write the source code to support the new desired functionality of that node
+-------------------------------------------------------------------------------
+]]>
+</fail>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<dependencies>
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/BUILD_README.txt
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/BUILD_README.txt?rev=1330192&r1=1330191&r2=1330192&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/BUILD_README.txt
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/BUILD_README.txt
Wed Apr 25 11:08:51 2012
@@ -1,28 +1,22 @@
-Quick Note:
------------
-The parser is a 'special' piece of the build tree - currently it doesn't
-behave as everything else due to javacc and the package layout.
+The following Parser related source files will be generated by Maven (and thus
not stored in version control):
+Parser.java
+ParserConstants.java
+ParserTokenManager.java
+ParserTreeConstants.java
+Token.java
+TokenMgrError.java
+JJTParserState.java
-1) The build script in this directory will take care of the simple case
-when the parser is modified via Parser.jjt. It runs 'jjtree' on Parser.jjt
-to make the AST nodes (which are then deleted later - more on this in a bit)
-and creates Parser.jj for javacc.
+See pom.xml how this magic works.
-2) Javacc is then run on Parser.jj to make Parser.java, which will be compiled
-like any other piece of java source via build-velocity.sh (or whatever
follows.)
-3) In the event that something 'serious' changes, such as an AST node is
created
-or altered, it must be *manually* moved to the node subdirectory, and have it's
-package declaration fixed. This should be an extremely rare event at this
point
-and will change with javacc 2.0.
-4) When committing changes, to aid readability to those watching the cvs
commit
-messages, please commit Parser.jjt separately from the .jj and .java
-files generated from .jjt.
+To recreate Parser (using src/parser/Parser.jjt), use a command line switch:
+mvn -Dparser.create=true package
--gmj
-5) Finally, note that in order to create code that will compile with JDK 1.5,
-you will need to use JavaCC 3.2 or later (replaces variable "enumeration" with
"e". (WGH)
+If there are new structures or nodetypes in the Parser.jjt, generate the new
AST nodefiles by using a command line switch:
+mvn -Dparser.nodefiles=true package
+Maven build will display the instructions.
\ No newline at end of file