Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

After a maven refresh annotation processors cannot find resources #72

Open
agentgt opened this issue Aug 9, 2019 · 3 comments
Open

Comments

@agentgt
Copy link

agentgt commented Aug 9, 2019

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:

#67

The original bug is here:

domaframework/doma#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
Copy link
Author

agentgt commented Aug 9, 2019

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
Copy link
Author

agentgt commented Aug 9, 2019

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
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants