Skip to content

Commit

Permalink
Release version 2.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpeeters committed Jan 23, 2025
1 parent 372e7c8 commit 8befc2f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ _Note:_ Currently [Treehugger](http://eed3si9n.com/treehugger/comments.html#Scal

##### Get the dependency with:

"com.julianpeeters" %% "avrohugger-core" % "2.11.1"
"com.julianpeeters" %% "avrohugger-core" % "2.11.2"


##### Description:
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace rewritten. Multiple conflicting wildcards are not permitted.

##### Get the dependency with:

"com.julianpeeters" %% "avrohugger-filesorter" % "2.11.1"
"com.julianpeeters" %% "avrohugger-filesorter" % "2.11.2"


##### Description:
Expand All @@ -231,17 +231,17 @@ To ensure dependent schemas are compiled in the proper order (thus avoiding `org
#### `avrohugger-tools`


Download the avrohugger-tools jar for Scala [2.12](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.12/2.11.1/avrohugger-tools_2.12-2.11.1-assembly.jar), or Scala [2.13](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.13/2.11.1/avrohugger-tools_2.13-2.11.1-assembly.jar) (>30MB!) and use it like the avro-tools jar `Usage: [-string] (schema|protocol|datafile) input... outputdir`:
Download the avrohugger-tools jar for Scala [2.12](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.12/2.11.2/avrohugger-tools_2.12-2.11.2-assembly.jar), or Scala [2.13](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.13/2.11.2/avrohugger-tools_2.13-2.11.2-assembly.jar) (>30MB!) and use it like the avro-tools jar `Usage: [-string] (schema|protocol|datafile) input... outputdir`:


* `generate` generates Scala case class definitions:

`java -jar /path/to/avrohugger-tools_2.12-2.11.1-assembly.jar generate schema user.avsc . `
`java -jar /path/to/avrohugger-tools_2.12-2.11.2-assembly.jar generate schema user.avsc . `


* `generate-specific` generates definitions that extend Avro's `SpecificRecordBase`:

`java -jar /path/to/avrohugger-tools_2.12-2.11.1-assembly.jar generate-specific schema user.avsc . `
`java -jar /path/to/avrohugger-tools_2.12-2.11.2-assembly.jar generate-specific schema user.avsc . `


## Warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private[avrohugger] class FileGenerator {
val topLevelSchemas: List[Schema] =
NestedSchemaExtractor.getNestedSchemas(schema, schemaStore, typeMatcher)
// most-nested classes processed first
topLevelSchemas.distinct.reverse.foreach(schema => {
topLevelSchemas.reverse.distinct.foreach(schema => {
// pass in the top-level schema's namespace if the nested schema has none
val ns = DependencyInspector.getReferredNamespace(schema) orElse topNS
format.compile(classStore, ns, Left(schema), outDir, schemaStore, typeMatcher, restrictedFields, targetScalaPartialVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private[avrohugger] class StringGenerator {
val topLevels =
NestedSchemaExtractor.getNestedSchemas(schema, schemaStore, typeMatcher)
//reversed to process nested classes first
val compilationUnits = topLevels.distinct.reverse.flatMap(schema => {
val compilationUnits = topLevels.reverse.distinct.flatMap(schema => {
// pass in the top-level schema's namespace if the nested schema has none
val maybeNS = DependencyInspector.getReferredNamespace(schema).orElse(maybeNamespace)
format.asCompilationUnits(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ object NestedSchemaExtractor {
}
case UNION => fieldSchema.getTypes().asScala.toList.flatMap(x => flattenSchema(x))
case ENUM => {
// if the field schema is one that has already been stored, use that one
if (schemaStore.schemas.contains(fieldSchema.getFullName)) List()
else List(fieldSchema)
}
Expand All @@ -54,13 +53,15 @@ object NestedSchemaExtractor {
}
}

fieldSchemas
fieldSchemas.distinct
.flatMap(flattenSchema)
.filter { schema =>
if (typeMatcher.avroScalaTypes.`enum` == EnumAsScalaString)
if (typeMatcher.avroScalaTypes.`enum` == EnumAsScalaString) {
schema.getType == RECORD | schema.getType == FIXED
else
}
else {
schema.getType == RECORD | schema.getType == ENUM | schema.getType == FIXED
}
}
case ENUM => List(schema)
case FIXED => List(schema)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lazy val avroVersion = "1.11.4"

lazy val commonSettings = Seq(
organization := "com.julianpeeters",
version := "2.11.2-SNAPSHOT",
version := "2.11.2",
ThisBuild / versionScheme := Some("semver-spec"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
Test / scalacOptions ++= Seq("-Yrangepos"),
Expand Down

0 comments on commit 8befc2f

Please sign in to comment.