构建 ANTLR4 源代码以获取源代码 jar
Building ANTLR4 source to get source jar
我可以从下载页面 (http://www.antlr.org/download.html) 下载最新的 ANTLR4 (antlr-4.5.3-complete.jar)。
把jar文件放到IntelliJ工程的lib目录下,把jar做成依赖,看看一切正常。
我正在尝试通过使用调试器进行跟踪来查看 ANTLR 的源代码,但我做不到,因为我没有源代码 jar。
我找到了源代码,以及构建 ANTLR 的说明(
How to build ANTLR itself)。但是,该指令使用的 bild.py
未包含在源代码中。
我从 Sam Hawell 的 tunnelvisionlabs/antlr4 中找到了 bild.py,但是当我复制脚本并 运行 它时,出现错误:
target all
require compile
require parsers
build compile
skipping mkjar_complete
Traceback (most recent call last):
File "/Users/smcho/Downloads/antlr4-4.5.3/bilder.py", line 847, in processargs
target()
File "bild.py", line 182, in all
mkjar()
File "bild.py", line 133, in mkjar
mkjar_complete()
File "bild.py", line 80, in mkjar_complete
require(compile)
File "/Users/smcho/Downloads/antlr4-4.5.3/bilder.py", line 434, in require
raise Exception()
Exception
bild failed
可能出了什么问题?如何构建 ANTLR4 以获取源 jar 文件?
maven
是构建 jar 文件的工具,如本文档所述:https://github.com/antlr/antlr4/blob/master/doc/building-antlr.md
mvn compile
完成编译。
要获取源 jar 文件,pom.xml 应该更新。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
然后 mvn package
将在 tool/target
目录中制作源 jar。
对于运行时jar,目标目录是runtime/Java/target
。
mvn install
会将 jars 安装到本地存储库中。
参考资料
如果你想获取源代码 (and/or javadoc),你应该简单地使用 ivy。你也可以像你写的那样使用 maven,但 ivy 更简单恕我直言。 http://mvnrepository.com/artifact/org.antlr/antlr4/4.5.3
我可以从下载页面 (http://www.antlr.org/download.html) 下载最新的 ANTLR4 (antlr-4.5.3-complete.jar)。
把jar文件放到IntelliJ工程的lib目录下,把jar做成依赖,看看一切正常。
我正在尝试通过使用调试器进行跟踪来查看 ANTLR 的源代码,但我做不到,因为我没有源代码 jar。
我找到了源代码,以及构建 ANTLR 的说明(
How to build ANTLR itself)。但是,该指令使用的 bild.py
未包含在源代码中。
我从 Sam Hawell 的 tunnelvisionlabs/antlr4 中找到了 bild.py,但是当我复制脚本并 运行 它时,出现错误:
target all
require compile
require parsers
build compile
skipping mkjar_complete
Traceback (most recent call last):
File "/Users/smcho/Downloads/antlr4-4.5.3/bilder.py", line 847, in processargs
target()
File "bild.py", line 182, in all
mkjar()
File "bild.py", line 133, in mkjar
mkjar_complete()
File "bild.py", line 80, in mkjar_complete
require(compile)
File "/Users/smcho/Downloads/antlr4-4.5.3/bilder.py", line 434, in require
raise Exception()
Exception
bild failed
可能出了什么问题?如何构建 ANTLR4 以获取源 jar 文件?
maven
是构建 jar 文件的工具,如本文档所述:https://github.com/antlr/antlr4/blob/master/doc/building-antlr.md
mvn compile
完成编译。
要获取源 jar 文件,pom.xml 应该更新。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
然后 mvn package
将在 tool/target
目录中制作源 jar。
对于运行时jar,目标目录是runtime/Java/target
。
mvn install
会将 jars 安装到本地存储库中。
参考资料
如果你想获取源代码 (and/or javadoc),你应该简单地使用 ivy。你也可以像你写的那样使用 maven,但 ivy 更简单恕我直言。 http://mvnrepository.com/artifact/org.antlr/antlr4/4.5.3