blob: 2b2495a65963693b2aa25e2d06be93aa4576992c [file] [log] [blame]
-------------
ANTLR v3 Maven Plugin
-------------
Jim Idle
-------------
March 2009
-------------
ANTLR v3 Maven plugin
The ANTLR v3 Maven plugin is completely re-written as of version 3.1.3; if you are familiar
with prior versions, you should note that there are some behavioral differences that make
it worthwhile reading this documentation.
The job of the plugin is essentially to tell the standard ANTLR parser generator where the
input grammar files are and where the output files should be generated. As with all Maven
plugins, there are defaults, which you are advised to comply to, but are not forced to
comply to.
This version of the plugin allows full control over ANTLR and allows configuration of all
options that are useful for a build system. The code required to calculate dependencies,
check the build order, and otherwise work with your grammar files is built into the ANTLR
tool as of version 3.1.3 of ANTLR and this plugin.
* Plugin Versioning
The plugin version tracks the version of the ANTLR tool that it controls. Hence if you
use version 3.1.3 of the plugin, you will build your grammars using version 3.1.3 of the
ANTLR tool, version 3.2 of the plugin will use version 3.2 of the ANTLR tool and so on.
You may also find that there are patch versions of the plugin suchas 3.1.3-1 3.1.3-2 and
so on. Use the latest patch release of the plugin.
The current version of the plugin is shown at the top of this page after the <<Last Deployed>> date.
* Default directories
As with all Maven plugins, this plugin will automatically default to standard locations
for your grammar and import files. Organizing your source code to reflect this standard
layout will greatly reduce the configuration effort required. The standard layout lookd
like this:
+--
src/main/
|
+--- antlr3/... .g files organized in the required package structure
|
+--- imports/ .g files that are imported by other grammars.
+--
If your grammar is intended to be part of a package called org.foo.bar then you would
place it in the directory <<<src/main/antlr3/org/foo/bar>>>. The plugin will then produce
.java and .tokens files in the output directory <<<target/generated-sources/antlr3/org/foo/bar>>>
When the Java files are compiled they will be in the correct location for the javac
compiler without any special configuration. The generated java files are automatically
submitted for compilation by the plugin.
The <<<src/main/antlr3/imports>>> directory is treated in a special way. It should contain
any grammar files that are imported by other grammar files (do not make subdirectories here.)
Such files are never built on their own, but the plugin will automatically tell the ANTLR
tool to look in this directory for library files.