Closed lrozenblyum closed 2 years ago
It's obviously caused by Eclipse now requiring Java 11 to run, which no longer includes the javax.xml.bind module. Does it build in command line when compiling with a JDK 11? You can you try adding
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
next to the hibernate modelgen dependency.
@fbricon 1) initially compilation in command line fails under JDK11. 2) compilation in command line with the dependency jakarta.xml.bind successfully generates target\generated-sources\annotations 3) Eclipse compilation still does nothing (even with the dependency above)
More details on the environment: The project itself is JDK8 based and uses it in Eclipse for compilation. Eclipse 2020-09 itself is indeed running under JDK11.
please provide an example project that succeed in CLI, but fails in Eclipse.
@fbricon here it is: https://github.com/lrozenblyum/m2e-apt-eclipse-2020-09-bug
Everything works with this pom.xml:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.leokom</groupId>
<artifactId>m2e-apt-eclipse-2020-09-bug</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<hibernate-c3p0.version>5.2.6.Final</hibernate-c3p0.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.8</java-version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate-c3p0.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate-c3p0.version}</version>
</path>
<path>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</path>
<path>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Eclipse specific: activate automatically when m2e plugin is installed -->
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<!-- Set "Maven Integration for Eclipse JDT APT" plugin option automatically
run annotation processors within the incremental compilation -->
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
</properties>
</profile>
</profiles>
</project>
Thank you @fbricon! Maybe it's a nice idea to extend some part of m2e-apt documentation to mention this code that helps resolving running under Eclipse 2020-09 (it's unexpected that IDE JDK11 affects the application code running under JDK8).
@lrozenblyum feel free to open a PR to improve the documentation. Else I'll come back to it later (no ETA)
@fbricon done, please check the pull request, remarks are welcome
The m2e-apt 1.5.2 doesn't work in Eclipse 2020-09
The code that depends on annotation processing which could compile in 2020-03, stops compiling in 2020-09.
Not sure if that's related to the problem, but Eclipse log contains the exceptions