Created
September 19, 2017 07:29
-
-
Save ldziedziul/f88b1c09ae2ad9cfffcc0d0b4791e1d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ext { | |
| javaLanguageLevel = 1.8 | |
| generatedMapperSourcesDir = "${buildDir}/generated-src" | |
| } | |
| configurations { | |
| mapstruct | |
| } | |
| dependencies { | |
| mapstruct group: 'org.mapstruct', name: 'mapstruct-processor', version: mapstruct_version | |
| } | |
| sourceSets.main { | |
| ext.originalJavaSrcDirs = java.srcDirs | |
| java.srcDir "${generatedMapperSourcesDir}" | |
| } | |
| task generateMainMapperClasses(type: JavaCompile) { | |
| ext.aptDumpDir = file("${buildDir}/tmp/apt/mapstruct") | |
| destinationDir = aptDumpDir | |
| classpath = compileJava.classpath + configurations.mapstruct | |
| source = sourceSets.main.originalJavaSrcDirs | |
| ext.sourceDestDir = file("$generatedMapperSourcesDir") | |
| options.define( | |
| compilerArgs: [ | |
| "-nowarn", | |
| "-proc:only", | |
| "-encoding", "UTF-8", | |
| "-processor", "org.mapstruct.ap.MappingProcessor", | |
| "-s", sourceDestDir.absolutePath, | |
| "-source", rootProject.javaLanguageLevel, | |
| "-target", rootProject.javaLanguageLevel, | |
| "-Amapstruct.defaultComponentModel=spring", | |
| "-Amapstruct.suppressGeneratorTimestamp=true" | |
| ] | |
| ); | |
| inputs.dir source | |
| outputs.dir generatedMapperSourcesDir; | |
| doFirst { | |
| sourceDestDir.mkdirs() | |
| } | |
| doLast { | |
| aptDumpDir.delete() | |
| } | |
| } | |
| compileJava.dependsOn generateMainMapperClasses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment