Ali İhsan TAŞDELEN
Ali İhsan TAŞDELEN

Reputation: 21

How to add Map Struct Processor without remove other processor paths?

I want to use Map Struct in my project but when I implement it in maven-compiler-plugin other all annotationProcessorPaths removed from project (most important one is Lombok). But after hours and hours of researching I cannot find how to add processor without use

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <annotationProcessorPaths>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${org.mapstruct.version}</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.36</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-mapstruct-binding</artifactId>
                <version>0.2.0</version>
            </path>
        </annotationProcessorPaths>
        <compilerArgs>
            <compilerArg>
                -Amapstruct.defaultComponentModel=spring
            </compilerArg>
        </compilerArgs>
    </configuration>
</plugin>

Okay I added lombok there but now Hikari CP throw problems and I think if I solve the Hikari's problems other techs will be problem again and I don't want to always patch my project. How can I use processor without use ?

Thank you for reading <3

-- UPDATE --

I tried code like,

<dependencies>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
        <version>${org.mapstruct.version}</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok-mapstruct-binding</artifactId>
        <version>0.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct-processor</artifactId>
        <version>${org.mapstruct.version}</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <compilerArgs>
            <arg>-proc:full</arg>
            <compilerArg>
                -Amapstruct.defaultComponentModel=spring
            </compilerArg>
        </compilerArgs>
    </configuration>
</plugin>

And it couldn't solve, we try add processors without use . I use Java 23.

Upvotes: 0

Views: 45

Answers (1)

Slawomir Jaranowski
Slawomir Jaranowski

Reputation: 8517

Without adding a annotationProcessorPaths to maven-compiler-path all annotation processors available on project class path will be used.

So you need add them to your project dependencies - can be in provided scope if only contains annotation processor - like mapstruct-processor.

But with newer JDK you must provide list of annotation processors or use a parameter: -proc:full

https://inside.java/2023/10/23/quality-heads-up/

https://inside.java/2024/06/18/quality-heads-up/

Upvotes: 2

Related Questions