Open rdicroce opened 6 years ago
In the case of JDT APT, the bug would most likely be upstream (in JDT). Can you de-mavenize the project, make it a pure Eclipse project and reproduce the issue? If yes, then a bug should be opened upstream.
Yes, it is also broken without Maven. Some searching uncovered Eclipse bug 447546, which has been open for 4 years with no progress.
What about the Experimental delegate mode? I assume that is still a bug in m2e-apt.
maven_execution mode only works for the maven-processor-plugin (I reckon it's not very clear from the readme) This seems to work:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lapis.throwaway</groupId>
<artifactId>querydsl-delegate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<m2e.apt.activation>maven_execution</m2e.apt.activation>
<version.com.mysema.querydsl>4.2.1</version.com.mysema.querydsl>
</properties>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${version.com.mysema.querydsl}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${version.com.mysema.querydsl}</version>
<classifier>jpa</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>8</source>
<target>8</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
That does not work for me. I end up with an empty target/generated-sources/apt.
In tinkering with this, I noticed that changing the configuration away from JDT APT doesn't seem to update the project settings in Java Compiler -> Annotation Processing, so at first I was still seeing the result of that doing its thing. Possibly you may be seeing the same thing. Try deleting the project from the workspace, clearing out all of the Eclipse metadata, then re-importing the project.
Well actually, the problem is, maven_execution mode doesn't deactivate JDT APT settings automatically, and that's probably a bug. The problem is, when jdt_apt is disabled, we don't want to disable APT if it was set manually by the user.
Anyways. Importing the project from a clean slate works for me, with <m2e.apt.activation>maven_execution</m2e.apt.activation>
mmm actually switching <m2e.apt.activation>jdt_apt</m2e.apt.activation>
to <m2e.apt.activation>maven_execution</m2e.apt.activation>
back and forth, after update project config, properly disables jdt apt settings in the Annotation Processing properties page
I still have not gotten it to work. What version of Eclipse are you testing with? I'm on Photon Release (4.8.0).
That shouldn't matter, but I'm on 2018-09 (released today) with m2e-apt 1.5.0.201805160042 (installed from http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt/)
Tried 2018-09. Still doesn't work. The files get generated if I execute a Maven build manually, but that's it. A full build (Project -> Clean) does nothing. An incremental build triggered by changing a file also does nothing. To be clear, "does nothing" means it does not remove files that were previously generated. Are you sure the files you're seeing are actually getting regenerated and are not just leftovers from an earlier build?
See https://www.youtube.com/watch?v=XgxpjGkNqS4
Eclipse runs with JDK 1.8, if it makes a difference
I don't expect deleting files will delete generated files in maven_execution mode. We simple ask java to run the annotation processor, without cleaning anything
Finally figured this out after I happened to open the Error Log and noticed an error complaining that
JVM is not suitable for processing annotation! ToolProvider.getSystemJavaCompiler() is null.
Basically, delegate mode only works if the JRE that is executing Eclipse is a JDK. I don't suppose there's some way to get delegate mode to use the JDK that Eclipse is configured to build with instead? Trying to get tools.jar on the classpath via a system-scoped Maven dependency didn't help either.
After digging through the maven-processor-plugin code, it looks like it should be possible to tell it where to find javac by using maven-toolchains-plugin. Unfortunately that doesn't work either because m2e isn't configuring Maven correctly, so maven-toolchains-plugin can't find toolchains.xml. See Eclipse bugs 521280 and 527398.
Ok, I'm stretched pretty thin already so I don't think I'll be able to fix the m2e part any time soon. If you want to provide a quality patch to fix this, then please do :-)
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.
I have a project that uses QueryDSL. I'm trying to use QueryDelegate to extend the generated code for OffsetDateTime. m2e-apt produces different results depending on whether Eclipse is executing a full build or an incremental build. A reproducer is attached below.
On a full build (e.g. using Project -> Clean), I get the expected result: QSomeEntity has a field odt with type QOffsetDateTime. But on an incremental build, the field has type DateTimePath, as if my QueryDelegate doesn't exist.
This is true for both JDT APT and Experimental delegate processing modes.
m2e-apt.zip