Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] m2e, code generation and the Eclipse project builders order

I am using m2e managed projects with the maven antlr3 plugin. I have also the Antlr3 configurator installed to manage lifecycle mappings.
As the Antlr3 plugin generates source code for parsers, I plug its main goal 'antlr' to the 'generate-sources' phase :

My problem is that when I launch a project build from the Eclipse IDE, the java builder is applied first and then the maven builder, by default. Thus compilation occurs
before code generation, which is managed by maven.
This cause my test classes, which have dependencies upon generated lexer and parser not to compile :

public class Test {
    public static void main(String[] args) throws Exception {
        TLexer lexer = new TLexer(input); -> error
        TParser parser = new TParser(tokens); -> error

I have to build the project a second time to have the errors removed. As a workaround, I can modify the builder order in the project's properties screen  using UP or DOWN buttons.
But every time I change my pom.xml and fire an 'Update Project Configuration...', the .project file, which stores the used builders and their application order is reset to defaults.
Googling a little bit, I found this link, indicating that it's the intended behavior in order to solve a resource clean issue when the builder order is changed.
I tried to issue a clean within Eclipse Indigo using 'Project -> Clean...' menu, and seems to work (resources and classes are effectively deleted), even if maven builder is set in first position.

Is it really necessary the reset the builder's order after an 'Update Project Configuration...' ?
Is there another way to force m2e and maven launch code generation before compilation using Eclipse tooling and not the mvn command  ?
Thanks for any answer or hint.

Back to the top