How do I get help on the antlr4-maven-plugin
Asked Answered
A

6

15

The antlr4-maven-plugin does not appear to be document on the Antlr4 website.

Avalos answered 10/3, 2013 at 16:52 Comment(0)
W
15

That might get you nothing, like it did me. Try this:

mvn org.antlr:antlr4-maven-plugin:help -Ddetail=true

Produces:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- antlr4-maven-plugin:4.0:help (default-cli) @ standalone-pom ---
[INFO] ANTLR 4 Maven plugin 4.0
Maven plugin for ANTLR 4 grammars

This plugin has 2 goals:

antlr4:antlr4
Parses ANTLR 4 grammar files *.g4 and transforms them into Java source files.

Available parameters:

arguments
  A list of additional command line arguments to pass to the ANTLR tool.

atn
  If set to true then the ANTLR tool will generate a description of the ATN
  for each rule in Dot format.

encoding
  specify grammar file encoding; e.g., euc-jp

excludes
  A set of Ant-like exclusion patterns used to prevent certain files from
  being processed. By default, this set is empty such that no files are
  excluded.

forceATN
  Use the ATN simulator for all predictions.

includes
  Provides an explicit list of all the grammars that should be included in
  the generate phase of the plugin. Note that the plugin is smart enough to
  realize that imported grammars should be included but not acted upon
  directly by the ANTLR Tool. A set of Ant-like inclusion patterns used to
  select files from the source directory for processing. By default, the
  pattern **/*.g4 is used to select grammar files.

libDirectory
  Specify location of imported grammars and tokens files.

listener
  Generate parse tree listener interface and base class.

options
  A list of grammar options to explicitly specify to the tool. These options
  are passed to the tool using the -D<option>=<value> syntax.

outputDirectory
  Specify output directory where the Java files are generated.

sourceDirectory
  The directory where the ANTLR grammar files (*.g4) are located.

treatWarningsAsErrors
  Treat warnings as errors.

visitor
  Generate parse tree visitor interface and base class.

antlr4:help
Display help information on antlr4-maven-plugin.
Call mvn antlr4:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.

Available parameters:

detail
  If true, display all settable properties for each goal.

goal
  The name of the goal for which to show help. If unspecified, all goals
  will be displayed.

indentSize
  The number of spaces per indentation level, should be positive.

lineLength
  The maximum length of a display line, should be positive.


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.635s
[INFO] Finished at: Wed Jul 03 14:52:12 EDT 2013
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
Westerfield answered 3/7, 2013 at 19:31 Comment(2)
You're just showing output, I'm not sure I'd call that an answer.Bagwell
+1 for including the fully qualified command that is required if you haven't yet downloaded the antlr4 artifacts.Neilneila
M
7

Here are two links to help right now:

We're working to get the Maven site documentation hosted online.


I place my grammars in the same folders as the Java files (in the package where I want the generated code to appear).

Since I declare my source directory at the top level like this:

<build>
  <sourceDirectory>src</sourceDirectory>
</build>

I would use the following configuration for the ANTLR 4 Maven plugin:

<plugin>
    <groupId>org.antlr</groupId>
    <artifactId>antlr4-maven-plugin</artifactId>
    <version>4.0</version>
    <configuration>
        <sourceDirectory>${basedir}/src</sourceDirectory>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>antlr4</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Miniskirt answered 8/7, 2013 at 10:8 Comment(0)
A
6

The antlr4-maven-plugin has a help goal which can be executed, using maven, like this:

mvn antlr4:help -Ddetail=true
Avalos answered 10/3, 2013 at 16:52 Comment(1)
Note that this will only work if you have already downloaded the appropriate artifacts. @TomEE's answer will work the first time and then either will work on subsequent calls.Neilneila
N
1

Help is limited, but (in addition to the other answers to this questions) I found the following places useful:

Neilneila answered 14/1, 2014 at 16:40 Comment(0)
W
0

Looks like the maven plugin site is now published:

http://www.antlr.org/api/maven-plugin/latest/index.html

Wrier answered 31/5, 2014 at 16:58 Comment(0)
M
0

You can also check out the following blog which describes both plugins for generating and testing ANTLR 4 grammars.

Mcgann answered 16/3, 2015 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.