prosseek
prosseek

Reputation: 190809

Building ANTLR4 source to get source jar

I could download the newest ANTLR4 (antlr-4.5.3-complete.jar) from the download page (http://www.antlr.org/download.html).

Putting the jar file in the lib directory of IntelliJ project to make the jar as a dependency to see everything works fine.

I'm trying to look into the ANTLR's source code by tracing with debugger, but I can't as I don't have the source jar.

I found the source code, and an instruction to build ANTLR ( How to build ANTLR itself). However, the instruction uses bild.py that is not included in the source.

I found the bild.py from Sam Hawell's tunnelvisionlabs/antlr4, but when I copy the script and run it, I got errors:

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

What might be wrong? How to build ANTLR4 to get source jar file?

Upvotes: 2

Views: 755

Answers (2)

cantSleepNow
cantSleepNow

Reputation: 10192

If you want to get source (and/or javadoc), you should simply use ivy. You could also use maven as you wrote, but ivy is simpler IMHO. http://mvnrepository.com/artifact/org.antlr/antlr4/4.5.3

Upvotes: 1

prosseek
prosseek

Reputation: 190809

maven is the tool to build the jar files as is described in this document: https://github.com/antlr/antlr4/blob/master/doc/building-antlr.md

mvn compile gets the compilation done.

For getting the source jar file, pom.xml should be updated.

<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>

Then mvn package will make the source jar in tool/target directory.

enter image description here

For the runtime jar, the target directory is runtime/Java/target.

enter image description here

mvn install will install the jars into local repository.

References

Upvotes: 1

Related Questions