Skip to content

Commit

Permalink
Release version 2.8.0
Browse files Browse the repository at this point in the history
Crossbuild for Scala 3, remove Scavro, remove reflective compilation.
  • Loading branch information
julianpeeters committed Nov 1, 2023
1 parent c5728fb commit b96c720
Show file tree
Hide file tree
Showing 123 changed files with 396 additions and 5,075 deletions.
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ API](https://avro.apache.org/docs/1.11.1/getting-started-java/#serializing-and-d
therefore have mutable `var` fields (for use with the Avro Specific API -
Scalding, Spark, Avro, etc.).

* `Scavro` (`@deprecated` since avrohugger v1.5.0) Case classes with immutable fields, intended to wrap Java generated
Avro classes (for use with the [Scavro](https://github.com/oedura/scavro#scavro-reader-and-writer)
runtime, Java classes provided separately (see [Scavro Plugin](https://github.com/oedura/scavro#scavro-plugin) or [sbt-avro](https://github.com/sbt/sbt-avro))).

##### Supports generating case classes with arbitrary fields of the following datatypes:

|Avro|`Standard`|`SpecificRecord`|Notes|
Expand Down Expand Up @@ -115,21 +111,21 @@ _Note:_ Currently [Treehugger](http://eed3si9n.com/treehugger/comments.html#Scal

* **Library For Scala 2.12, and 2.13**
* **Parses Schemas and IDLs with Avro version 1.11**
* **Generates Code Compatible with Scala 2.12, 2.13**
* **Generates Code Compatible with Scala 2.12, 2.13, 3**



#### `avrohugger-core`

##### Get the dependency with:

"com.julianpeeters" %% "avrohugger-core" % "1.7.0"
"com.julianpeeters" %% "avrohugger-core" % "2.8.0"


##### Description:

Instantiate a `Generator` with `Standard`, `Scavro`, or `SpecificRecord` source
formats. Then use
Instantiate a `Generator` with `Standard` or `SpecificRecord` source formats.
Then use


`tToFile(input: T, outputDir: String): Unit`
Expand Down Expand Up @@ -214,7 +210,7 @@ namespace rewritten. Multiple conflicting wildcards are not permitted.

##### Get the dependency with:

"com.julianpeeters" %% "avrohugger-filesorter" % "1.7.0"
"com.julianpeeters" %% "avrohugger-filesorter" % "2.8.0"


##### Description:
Expand All @@ -234,22 +230,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/1.7.0/avrohugger-tools_2.12-1.7.0-assembly.jar), or Scala [2.13](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.13/1.7.0/avrohugger-tools_2.13-1.7.0-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.8.0/avrohugger-tools_2.12-2.8.0-assembly.jar), or Scala [2.13](https://search.maven.org/remotecontent?filepath=com/julianpeeters/avrohugger-tools_2.13/2.8.0/avrohugger-tools_2.13-2.8.0-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-1.7.0-assembly.jar generate schema user.avsc . `
`java -jar /path/to/avrohugger-tools_2.12-2.8.0-assembly.jar generate schema user.avsc . `


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

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


* `generate-scavro` (`@deprecated` since avrohugger v1.5.0) generates definitions that extend Scavro's `AvroSerializable`:

`java -jar /path/to/avrohugger-tools_2.12-1.7.0-assembly.jar generate-scavro schema user.avsc . `
`java -jar /path/to/avrohugger-tools_2.12-2.8.0-assembly.jar generate-specific schema user.avsc . `


## Warnings
Expand Down
200 changes: 0 additions & 200 deletions avrohugger-core/src/main/scala/format/Scavro.scala

This file was deleted.

4 changes: 2 additions & 2 deletions avrohugger-core/src/main/scala/format/SpecificRecord.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object SpecificRecord extends SourceFormat{
val javaTreehugger = SpecificJavaTreehugger
val scalaTreehugger = SpecificScalaTreehugger

val defaultTypes: AvroScalaTypes = AvroScalaTypes.defaults.copy(enum = JavaEnum)
val defaultTypes: AvroScalaTypes = AvroScalaTypes.defaults.copy(`enum` = JavaEnum)

def asCompilationUnits(
classStore: ClassStore,
Expand All @@ -40,7 +40,7 @@ object SpecificRecord extends SourceFormat{
targetScalaPartialVersion: String): List[CompilationUnit] = {

registerTypes(schemaOrProtocol, classStore, typeMatcher)
val enumType = typeMatcher.avroScalaTypes.enum
val enumType = typeMatcher.avroScalaTypes.`enum`

val namespace =
CustomNamespaceMatcher.checkCustomNamespace(
Expand Down
4 changes: 2 additions & 2 deletions avrohugger-core/src/main/scala/format/Standard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object Standard extends SourceFormat {
typeMatcher,
maybeDefaultNamespace = ns)

val enumType = typeMatcher.avroScalaTypes.enum
val enumType = typeMatcher.avroScalaTypes.`enum`

schemaOrProtocol match {
case Left(schema) => {
Expand Down Expand Up @@ -179,7 +179,7 @@ object Standard extends SourceFormat {
schemaOrProtocol match {
case Left(schema) => schema.getName
case Right(protocol) => {
val localSubTypes = typeMatcher.avroScalaTypes.enum match {
val localSubTypes = typeMatcher.avroScalaTypes.`enum` match {
case JavaEnum => getLocalSubtypes(protocol).filterNot(isEnum)
case ScalaCaseObjectEnum => getLocalSubtypes(protocol)
case ScalaEnumeration => getLocalSubtypes(protocol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ trait SourceFormat {
def fileExt(
schemaOrProtocol: Either[Schema, Protocol],
typeMatcher: TypeMatcher): String = {
val enumType = typeMatcher.avroScalaTypes.enum
val enumType = typeMatcher.avroScalaTypes.`enum`
def enumExt: String = enumType match {
case JavaEnum => ".java"
case ScalaCaseObjectEnum => ".scala"
Expand Down Expand Up @@ -177,7 +177,7 @@ trait SourceFormat {
classStore: ClassStore,
typeMatcher: TypeMatcher): Unit = {
def registerSchema(schema: Schema): Unit = {
val typeName = typeMatcher.avroScalaTypes.enum match {
val typeName = typeMatcher.avroScalaTypes.`enum` match {
case JavaEnum => schema.getName
case ScalaCaseObjectEnum => schema.getName
case ScalaEnumeration => renameEnum(schema, "Value")
Expand Down
Loading

0 comments on commit b96c720

Please sign in to comment.