Claudio Weiler
Claudio Weiler

Reputation: 669

Generating JPA metamodel with Jakarta stack in Eclipse

We have some Maven projects based on Java EE 8 stack building successfully on Eclipse.

JPA metamodel are automatically generated with incremental build. Our setup uses eclipselink-maven-plugin version 2.7.5.1 (last version tested, previous also work), and Eclipse is version 2022-06, with Java 11.

Here the configuration snippet :

<plugin>
    <groupId>com.ethlo.persistence.tools</groupId>
    <artifactId>eclipselink-maven-plugin</artifactId>
    <configuration>
        <generatedSourcesDirectory>${project.basedir}/src/main/jpa-metamodel</generatedSourcesDirectory>
    </configuration>
    <executions>
        <execution>
            <id>generate-jpa-metamodels</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>modelgen</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<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.basedir}/src/main/jpa-metamodel</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Nothing special, but this correctly configures Eclipse to incremental build metamodel and recognize new source folder.

Ok. Now, to upgrade to Jakarta EE 10, eclipselink-maven-plugin plugin needed to be upgraded to 3.0.2 and it broke project update as also "Run As > Maven goal". Eclipse upgraded to 2023-09 with Java 21. Problem is that it can't override metamodel artifacts anymore:

Hibernate JPA 2 Static-Metamodel Generator 6.2.0.CR4
Problem with Filer: Attempt to recreate a file for type ...

Note that this breaks context menu action "Run As > Maven goal" (e.g. Maven test), but a custom run configuration with goals: "clean test" works if configuration source is mapped to target folder.

I found this discussion that says that is an expected behavior, but can't find what changed on eclipselink-maven-plugin that could cause this breaking change.

Do you have any tip, fix or workaround?

Thanks!


Edit

Minimal reproducible example: https://github.com/claudioweiler/jpametamodelfail-mre

References:

Upvotes: 0

Views: 53

Answers (0)

Related Questions