Search code examples
javaspringmavenmapstruct

Mappping Processor as plugin in spring maven project


I develop a project which uses lombok and mapstruct libraries. I have the following maven structure:

        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.3.6</version>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>1.3.1.Final</version>
        </dependency>
...

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
            <annotationProcessorPaths>
                <path>
                    <groupId>org.mapstruct</groupId>
                    <artifactId>mapstruct-processor</artifactId>
                    <version>1.3.1.Final</version>
                </path>
                <path>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok</artifactId>
                    <version>1.18.8</version>
                </path>
            </annotationProcessorPaths>
        </configuration>
    </plugin>

So far I have not any problems with running up application. Today I recevied the follwing error during compilation.

java: Internal error in the mapping processor: java.lang.NullPointerException   at org.mapstruct.ap.internal.processor.DefaultVersionInformation.createManifestUrl(DefaultVersionInformation.java:180)  

This is an example usage of MapStruct in my project.

@Mapper(componentModel = "spring", uses = {}, unmappedTargetPolicy = ReportingPolicy.WARN)
public interface AccountMapper {
    @Mapping(source = "registerDto.firstName", target = "firstName")
    Account from(RegisterDto registerDto, PasswordDto passwordDto);
}

What could be the issue in that case ? That problem I have only in IntelliJ. In cmd I can run and compile project.


Solution

  • I have found an interesting article which solves compilation problem in Intellij. https://youtrack.jetbrains.com/issue/IDEA-220430