xref: /aosp_15_r20/external/antlr/antlr3-maven-plugin/src/site/apt/index.apt (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot         -------------
2*16467b97STreehugger Robot         ANTLR v3 Maven Plugin
3*16467b97STreehugger Robot         -------------
4*16467b97STreehugger Robot         Jim Idle
5*16467b97STreehugger Robot         -------------
6*16467b97STreehugger Robot         March 2009
7*16467b97STreehugger Robot         -------------
8*16467b97STreehugger Robot
9*16467b97STreehugger RobotANTLR v3 Maven plugin
10*16467b97STreehugger Robot
11*16467b97STreehugger Robot The ANTLR v3 Maven plugin is completely re-written as of version 3.1.3; if you are familiar
12*16467b97STreehugger Robot with prior versions, you should note that there are some behavioral differences that make
13*16467b97STreehugger Robot it worthwhile reading this documentation.
14*16467b97STreehugger Robot
15*16467b97STreehugger Robot The job of the plugin is essentially to tell the standard ANTLR parser generator where the
16*16467b97STreehugger Robot input grammar files are and where the output files should be generated. As with all Maven
17*16467b97STreehugger Robot plugins, there are defaults, which you are advised to comply to, but are not forced to
18*16467b97STreehugger Robot comply to.
19*16467b97STreehugger Robot
20*16467b97STreehugger Robot This version of the plugin allows full control over ANTLR and allows configuration of all
21*16467b97STreehugger Robot options that are useful for a build system. The code required to calculate dependencies,
22*16467b97STreehugger Robot check the build order, and otherwise work with your grammar files is built into the ANTLR
23*16467b97STreehugger Robot tool as of version 3.1.3 of ANTLR and this plugin.
24*16467b97STreehugger Robot
25*16467b97STreehugger Robot* Plugin Versioning
26*16467b97STreehugger Robot
27*16467b97STreehugger Robot The plugin version tracks the version of the ANTLR tool that it controls. Hence if you
28*16467b97STreehugger Robot use version 3.1.3 of the plugin, you will build your grammars using version 3.1.3 of the
29*16467b97STreehugger Robot ANTLR tool, version 3.2 of the plugin will use version 3.2 of the ANTLR tool and so on.
30*16467b97STreehugger Robot
31*16467b97STreehugger Robot You may also find that there are patch versions of the plugin such as 3.1.3-1 3.1.3-2 and
32*16467b97STreehugger Robot so on. Use the latest patch release of the plugin.
33*16467b97STreehugger Robot
34*16467b97STreehugger Robot The current version of the plugin is shown at the top of this page after the <<Last Deployed>> date.
35*16467b97STreehugger Robot
36*16467b97STreehugger Robot
37*16467b97STreehugger Robot* Default directories
38*16467b97STreehugger Robot
39*16467b97STreehugger Robot As with all Maven plugins, this plugin will automatically default to standard locations
40*16467b97STreehugger Robot for your grammar and import files. Organizing your source code to reflect this standard
41*16467b97STreehugger Robot layout will greatly reduce the configuration effort required. The standard layout lookd
42*16467b97STreehugger Robot like this:
43*16467b97STreehugger Robot
44*16467b97STreehugger Robot+--
45*16467b97STreehugger Robot src/main/
46*16467b97STreehugger Robot      |
47*16467b97STreehugger Robot      +--- antlr3/... .g files organized in the required package structure
48*16467b97STreehugger Robot             |
49*16467b97STreehugger Robot             +--- imports/  .g files that are imported by other grammars.
50*16467b97STreehugger Robot+--
51*16467b97STreehugger Robot
52*16467b97STreehugger Robot If your grammar is intended to be part of a package called <<<org.foo.bar>>> then you would
53*16467b97STreehugger Robot place it in the directory <<<src/main/antlr3/org/foo/bar>>>. The plugin will then produce
54*16467b97STreehugger Robot <<<.java>>> and <<<.tokens>>> files in the output directory <<<target/generated-sources/antlr3/org/foo/bar>>>
55*16467b97STreehugger Robot When the Java files are compiled they will be in the correct location for the Javac
56*16467b97STreehugger Robot compiler without any special configuration. The generated java files are automatically
57*16467b97STreehugger Robot submitted for compilation by the plugin.
58*16467b97STreehugger Robot
59*16467b97STreehugger Robot The <<<src/main/antlr3/imports>>> directory is treated in a special way. It should contain
60*16467b97STreehugger Robot any grammar files that are imported by other grammar files (do not make subdirectories here.)
61*16467b97STreehugger Robot Such files are never built on their own, but the plugin will automatically tell the ANTLR
62*16467b97STreehugger Robot tool to look in this directory for library files.
63