forked from mraible/21-points
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapstruct.gradle
51 lines (43 loc) · 1.33 KB
/
mapstruct.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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