Skip to content

Commit

Permalink
Ignore virtual content without definition
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Jan 12, 2024
1 parent 02e7050 commit ba36c00
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions buildSrc/src/main/kotlin/tool/generator/api/task/GenerateApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ open class GenerateApi : DefaultTask() {
}

definitionMap[fileToPackage(sourceFile)]?.let { definition ->
if (definition::class.java.isAnnotationPresent(DisableDefinition::class.java)) {
if (isDefinitionDisabled(definition)) {
logger.info(" - (disabled) $sourceFile")
} else {
logger.info(" - $sourceFile")
Expand All @@ -76,7 +76,12 @@ open class GenerateApi : DefaultTask() {
* This is helpful to use when a class is fully auto-generated.
*/
private fun createVirtualContent() {
virtualContents.forEach { vc ->
for (vc in virtualContents) {
if (isDefinitionDisabled(definitionMap["${vc.packageName}.${vc.contentName}"])) {
logger.info(" - No definitions for virtual content: [${vc.packageName}.${vc.contentName}]")
continue
}

val dirFile = File(genDstDir + '/' + vc.packageName.replace('.', '/'))
dirFile.mkdirs()

Expand Down Expand Up @@ -144,4 +149,8 @@ open class GenerateApi : DefaultTask() {
if (it.isBlank()) it else it.prependIndent(BLANK_SPACE)
}.trimEnd()
}

private fun isDefinitionDisabled(definition: Definition?): Boolean {
return definition == null || definition::class.java.isAnnotationPresent(DisableDefinition::class.java)
}
}

0 comments on commit ba36c00

Please sign in to comment.