Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Files were generated into not-existing folder, added call to create all missing
parent folders.
  • Loading branch information
mcenkar committed Mar 3, 2023
1 parent cd99b62 commit ffbd5b4
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait SourceFormat {
typeMatcher: TypeMatcher,
restrictedFields: Boolean,
targetScalaPartialVersion: String): List[CompilationUnit]

def compile(
classStore: ClassStore,
namespace: Option[String],
Expand All @@ -61,7 +61,7 @@ trait SourceFormat {
typeMatcher: TypeMatcher,
restrictedFields: Boolean,
targetScalaPartialVersion: String): Unit

val defaultTypes: AvroScalaTypes

def getName(
Expand All @@ -87,7 +87,7 @@ trait SourceFormat {
case ScalaEnumeration => ".scala"
case EnumAsScalaString => sys.error("Only RECORD and ENUM can be top-level definitions")
}

schemaOrProtocol match {
case Left(schema) => schema.getType match {
case RECORD => ".scala"
Expand All @@ -97,7 +97,7 @@ trait SourceFormat {
}
case Right(protocol) => ".scala"
}

}

def getFilePath(
Expand Down Expand Up @@ -202,7 +202,7 @@ trait SourceFormat {
case _ => sys.error("Only RECORD, ENUM or FIXED can be top-level definitions")
}
}

// From: https://github.com/apache/avro/blob/33d495840c896b693b7f37b5ec786ac1acacd3b4/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java#L70
val RESERVED_WORDS: Set[String] = Set("abstract", "assert", "boolean", "break", "byte", "case", "catch",
"char", "class", "const", "continue", "default", "do", "double",
Expand All @@ -222,7 +222,8 @@ trait SourceFormat {
}
val contents = compilationUnit.codeString.getBytes()
try { // delete old and/or create new
Files.deleteIfExists(path)
Files.deleteIfExists(path) // delete file if exists
Files.createDirectories(path.getParent) // create all parent folders
Files.write(path, contents, StandardOpenOption.CREATE)
()
}
Expand All @@ -232,4 +233,4 @@ trait SourceFormat {
}
}

}
}

0 comments on commit ffbd5b4

Please sign in to comment.