Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPA Streamer not working with MapStruct #165

Closed
subhrajlahiri opened this issue Aug 7, 2021 · 1 comment
Closed

JPA Streamer not working with MapStruct #165

subhrajlahiri opened this issue Aug 7, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@subhrajlahiri
Copy link

subhrajlahiri commented Aug 7, 2021

I am facing the same issue. The metamodels for JPAStreamers are not generating when using in the same projects as that with MapStruct. When tried on a separate project. That worked fine.

Providing the pom.xml I am using

<?xml version="1.0" encoding="UTF-8"?>
<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>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.8</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.test</groupId>
	<artifactId>test-app</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>test app</name>
	<description>test app</description>
	<properties>
		<spring.profiles.active>no_profile_selected_error</spring.profiles.active>
		<java.version>11</java.version>
		<firebase.version>7.1.0</firebase.version>
		<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
		<projectlombok.version>1.18.20</projectlombok.version>
		<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.firebase</groupId>
			<artifactId>firebase-admin</artifactId>
			<version>${firebase.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mapstruct</groupId>
			<artifactId>mapstruct</artifactId>
			<version>${org.mapstruct.version}</version>
			<optional>true</optional>
		</dependency>
		<dependency>
            <groupId>com.speedment.jpastreamer</groupId>
            <artifactId>jpastreamer-core</artifactId>
            <version>1.0.2</version>
        </dependency>
        <dependency>
            <groupId>com.speedment.jpastreamer.integration.spring</groupId>
            <artifactId>spring-boot-jpastreamer-autoconfigure</artifactId>
            <version>1.0.2</version>
        </dependency>
	</dependencies>
	<build>
		<finalName>${project.artifactId}-${spring.profiles.active}-${project.version}</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>${project.parent.version}</version>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
				<configuration>
					<source>11</source> <!-- depending on your project -->
					<target>11</target> <!-- depending on your project -->
					<annotationProcessorPaths>
						<path>
							<groupId>org.mapstruct</groupId>
							<artifactId>mapstruct-processor</artifactId>
							<version>${org.mapstruct.version}</version>
						</path>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok-mapstruct-binding</artifactId>
							<version>${lombok-mapstruct-binding.version}</version>
						</path>
						<path>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
							<version>${projectlombok.version}</version>
						</path>
						<!-- other annotation processors -->
					</annotationProcessorPaths>
				</configuration>
			</plugin>
			<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>
                                    ${project.build.directory}/generated-sources/jpa-streamer
                                </source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
		</plugins>
	</build>
</project>

@minborg minborg added the bug Something isn't working label Aug 8, 2021
@julgus
Copy link
Member

julgus commented Jun 5, 2023

It seems to me like the issue is that you are pointing specifically at the Lombok and MapStruct annotation processors, but not at the JPAStreamer one, and thus it is omitted.

I came to this conclusion after conducting the following experiment:

1. Using JPAStreamer and Spring Boot only. Bare bones configuration of the Maven Compiler Plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <proc>only</proc> // Using process only to only run the annotation processors with the command mvn compile
        <source>17</source>
        <target>17</target>
    </configuration>
</plugin>

Result: mvn compile generates the JPAStreamer metamodel.

2. Using Spring Boot, JPAStreamer, Lombok, and MapStruct - copying your provided Maven Compiler Config.

Result: mvn compile fails to generate the JPAStreamer metamodel.

3. Adding the path to the JPAStreamer field generator as well under <annotationProcessorPaths>:

<annotationProcessorPaths>
    ...
    <path>
        <groupId>com.speedment.jpastreamer</groupId>
        <artifactId>jpastreamer-core</artifactId>
        <version>3.0.1</version>
    <path>
    ...
</annotationProcessorPaths>

Result: mvn compile generates the JPAStreamer metamodel.

I'll be closing this issue with the conclusion that there is nothing inherently problematic with MapStruct in combination with JPAStreamer. Please reopen if you disagree.

@julgus julgus closed this as completed Jun 5, 2023
@julgus julgus self-assigned this Jun 5, 2023
@julgus julgus added this to the 3.0.2 milestone Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants