Search code examples
javamavengwtp

maven processor plugin order of generated sources in a gwtp app


I'm using maven processor plugin to generate sources.

        <!-- Run annotation processors on src/home/java sources -->
        <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>2.2.4</version>
            <executions>
                <execution>
                    <id>process</id>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.gwtplatform</groupId>
                    <artifactId>gwtp-processors</artifactId>
                    <version>${gwtp.version}</version>
                </dependency>
            </dependencies>
        </plugin>

The problem is that I have generated classes that are dependent on these generated classes.

E.g.

com.project.client.application.event.DevInfoEvent.java has a classmember of DevInfoDto com.project.shared.dto.generated.dev.DevInfoDto.java

Both files are generated, but the problem is the DevInfoEvent is generated sooner, therefore I got an error that it can't resolve the DevInfoDto

When I run the generate-sources from eclipse for the second time, it is ok, because the DevInfoDto is already generated. But this behavior is not good me. (Don't want to run compile on the CI server twice).

Is there a way to tell maven processor plugin some order, in which it should generate classes?


Solution

  • I'd make com.project.client and com.project.shared two different Maven projects, declare shared as a dependency of client and aggregate them as <module>s in a parent project. Such, when building this parent project, Maven's reactor takes care of the proper build order.

    This also makes sense in another way: shared functionality is probably different to client functionality.