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

MapStruct errors out when trying to process classes that reference generated code #769

Closed
wouterh-dev opened this issue Mar 3, 2016 · 27 comments
Assignees
Milestone

Comments

@wouterh-dev
Copy link

I'm generating code based on a wsdl file, and with jOOQ. I'd also like to use MapStruct. This works fine when I'm running generate-sources on my project after it has already compiled the other generated code, but when running mvn clean generate-sources MapStruct appears to be scanning all of my Java files and errors out because a few files are referencing, at this point, non-existent classes. This happens even if the MapStruct plugin is positioned after the other generation plugins.

Here's the relevant section of my pom:

        <plugins>
            <plugin>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>${postgresql.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <jdbc>
                        <driver>org.postgresql.Driver</driver>
                        <url>jdbc:postgresql://localhost/something</url>
                        <user>something</user>
                        <password>something</password>
                    </jdbc>
                    <generator>
                        <name>org.jooq.util.DefaultGenerator</name>
                        <database>
                            <name>org.jooq.util.postgres.PostgresDatabase</name>
                            <includes>.*</includes>
                            <excludes />
                            <inputSchema>public</inputSchema>

                            <customTypes>
                                <customType>
                                    <name>JsonNode</name>
                                    <type>com.fasterxml.jackson.databind.JsonNode</type>
                                    <binding>com.something.PostgresJSONBinding</binding>
                                </customType>
                            </customTypes>
                            <forcedTypes>
                                <forcedType>
                                    <name>JsonNode</name>
                                    <expression>.*</expression>
                                    <types>jsonb</types>
                                </forcedType>
                            </forcedTypes>
                        </database>
                        <generate>
                            <pojos>true</pojos>
                        </generate>
                        <target>
                            <packageName>com.something.jooq</packageName>
                            <directory>src/main/generated</directory>
                        </target>
                    </generator>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/wsdl/something.wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-autoNameResolution</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</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.build.directory}/generated/cxf/</source>
                                <source>src/main/generated</source>
                                <source>${project.build.directory}/generated-sources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.2.3</version>
                <configuration>
                    <defaultOutputDirectory>
                        ${project.build.directory}/generated-sources
                    </defaultOutputDirectory>
                    <processors>
                        <processor>org.mapstruct.ap.MappingProcessor</processor>
                    </processors>
                    <options>
                        <mapstruct.defaultComponentModel>spring</mapstruct.defaultComponentModel>
                    </options>
                </configuration>
                <executions>
                    <execution>
                        <id>process</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>process</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${org.mapstruct.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

And here is some of the debug output:

[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/service/Audit.java:14: error: package com.something.jooq.something does not exist
import com.something.jooq.something.Tables;
                                ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:10: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotificationResponse;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:11: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyCountingCategoriesRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:12: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyCountingCategoriesResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:13: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyEntryRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:14: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyExitRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:15: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyPaymentRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:16: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PaymentRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:17: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PaymentResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:18: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PermissionRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:19: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PermissionResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:20: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PingRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:21: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PingResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:31: error: cannot find symbol
  public PingResponse2 ping(@WebParam(name = "request") PingRequest request);
                                                        ^
  symbol:   class PingRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:31: error: cannot find symbol
  public PingResponse2 ping(@WebParam(name = "request") PingRequest request);
         ^
  symbol:   class PingResponse2
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:41: error: cannot find symbol
      @WebParam(name = "request") NotifyCountingCategoriesRequest request);
                                  ^
  symbol:   class NotifyCountingCategoriesRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:40: error: cannot find symbol
  public NotifyCountingCategoriesResponse2 notifyCountingCategories(
         ^
  symbol:   class NotifyCountingCategoriesResponse2
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:50: error: cannot find symbol
  public NotificationResponse notifyPayment(@WebParam(name = "request") NotifyPaymentRequest request);
                                                                        ^
  symbol:   class NotifyPaymentRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:50: error: cannot find symbol
  public NotificationResponse notifyPayment(@WebParam(name = "request") NotifyPaymentRequest request);
         ^
  symbol:   class NotificationResponse
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:58: error: cannot find symbol
  public PaymentResponse2 payment(@WebParam(name = "request") PaymentRequest request);
                                                              ^
  symbol:   class PaymentRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:58: error: cannot find symbol
  public PaymentResponse2 payment(@WebParam(name = "request") PaymentRequest request);
         ^
  symbol:   class PaymentResponse2
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:67: error: cannot find symbol
  public NotificationResponse notifyExit(@WebParam(name = "request") NotifyExitRequest request);
                                                                     ^
  symbol:   class NotifyExitRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:67: error: cannot find symbol
  public NotificationResponse notifyExit(@WebParam(name = "request") NotifyExitRequest request);
         ^
  symbol:   class NotificationResponse
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:76: error: cannot find symbol
  public PermissionResponse2 permission(@WebParam(name = "request") PermissionRequest request);
                                                                    ^
  symbol:   class PermissionRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:76: error: cannot find symbol
  public PermissionResponse2 permission(@WebParam(name = "request") PermissionRequest request);
         ^
  symbol:   class PermissionResponse2
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:85: error: cannot find symbol
  public NotificationResponse notifyEntry(@WebParam(name = "request") NotifyEntryRequest request);
                                                                      ^
  symbol:   class NotifyEntryRequest
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpoint.java:85: error: cannot find symbol
  public NotificationResponse notifyEntry(@WebParam(name = "request") NotifyEntryRequest request);
         ^
  symbol:   class NotificationResponse
  location: interface com.something.something.api.something.somethingEndpoint
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:9: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotificationResponse;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:10: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyCountingCategoriesRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:11: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyCountingCategoriesResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:12: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyEntryRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:13: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyExitRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:14: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.NotifyPaymentRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:15: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PaymentRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:16: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PaymentResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:17: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PermissionRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:18: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PermissionResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:19: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PingRequest;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:20: error: package com.something.projects.something.parking.v4 does not exist
import com.something.projects.something.parking.v4.PingResponse2;
                                          ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:21: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.CountingCategoryDataEnum;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:22: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.DetailEnum;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:23: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.EntryMovement;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:24: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.ExitMovement;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:25: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.Identification;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:26: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.Location;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:27: error: package com.something.projects.something.types.v4 does not exist
import com.something.projects.something.types.v4.somethingHeader;
                                        ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:38: error: cannot find symbol
  public PingResponse2 ping(PingRequest request) {
                            ^
  symbol:   class PingRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:38: error: cannot find symbol
  public PingResponse2 ping(PingRequest request) {
         ^
  symbol:   class PingResponse2
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:54: error: cannot find symbol
      NotifyCountingCategoriesRequest request) {
      ^
  symbol:   class NotifyCountingCategoriesRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:53: error: cannot find symbol
  public NotifyCountingCategoriesResponse2 notifyCountingCategories(
         ^
  symbol:   class NotifyCountingCategoriesResponse2
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:75: error: cannot find symbol
  public NotificationResponse notifyPayment(NotifyPaymentRequest request) {
                                            ^
  symbol:   class NotifyPaymentRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:75: error: cannot find symbol
  public NotificationResponse notifyPayment(NotifyPaymentRequest request) {
         ^
  symbol:   class NotificationResponse
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:93: error: cannot find symbol
  public PaymentResponse2 payment(PaymentRequest request) {
                                  ^
  symbol:   class PaymentRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:93: error: cannot find symbol
  public PaymentResponse2 payment(PaymentRequest request) {
         ^
  symbol:   class PaymentResponse2
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:119: error: cannot find symbol
  public NotificationResponse notifyExit(NotifyExitRequest request) {
                                         ^
  symbol:   class NotifyExitRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:119: error: cannot find symbol
  public NotificationResponse notifyExit(NotifyExitRequest request) {
         ^
  symbol:   class NotificationResponse
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:150: error: cannot find symbol
  public PermissionResponse2 permission(PermissionRequest request) {
                                        ^
  symbol:   class PermissionRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:150: error: cannot find symbol
  public PermissionResponse2 permission(PermissionRequest request) {
         ^
  symbol:   class PermissionResponse2
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:172: error: cannot find symbol
  public NotificationResponse notifyEntry(NotifyEntryRequest request) {
                                          ^
  symbol:   class NotifyEntryRequest
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:172: error: cannot find symbol
  public NotificationResponse notifyEntry(NotifyEntryRequest request) {
         ^
  symbol:   class NotificationResponse
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:200: error: cannot find symbol
  protected void fillReturnHeader(somethingHeader headerIn, somethingHeader headerOut) {
                                  ^
  symbol:   class somethingHeader
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/somethingEndpointImpl.java:200: error: cannot find symbol
  protected void fillReturnHeader(somethingHeader headerIn, somethingHeader headerOut) {
                                                      ^
  symbol:   class somethingHeader
  location: class com.something.something.api.something.somethingEndpointImpl
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/AuditApi.java:17: error: package com.something.jooq.something does not exist
import com.something.jooq.something.Tables;
                                ^
[DEBUG] diagnostic /home/vagrant/projects/something-something/src/main/java/com/something/something/api/something/AuditApi.java:18: error: package com.something.jooq.something.tables.records does not exist
import com.something.jooq.something.tables.records.AuditLogRecord;
                                               ^
[ERROR] error on execute: error during compilation
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.370 s
[INFO] Finished at: 2016-03-03T18:09:41+01:00
[INFO] Final Memory: 42M/362M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.bsc.maven:maven-processor-plugin:2.2.3:process (process) on project something-something: Error executing: error during compilation -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.bsc.maven:maven-processor-plugin:2.2.3:process (process) on project something-something: Error executing
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:291)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: java.lang.Exception: error during compilation
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:542)
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:284)
    ... 22 more

(I have replaced sensitive names with something)

Is it perhaps possible to restrict the packages that MapStruct scans?

@gunnarmorling
Copy link
Member

Hum, MapStruct is only interested in types annotated with @Mapper, so it's not quite clear to me why it has trouble with these other types. Do you think you could provide a minimum Maven project exposing this bug? I'll then take a look.

@wouterh-dev
Copy link
Author

@gunnarmorling I wouldn't be surprised if this was the same issue as https://groups.google.com/forum/#!topic/mapstruct-users/minP3fHfrU8

I'll get started on a minimum project demonstrating the bug.

@gunnarmorling
Copy link
Member

gunnarmorling commented Mar 3, 2016 via email

@wouterh-dev
Copy link
Author

@gunnarmorling I've managed to replicate the issue in a minimal project: https://github.com/wouterhund/mapstruck-error-demo

Performing a mvn clean install should show you the error. I can work around the issue by attaching mapstruct to the compile phase, but I'd rather not do that.

I'm using build-helper-maven-plugin to add an extra sources directory, which does not seem to be picked up by maven-processor-plugin or mapstruct. I'm using build-helper-maven-plugin in my real project, which causes the same problem, but it also happens when just using cxf or jooq code generation.

@gunnarmorling
Copy link
Member

gunnarmorling commented Mar 3, 2016 via email

@wouterh-dev
Copy link
Author

I happened upon the addCompileSourceRoots configuration option of the maven-processor-plugin which seems to fix this issue, as long as MapStruct is ordered last in the plugins directive. However I wasn't able to find this option in the documentation of maven-processor-plugin.

@wouterh-dev
Copy link
Author

Enabling addCompileSourceRoots seems to expose a compiler bug when running incremental compilations (in JDK8U66 at least, with mvn clean compile; mvn compile) so this is not advised. A stacktrace of the bug:

An exception has occurred in the compiler (1.8.0_66-internal). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.IllegalStateException: endPosTable already set
    at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
    at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
    at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
    at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:892)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
    at com.sun.tools.javac.main.Main.compile(Main.java:523)
    at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:625)
    at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:363)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

I'm back to running mapstruct in the compile phase without addCompileSourceRoots

@agudian
Copy link
Member

agudian commented Mar 7, 2016

What you're seeing is not a bug in the JDK, but one in the maven-compiler-plugin. Update that one to 3.5.1 and you should be good.
Btw, that version of the maven-compiler-plugin also allows you to configure the annotation processor dependencies explicitly using the option annotationProcessorPaths.

@wouterh-dev
Copy link
Author

That last bit helped a lot, thanks.

But when I switched to using the maven-compiler-plugin 3.5.1 with maven-processor-plugin 3.1.0 using addCompileSourceRoots I still got the same exception, which occurs during the maven-processor-plugin:3.1.0:process (process) phase.

Still using maven-compiler-plugin 3.5.1 I switched to using annotationProcessorPaths which seems to work smoothly, dropping the need for maven-processor-plugin. This does mean the generation happens during the compile phase instead of the generate-sources phase, but I can live with that.

@gunnarmorling
Copy link
Member

I still got the same exception

Is this reproduce-able in the demo project you linked above? I don't get it there, also when adding "addCompileSourceRoots". Does it only happen if you don't do a "clean" by any chance?

@gunnarmorling
Copy link
Member

Ah yes, seeing it now, when running "mvn install" after "mvn clean install".

@wouterh-dev
Copy link
Author

Yes, it only happens when doing an incremental compilation. So mvn clean compile; mvn compile triggers it for me consistently.

@gunnarmorling
Copy link
Member

@agudian, I'm getting this error from the maven-processor-plugin, not the compiler plug-in. I think it's caused by the fact that MapStruct tries to create mapper implementations a second time.

After some googling it appears to be a common issue with annotation processors and incremental compilation. It's not quite clear to me how to avoid it at this point (apart from running "mvn clean compile").

@gunnarmorling
Copy link
Member

So one - admittedly hacky - approach is to delete the directory with generated sources yourself, e.g. using the maven-antrun-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <target>
                    <delete dir="${project.build.directory}/generated-sources" />
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>

Adding this prior to the maven-processor-plugin configuration makes "mvn compile" work.

I suppose, actually maven-processor-plugin should do this deletion itself.

@wouterh-dev
Copy link
Author

Is there a reason to prefer maven-processor-plugin over annotationProcessorPaths with a recent maven-compiler-plugin? As a note, seems you can also pass arguments to mapstruct with for example

<compilerArguments>
    <Amapstruct.defaultComponentModel>spring</Amapstruct.defaultComponentModel>
</compilerArguments>

@agudian
Copy link
Member

agudian commented Mar 7, 2016

That incremental issue with annotation processors was fixed in maven-compiler-p 3.5.1, but it can't do anything about the same kind of issue in the processor plugin.
Personally, I'd always prefer using the compiler-plugin only. It's a much simpler configuration, the classpath of the used processors is cleaner and the compiler itself doesn't have to be called twice.

@gunnarmorling
Copy link
Member

Yes, the main reason for me preferring the maven-processor-plugin in the past was isolation of the processor path. As you say, that's doable with the compiler plug-in itself now.

Another smaller advantage is being able to generate mappers (only) via mvn generate-sources instead of doing a full compile, but that's not so critical. Plus, one can achieve the same with the processor plug-in by adding another execution with "proc:only" to the generate-sources phase.

I think we just can change the documentation and show usage of the compiler plug-in with "annotationProcessorPaths".

@agudian, do you know whether the M2E plug-in already picks up configuration from "annotationProcessorPaths"? I.e. is experience for Eclipse users as good as with the separate plug-in?

@wouterh-dev
Copy link
Author

@gunnarmorling I happen to know that it does. I'm using Eclipse and with Window->Preferences->Maven->Annotation Processors enabled everything works extremely smoothly.

@agudian
Copy link
Member

agudian commented Mar 8, 2016

Right, it came with the latest update to m2e-apt. Btw, if you add the following to the <properties> section, the plugin will automatically enable the processor stuff, also in freshly setup workspaces:

  <properties>
    <!-- Automatically activate m2e APT in Eclipse  -->
    <m2e.apt.activation>jdt_apt</m2e.apt.activation>
  </properties>

@wouterh-dev
Copy link
Author

Oh, that is awesome. Thanks again.
On Mar 8, 2016 10:17 AM, "Andreas Gudian" notifications@github.com wrote:

Right, it came with the latest update to m2e-apt. Btw, if you add the
following to the section, the plugin will automatically
enable the processor stuff, also in freshly setup workspaces:

jdt_apt


Reply to this email directly or view it on GitHub
#769 (comment)
.

@agudian agudian modified the milestones: 1.1.0.Beta1, 1.1.0.CR1 Mar 15, 2016
@gunnarmorling gunnarmorling self-assigned this Mar 15, 2016
@gunnarmorling gunnarmorling modified the milestones: 1.1.0.Beta1, 1.1.0.CR1 Mar 15, 2016
gunnarmorling added a commit to gunnarmorling/mapstruct that referenced this issue Mar 15, 2016
@gunnarmorling
Copy link
Member

Sent PR #786 for updating the docs.

@agudian
Copy link
Member

agudian commented Mar 16, 2016

Doc update is merged. Thanks, Gunnar!

@fdimauro
Copy link

Did the original issue ever get fixed? And if so how?

@fdimauro
Copy link

I am having the same issue at the command line.

@filiphr
Copy link
Member

filiphr commented Feb 20, 2017

Did you configure your pom like in our documentation?

@fdimauro
Copy link

fdimauro commented Feb 20, 2017 via email

@gunnarmorling
Copy link
Member

gunnarmorling commented Feb 20, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants