Antlr Project的Maven执行失败

时间:2016-03-13 23:12:56

标签: maven antlr4

我正在尝试使用Maven插件指令在Eclipse(Mars)中创建一个Antlr4(4.5)项目: http://www.antlr.org/api/maven-plugin/latest/plugin-info.html

我收到此错误:

Execution antlr of goal org.antlr:antlr4-maven-plugin:4.5:antlr4 failed. (org.antlr:antlr4-maven-plugin:
 4.5:antlr4:antlr:generate-sources) org.apache.maven.plugin.PluginExecutionException: Execution antlr of goal 
 org.antlr:antlr4-maven-plugin:4.5:antlr4 failed. at 
 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at 
 org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331) at 
 org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362) at 
 org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1) at 
 org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
 at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) at 
 org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360) at 
 org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:
 52) at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115) at 
 org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
 at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105) at 
 org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
 at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) at 
 org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86) at 
 org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200) at 
 org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734) at 
 org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245) at 
 org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300) at 
 org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
 org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303) at 
 org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359) at 
 org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382) at 
 org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144) at 
 org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at 
 org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Caused by: java.lang.NullPointerException at 
 org.antlr.v4.automata.ParserATNFactory.elemList(ParserATNFactory.java:486) at 
 org.antlr.v4.automata.ParserATNFactory.alt(ParserATNFactory.java:473) at 
 org.antlr.v4.parse.ATNBuilder.alternative(ATNBuilder.java:557) at 
 org.antlr.v4.parse.ATNBuilder.ruleBlock(ATNBuilder.java:291) at 
 org.antlr.v4.automata.ParserATNFactory._createATN(ParserATNFactory.java:184) at 
 org.antlr.v4.automata.LexerATNFactory.createATN(LexerATNFactory.java:137) at 
 org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:414) at org.antlr.v4.Tool.process(Tool.java:387) at 
 org.antlr.mojo.antlr4.Antlr4Mojo$CustomTool.process(Antlr4Mojo.java:474) at 
 org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:346) at 
 org.antlr.mojo.antlr4.Antlr4Mojo.execute(Antlr4Mojo.java:279) at 
 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 31 
 more

在这个pom.xml文件中:

<project xmlns="http://maven.apache.org/POM/4.0.0"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.mycompany.myproj.theProj</groupId>
  <artifactId>Proj3000</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Project 3000</name>
  <build>
    <plugins>
      <plugin>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-maven-plugin</artifactId>
        <version>4.5</version>
        <executions>
          <execution>     <!-- error happens on this line -->
            <id>antlr</id>
            <goals>
              <goal>antlr4</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

我手动将插件添加到pom.xml文件中。我将版本发送到4.5,因为说明说他们使用antlr4版本与maven插件版本保持同步。

[使用命令行运行结果编辑]

我从命令行运行,如下所示:mvn clean install

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution antlr of goal org.antlr:antlr4-maven-plugin:4.5:antlr4 failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.NullPointerException
at org.antlr.v4.automata.ParserATNFactory.elemList(ParserATNFactory.java:486)
at org.antlr.v4.automata.ParserATNFactory.alt(ParserATNFactory.java:473)
at org.antlr.v4.parse.ATNBuilder.alternative(ATNBuilder.java:557)
at org.antlr.v4.parse.ATNBuilder.ruleBlock(ATNBuilder.java:291)
at org.antlr.v4.automata.ParserATNFactory._createATN(ParserATNFactory.java:184)
at org.antlr.v4.automata.LexerATNFactory.createATN(LexerATNFactory.java:137)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:414)
at org.antlr.v4.Tool.process(Tool.java:387)
at org.antlr.mojo.antlr4.Antlr4Mojo$CustomTool.process(Antlr4Mojo.java:474)
at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:346)
at org.antlr.mojo.antlr4.Antlr4Mojo.execute(Antlr4Mojo.java:279)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134

我该如何纠正?

0 个答案:

没有答案