java - How to import grammar in Antlr4 to build with maven -


i'm trying build antlr project maven, project structure like

src/main +       |-antlr4              |-fo/bar                    |-g1.g4                    |-g2.g4              |-imports 

in g1 imports g2 like:

grammar g1; import g2; 

however, when compile maven, got following error:

[error] message{errortype=cannot_find_imported_grammar, args=[g2, fo\bar\g1.g4], e=null, filename='null', line=-1, charposition=-1} 

it works no problem if put g1.g4 , g2.g4 directly under antlr4 directory. looks me when put grammer files in package need special syntax reference in import statement?

i notice issue: antlr4 maven plugin cannot find grammar files in different directories

but here, grammars in 1 directory.

i think need g2.g4 grammar in imports package (src/main/antlr4/imports). have duplicated grammar. avoid this, change import setting of antlr plugin this:

<build>   <plugins>     <plugin>       <groupid>org.antlr</groupid>       <artifactid>antlr4-maven-plugin</artifactid>       <version>4.1</version>       <configuration>         <libdirectory>${basedir}/src/main/antlr4/fo/bar</libdirectory>       </configuration>       <executions>         <execution>           <goals>             <goal>antlr4</goal>           </goals>         </execution>       </executions>     </plugin>   </plugins> </build> 

note configuration libdirectory.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -