{"id":15056510,"url":"https://github.com/kivanval/gravrity","last_synced_at":"2025-04-10T04:34:18.727Z","repository":{"id":217598909,"uuid":"742860193","full_name":"kivanval/gravrity","owner":"kivanval","description":"A Gradle plugin that compiles Apache Avro files (*.avpr, *.avsc, *.avdl) into the corresponding Scala files in your project using the Avrohugger. ","archived":false,"fork":false,"pushed_at":"2024-07-07T05:08:21.000Z","size":335,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-07-07T06:24:29.133Z","etag":null,"topics":["avro","avro-schema","gradle-plugin","groovy","scala","spock"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kivanval.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-13T15:33:13.000Z","updated_at":"2024-07-07T06:24:37.807Z","dependencies_parsed_at":"2024-02-14T00:26:12.184Z","dependency_job_id":"dc07b6c7-5eab-4a59-a45d-a21a977aa67c","html_url":"https://github.com/kivanval/gravrity","commit_stats":null,"previous_names":["kivanval/gradle-avrohugger","kivanval/gravrity"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivanval%2Fgravrity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivanval%2Fgravrity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivanval%2Fgravrity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivanval%2Fgravrity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kivanval","download_url":"https://codeload.github.com/kivanval/gravrity/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239140081,"owners_count":19588330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avro","avro-schema","gradle-plugin","groovy","scala","spock"],"created_at":"2024-09-24T21:52:16.982Z","updated_at":"2025-02-16T14:31:08.074Z","avatar_url":"https://github.com/kivanval.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🇺🇦 HELP UKRAINE\n\nI'm the creator of this project.\nMy country, Ukraine, [is being invaded by the Russian Federation, right now](https://war.ukraine.ua). If you want to help my country to fight, consider donating to [charity supporting Ukrainian army](https://www.comebackalive.in.ua/). More options is described on [support ukraine](https://supportukrainenow.org/) site.\n\n# Avrohugger Plugin for Gradle\n\nA Gradle plugin that compiles [Apache Avro](https://avro.apache.org/docs/1.11.1/) files (```*.avpr, *.avsc, *.avdl```) \ninto the corresponding Scala files in your project using the [Avrohugger](https://github.com/julianpeeters/avrohugger).\nIt has two main functions:\n1. Collects all the necessary information for the Avohugger Generator, which generates Scala sources from Apache Avro files.\n2. Adds the generated Scala source files to the input of the Scala sourceSet, so that they can be compiled along with your Scala sources.\n\n## Latest Version\n\nThe latest version is 1.0.0. It requires at least Gradle 7.2 and Java 8.\n```groovy\nplugins {\n  id 'io.github.kivanval.avrohugger' version '1.0.0'\n}\n```\n\n## Development Version\n\nTo try out the head version, you can download the source and build it with ```./gradlew publishToMavenLocal```, then in ```settings.gradle```:\n```groovy\npluginManagement {\n  repositories {\n    gradlePluginPortal()\n    mavenLocal()\n  }\n}\n```\nAnd in ```build.gradle```:\n```groovy\nplugins {\n  id 'io.github.kivanval.avrohugger' version '1.0.0-SNAPSHOT'\n}\n```\n\n## Configuring Avrohugger generation\n\nThe Avrohugger plugin assumes that the Apache Avro files (```*.avpr, *.avsc, *.avdl```) \nare organized in the same way as Scala source files, in sourceSets. \nThe files generated by the Avrohugger Generator are added to the Scala sources \nbefore executing ```./gradlew compileScala```.\n\n### Customizing source directories\n\nThe plugin adds a new source directory named ```avro``` alongside ```scala``` to every sourceSet. \nBy default, it includes all ```*.avpr, *.avsc, *.avdl``` files under ```src/$sourceSetName/avro```. \nYou can customize it in the same way as you would customize the scala sources.\n```groovy\nsourceSets {\n    main {\n        avro {\n            // In addition to the default 'src/main/avro'\n            srcDir 'src/main/avro-schemas'\n            include '**/*.json'\n            // Change default output path 'generated/sources/avrohugger/scala/main'\n            // \n            destinationDirectory = file(\"$rootDir/someDir\")\n        }\n    }\n    test {\n        avro {\n            // In addition to the default 'src/test/avro'\n            srcDir 'src/test/avro-schemas'\n        }\n    }\n}\n```\n**Warning**: Use empty directories for ```destinationDirectory```, \nas the ```./gradlew clean``` will remove all files from the directory path specified!\n\n### Customizing Avrohugger generation\n\nThe plugin adds a ```avrohugger``` extension to the project.\nIt provides all the configurations necessary for the generator.\n- Groovy\n```groovy\navrohugger {\n    // There are two types of generation: standard and specific. \n    // Choose the one you need and change the standard configuration for the types if necessary.\n    format = specificRecord {\n        intType = scalaInt\n        decimalType = scalaBigDecimal(roundingMode.CEILING())\n    }\n    // Mapping avro namespaces to scala packages\n    namespaceMapping = ['com.example': 'io.github.kivanval.avrohugger']\n    // Flag related to case classes limitation in Scala versions \u003c= 2.10.*\n    restrictedFieldNumber = false\n}\n```\n- Kotlin\n```kotlin\navrohugger {\n    // There are two types of generation: standard and specific. \n    // Choose the one you need and change the standard configuration for the types if necessary.\n    format = specificRecord {\n        intType = scalaInt\n        decimalType = scalaBigDecimal(roundingMode.CEILING())\n    }\n    // Mapping avro namespaces to scala packages\n    namespaceMapping = mapOf(\"com.example\" to \"io.github.kivanval.avrohugger\")\n    // Flag related to case classes limitation in Scala versions \u003c= 2.10.*\n    restrictedFieldNumber = false\n}\n```\n\n#### Default configuration\n\nTo understand the standard type mappings for the plugin, \nI recommend checking out the [Avrohugger](https://github.com/julianpeeters/avrohugger).\n\n```groovy\navrohugger {\n    // default type mapping from avrohugger\n    format = standard\n    namespaceMapping = []\n    restrictedFieldNumber = false\n}\n```\n\n#### Specific format\n\nUsing the specific format make sure you have \na dependency on [Apache Avro](https://mvnrepository.com/artifact/org.apache.avro/avro). \nAt the moment this has to be done manually.\n\n```groovy\n dependencies {\n    implementation 'org.apache.avro:avro:1.11.3'\n }\n```\n\n## Avro files in dependencies\n\nIf the dependency is put in the ```avro``` configuration, \nthe avro files are extracted to a ```extracted/sources/avrohugger/avro/$sourceSetName``` directory\nand added to the avro source sets in the project. \nExample:\n\n```groovy\ndependencies {\n    // avro files can be from a local package,\n    avro files('lib/nestedSample.zip')\n    // ... a local directory,\n    avro files('ext/')\n    // ... or an artifact from a repository\n    testAvro 'com.example:published-avro:1.0.0'\n}\n```\n\n## Sandbox\n\nIf you want to manually test the plugin, \nuse [sandbox](https://github.com/kivanval/gradle-avrohugger/tree/develop/sandbox) for this purpose.\nRun ```./gradlew build``` under the sandbox directory to test it out.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivanval%2Fgravrity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkivanval%2Fgravrity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivanval%2Fgravrity/lists"}