@@ -57,7 +57,7 @@ abstract class GenerateTask : DefaultTask() {
57
57
@get:OutputDirectory
58
58
@get:Optional
59
59
@get:Option(option = " outputDir" , description = " Configures path of the Generated code directory." )
60
- abstract val outputDirectory : DirectoryProperty
60
+ abstract val outputDir : DirectoryProperty
61
61
62
62
@get:InputFiles
63
63
@get:Optional
@@ -71,12 +71,12 @@ abstract class GenerateTask : DefaultTask() {
71
71
72
72
@TaskAction
73
73
fun swaggerGenerate () {
74
- platform.convention (DEFAULT_PLATFORM )
75
- specName.convention (DEFAULT_NAME )
76
- packageName.convention (DEFAULT_PACKAGE )
77
- outputDirectory.convention (project.objects.directoryProperty().value(project. layout.buildDirectory.dir(DEFAULT_OUTPUT_DIR )))
78
- platform.convention( DEFAULT_PLATFORM )
79
- specName.convention(project.provider { readVersionFromSpecfile(inputFile.get().asFile) } )
74
+ val platform = platform.getOrElse (DEFAULT_PLATFORM )
75
+ val specName = specName.getOrElse (DEFAULT_NAME )
76
+ val packageName = packageName.getOrElse (DEFAULT_PACKAGE )
77
+ val outputDir = outputDir.getOrElse (project.layout.buildDirectory.dir(DEFAULT_OUTPUT_DIR ).get()).asFile
78
+ val inputFile = inputFile.get().asFile
79
+ val specVersion = specVersion.getOrElse( readVersionFromSpecfile(inputFile) )
80
80
81
81
val headersToRemove = features?.headersToRemove?.get() ? : emptyList()
82
82
@@ -89,27 +89,27 @@ abstract class GenerateTask : DefaultTask() {
89
89
specName ${' \t ' } $specName
90
90
specVers ${' \t ' } $specVersion
91
91
input ${" \t\t " } $inputFile
92
- output ${" \t\t " } $outputDirectory
92
+ output ${" \t\t " } $outputDir
93
93
groupId ${' \t ' } $packageName
94
94
artifactId ${' \t ' } $packageName
95
95
features ${' \t ' } ${headersToRemove.joinToString(separator = " ," , prefix = " [" , postfix = " ]" )}
96
96
""" .trimIndent())
97
97
98
98
val params = mutableListOf<String >()
99
99
params.add(" -p" )
100
- params.add(platform.get() )
100
+ params.add(platform)
101
101
params.add(" -s" )
102
- params.add(specName.get() )
102
+ params.add(specName)
103
103
params.add(" -v" )
104
- params.add(specVersion.get() )
104
+ params.add(specVersion)
105
105
params.add(" -g" )
106
- params.add(packageName.get(). substringBeforeLast(' .' ))
106
+ params.add(packageName.substringBeforeLast(' .' ))
107
107
params.add(" -a" )
108
- params.add(packageName.get(). substringAfterLast(' .' ))
108
+ params.add(packageName.substringAfterLast(' .' ))
109
109
params.add(" -i" )
110
- params.add(inputFile.get().asFile. toString())
110
+ params.add(inputFile.toString())
111
111
params.add(" -o" )
112
- params.add((outputDirectory.get().asFile) .toString())
112
+ params.add(outputDir .toString())
113
113
114
114
if (headersToRemove.isNotEmpty()) {
115
115
params.add(" -ignoreheaders" )
@@ -121,8 +121,7 @@ abstract class GenerateTask : DefaultTask() {
121
121
122
122
// Copy over the extra files.
123
123
val source = extraFiles.orNull?.asFile
124
- val destination = outputDirectory.get().asFile
125
- source?.copyRecursively(destination, overwrite = true )
124
+ source?.copyRecursively(outputDir, overwrite = true )
126
125
}
127
126
128
127
private fun readVersionFromSpecfile (specFile : File ): String {
0 commit comments