Skip to content

Commit

Permalink
fix: Fix exception on empty VssDefinition asset file
Browse files Browse the repository at this point in the history
If the VssDefinition annotation is missing but the processor is
executed then the necessary asset file can't be found.

- Removes a redundant `maven-publish` plugin

close #43

Signed-Off-By: Mark Hüsers <mark.huesers@etas.com>
  • Loading branch information
Chrylo committed Nov 24, 2023
1 parent dbd4e19 commit 5153077
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion vss-processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
kotlin("jvm")
`maven-publish`
publish
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class VssDefinitionProcessor(
val vssDefinitionPath = vssDefinition.vssDefinitionPath

val definitionFile = loadAssetFile(vssDefinitionPath)
if (!definitionFile.exists()) {
if (definitionFile == null || !definitionFile.exists()) {
logger.error("No VSS definition file was found!")
return
}
Expand All @@ -97,13 +97,14 @@ class VssDefinitionProcessor(
}

// Uses the default file path for generated files (from the code generator) and searches for the given file.
private fun loadAssetFile(fileName: String): File {
val generationPath = codeGenerator.generatedFile.first().absolutePath
private fun loadAssetFile(fileName: String): File? {
val generatedFile = codeGenerator.generatedFile.firstOrNull() ?: return null
val generationPath = generatedFile.absolutePath
val buildPath = generationPath.replaceAfter(BUILD_FOLDER_NAME, "")
val assetsFilePath = "$buildPath/$ASSETS_BUILD_DIRECTORY"
val assetsFolder = File(assetsFilePath)

return assetsFolder.walk().first { it.name == fileName }
return assetsFolder.walk().firstOrNull { it.name == fileName }
}

private fun generateModelFiles(vssPathToSpecification: Map<VssPath, VssSpecificationSpecModel>) {
Expand Down

0 comments on commit 5153077

Please sign in to comment.