Building String Template with Maven 2
Maven 2 makes building String Template very easy. However, the layout of the code and project resources do not match the typical Maven project structure. It is possible to bend Maven around the StringTemplate project layout via various configuration settings. A much simpler and elagent solution is to modify the project structure. The following batch file does just that for String Template 3.x:
@echo off
set pkg=org\antlr\stringtemplate
echo Setting up the source structure to maven 2 standards.
move src src-orig
mkdir src\main\java\%pkg%\language
mkdir src\main\java\%pkg%\misc
mkdir src\main\antlr
mkdir src\test\java\%pkg%\test
mkdir src\test\resources\%pkg%\test
copy src-orig\%pkg%\*.java src\main\java\%pkg%
copy src-orig\%pkg%\language\*.java src\main\java\%pkg%\language
copy src-orig\%pkg%\language\*.g src\main\antlr
copy src-orig\%pkg%\misc\*.java src\main\java\%pkg%\misc
copy src-orig\%pkg%\test\*.java src\test\java\%pkg%\test
copy src-orig\%pkg%\test\*.st src\test\resources\%pkg%\test
The batch file should be placed in the parent directory of src and run once (it may be removed after that). The batch job copies the original src directory to src-orig and builds a standard maven 2 project structure from the files. A similar unix shell script can be created quite easily. The pom.xml file listed below is required to describe the project and enable building with maven 2 (eg. /> mvn package). Place the pom file in the the same location as the batch job.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.stringtemplate</groupId>
<artifactId>stringtemplate</artifactId>
<packaging>jar</packaging>
<version>3.0.1</version>
<description>String template engine</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antlr-plugin</artifactId>
<configuration>
<grammars>action.g,angle.bracket.template.g,eval.g,group.g,interface.g,template.g</grammars>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
test</scope>-->
</dependency>
<dependency><groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Note: Over time the list of gramar files in the pom will need updating.