querydsl / apt-maven-plugin

Maven APT plugin
Apache License 2.0
79 stars 41 forks source link

Cannot use mysema maven-apt-plugin in an Eclipse Roo project #13

Closed benze closed 11 years ago

benze commented 11 years ago

I've tried creating a basic ROO project in eclipse and added the required QueryDSL dependencies/plugins to my pom.xml. However, no classes are generated in the target folder by the plugin.

I am using Eclipse 3.7, m2e 1.2, Java 6. I also have the mysema m2e plugin installed from http://ilx.github.com/m2e-querydsl/repository/0.0.5/.

These are my additions to a base roo project pom.xml. QueryDSL version is specified as 2.7.3

    <!-- Querydsl -->
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-core</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>${querydsl.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>${querydsl.version}</version>
    </dependency>

        <plugin>
            <!-- Requires mysema m2e plugin (http://ilx.github.com/m2e-querydsl/repository/0.0.5/) -->
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <logOnlyOnError>true</logOnlyOnError>
                        <outputDirectory>target/generated-sources/apt</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>${querydsl.version}</version>
                </dependency>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-jpa</artifactId>
                    <classifier>apt</classifier>
                    <version>${querydsl.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <!-- right now this seems needed -->

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>target/generated-sources/apt</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

There are no pom errors or warnings.

Thanks,

Eric

timowest commented 11 years ago

Do you have javax.persistence.Entity annotated sources or some Roo specific annotations instead? The configuration looks ok.

benze commented 11 years ago

I've tried it with both. I've tried with a Roo annotated entity (ie: @RooJpaEntity), a Roo annotated entity but with a @Entity declaration in the class itself (not in the Roo ITD) and neither worked. I've also tried it with a non-Roo Entity class (ie: a regulary entity class with @Entity and no Roo annotations) but the auto generation just does not seem to trigger. Even if I do a clean on the project, when it rebuilds it, the mysema-apt plugin does not seem to launch (no classes are generated).

I am guessing that there is probably a conflict with another dependency/plugin, but I just haven't been able to find it. I've tried taking a functional pom.xml (without Roo) and add in the Roo dependencies (to try to limit the number of changes and help me pinpoint where the conflict occurs), but when I tried that, I ended up with other eclipse/maven errors (ie: Maven Error - cannot read project description, etc), and cannot update the maven configuration. So I have had to create a Roo project from scratch (ie: new roo project wizard) and add the above snippets to the pom. I then copied the entity classes from the non-Roo project to the Roo project and the metadata classes that were generated in the functional project are no longer generated in Eclipse.

Of course, i can always do a maven generate-sources to produce the necessary metadata classes, but it would be nice to have the plugin auto-generate for me as it does in a non-roo project.

Thanks!

Eric

timowest commented 11 years ago

Could you provide a minimal example project that fails? One Entity annotated class is enough.

benze commented 11 years ago

Sure. But I'm not quite sure how to attach/upload content to this issue. Is there a way I can zip up an example and attach it?

timowest commented 11 years ago

You can e.g. send it to me directly or create a GitHub project for it.

timowest commented 11 years ago

I guess this can be closed now?