3
votes

I was trying to build ANTLR version 4 from source, as I downloaded it from the official website, but I cannot do it using ant. I downloaded the antlr-3.5-complete-no-st3.jar to the /lib folder as build.xml says, but when I run ant it returns:

[mkdir] Created dir: /../antlr/antlr4-master/build/generated-sources/antlr3/org/antlr/v4/parse [java] error(7): cannot find or open file: *.g

BUILD FAILED /../antlr/antlr4-master/build.xml:108: The following error occurred while executing this line: /../antlr/antlr4-master/build.xml:84: Java returned: 1

I am on a MacBook running OSX 10.8.2 Is there anything else I have to do in order to have a successful compilation using ant?

Thanks in advance, Dimos

2

2 Answers

1
votes

You need to use Maven to build ANTLR 4 from source.

Building ANTLR 4 with Maven

0
votes

Above "Building ANTLR 4 with Maven" link seems not available. Please follow the below links for ANTLR 4 maven build. These helped me to achieve antlr 4 maven build.

https://groups.google.com/forum/#!msg/antlr-discussion/Vw4Ia__sgPk/nDS5Y9YSDGIJ

How do I get help on the antlr4-maven-plugin

My ANTLR-Maven Plugin is as below:-

<build>
    <plugins>
        <plugin>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-maven-plugin</artifactId>
            <version>4.0</version>
            <configuration>
                <sourceDirectory>${basedir}/src/main/java/com/test</sourceDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>antlr4</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>

    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.antlr</groupId>
                                    <artifactId>
                                        antlr4-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [4.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>antlr4</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>
    <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-maven-plugin</artifactId>
        <version>4.2.2</version>
    </dependency>
</dependencies>