querydsl / apt-maven-plugin

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

Usage question - automatically add target/generated-sources/java folder #50

Closed paulvi closed 8 years ago

paulvi commented 8 years ago

I have followed https://github.com/querydsl/apt-maven-plugin/wiki/m2e-usage mvn package build passed, with sources generated

but I have to manually add classpathentry in Eclipse

<classpathentry kind="src" path="target/generated-sources/java"/>

Should this target/generated-sources/java folder automatically be added in Eclipse on import?

I guess some extra pom.xml configuration is needed.

Shredder121 commented 8 years ago

It's been a while since I used Eclipse, but doesn't the Maven Eclipse plugin solve that? mvn eclipse:eclipse?

paulvi commented 8 years ago

mvn eclipse:eclipse does not generate correct eclipse files for current m2e plugin.

Usage of mvn eclipse:eclipse has been discouraged for several years now.

I think it is similar to gradle build eclipse generate Eclipse files as general project, that may be OK for a look but not for work. Anyways, I feel there should be extra things in pom.xml like maven-helper-plugin

paulvi commented 8 years ago

from http://stackoverflow.com/questions/7160006/m2e-and-having-maven-generated-source-folders-as-eclipse-source-folders

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>${project.build.directory}/generated-sources/java/</source>
                </sources>
            </configuration>
        </execution>
    </executions>
 </plugin>
paulvi commented 8 years ago

It works.

Wiki updated https://github.com/querydsl/apt-maven-plugin/wiki/m2e-usage

Shredder121 commented 8 years ago

Thanks for verifying that and writing about it, much appreciated.