title: How can I generate Mapstruct mapper implementations for test scope mapper interface in Gradle build?
body: <p>I'm having a simple Java single module Gradle project in which I use Mapstruct for the Java mapping. My <code>build.gradle</code> looks like this:</p>
  
  <pre><code>plugins {
      id 'java-library'
      id 'groovy'
      id 'net.ltgt.apt' version '0.20'
  }
  
  repositories {
      jcenter()
  }
  
  dependencies {
      implementation 'org.mapstruct:mapstruct-jdk8:1.2.0.Final'
      annotationProcessor 'org.mapstruct:mapstruct-processor:1.2.0.Final'
  
      testImplementation 'org.codehaus.groovy:groovy-all:2.5.5'
  
      // Use the awesome Spock testing and specification framework even with Java
      testImplementation 'org.spockframework:spock-core:1.2-groovy-2.5'
      testImplementation 'junit:junit:4.12'
  }
  
  sourceSets {
      main {
          java {
              srcDirs "${project.buildDir}/generated/sources/annotationProcessor/java/main"
          }
      }
      test {
          java {
              srcDirs "${project.buildDir}/generated/sources/annotationProcessor/java/test"
          }
      }
  }
  </code></pre>
  
  <p>My source folder contains the following Java source code:</p>
  
  <pre><code>src
  ├── main
  │   ├── java
  │   │   └── ch
  │   │       └── silviowangler
  │   │           ├── Person.java
  │   │           ├── SomeMapper.java
  │   │           └── User.java
  │   └── resources
  └── test
      ├── groovy
      │   └── ch
      │       └── silviowangler
      ├── java
      │   └── ch
      │       └── silviowangler
      │           └── YoloMapper.java
      └── resources
  </code></pre>
  
  <p><code>SomeMapper</code> is a simple mapper interface that looks like this</p>
  
  <pre><code>@Mapper
  public interface SomeMapper {
  
      @Mappings({
              @Mapping(target = "firstName", source = "nickname"),
              @Mapping(target = "surname", ignore = true),
              @Mapping(target = "dateOfBirth", ignore = true)
      })
      Person fromString(User user);
  }
  </code></pre>
  
  <p>And the <code>YoloMapper</code> that resides in the test scope looks like that</p>
  
  <pre><code>@Mapper
  public interface YoloMapper {
  
      String fromLocalDate(LocalDate localDate);
  }
  </code></pre>
  
  <p>When I run <code>./gradlew clean cTJ</code> the build completes successfully and the annotation processor generates a mapper implementation for <code>SimpleMapper</code> but it does not generate anything for the <code>YoloMapper</code>. The <code>build</code> folder after the build looks like</p>
  
  <pre><code>build
  ├── classes
  │   └── java
  │       ├── main
  │       │   └── ch
  │       │       └── silviowangler
  │       │           ├── Person.class
  │       │           ├── SomeMapper.class
  │       │           ├── SomeMapperImpl.class
  │       │           └── User.class
  │       └── test
  │           └── ch
  │               └── silviowangler
  │                   └── YoloMapper.class
  ├── generated
  │   └── sources
  │       └── annotationProcessor
  │           └── java
  │               ├── main
  │               │   └── ch
  │               │       └── silviowangler
  │               │           └── SomeMapperImpl.java
  │               └── test
  └── tmp
      ├── compileJava
      └── compileTestJava
  </code></pre>
  
  <p>How can I make Gradle to tell the annotation processor to generate Mapstruct mapper implementation in the test scope?</p>