jbosstools / m2e-apt

Maven integration with Eclipse JDT Annotation Processor Toolkit
39 stars 19 forks source link

After a maven refresh annotation processors cannot find resources #72

Open agentgt opened 5 years ago

agentgt commented 5 years ago

After a maven refresh annotation processors cannot find resources in the classpath (ie files in src/main/resources). Eclipse 4.12 and m2e-apt 1.5.2

This might be related to:

https://github.com/jbosstools/m2e-apt/issues/67

The original bug is here:

https://github.com/domaframework/doma/issues/319

Basically if I touch a file (ie edit it) that is processed by the annotation processor than the annotation processor is able to find the resources in src/main/resources (its in the classpath).

However if I do a Maven refresh configuration ("Alt-F5" = Maven -> Update Project) than the processor cannot find resources (classpath) in src/main/resources.

I presume this is something to do with what #67 was talking about with inconsistencies with incremental and full builds.

agentgt commented 5 years ago

I also tested with and without the maven-processor-plugin version 3.3.3

EDIT ... sorry it does work for the maven-processor-plugin if you delegate to in the project configuration as per the README but the error messages for the annotations then happen on the POM instead of the Java file (Eclipse UI).

I can't decide which behavior is better. False errors on Java files or positive hard to read errors on the POM file.

agentgt commented 5 years ago

For other that may have this problem:

The best work around I have found is to turn on default m2e-apt and then have Maven copy the resources:

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/generated-sources/annotations</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/src/main/resources</directory>
                  <includes>
                    <include>META-INF/**/*.sql</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

I'm not entirely sure how the above works. I know its copying the resources and I know the m2e plugin will do that but I'm not sure if it invalidates some things for incremental build or the above always causes a full build.

mickaelistria commented 2 years ago

m2e-apt's code is now included in https://github.com/eclipse-m2e/m2e-core , please consider reporting issue to https://github.com/eclipse-m2e/m2e-core/issues if it's still relevant.