I'm using Netbeans 7.1.1 with a Maven project with the ANTLR Maven Plugin to generate a Lexer+Parser Java class - this works.
What I'm struggling to work out:
How can I build a test rig within the same project, such that the Lexer and Parser Class are found at development-time ?
Is there a Maven-way of specifying : build the 'generated source' stuff first (ie, Antlr-generated) THEN my 'manual' source?
Should I build a secondary Maven Project, which relies on the first project ?
Is there is a 'generic' (dynamic?) mechanism for building an ANTLR test rig class that doesn't really on Parser/Lexer class already existing ? (a 'ClassForName' JDBC-Style mechanism ?)
To Clarify the issue; here's a snippet of my Test Rig class, which is uncompilable (due to the Lexer / Parsers not having been built yet....):
...
myLexer lexer = new myLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
myParser parser = new myParser(tokens);
parser.file();
...
OK - after the advice below and double-checking the generated java - in fact I hadn't noticed that my Grammar file (although laid out in java package structure) did not contain a @header directive to specify a target java project for the generated classes to live in.
This was the reason that my test (or indeed my main program) was unable to see the Lexer/Parser classes. (I was simply trying to access java classes which were in a different package structure to what I had thought).
This other StackOverFlow case was the final clincher for me: