-
Notifications
You must be signed in to change notification settings - Fork 1.7k
WIP: AVRO-4223 Gradle plugin for generating Java code #3614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
frevib
wants to merge
72
commits into
apache:main
Choose a base branch
from
frevib:AVRO-4223-gradle-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,888
−0
Draft
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
3f04a2c
Add Gradle plugin bootstrap
7a18d79
Add test for generating Java code
e6082e6
Rename task
8947e41
Add Maven publish
d0b8794
Rever change to Java file
ea3e5b6
Rever changes to Java files
2589fdd
Cleanup
28934e0
Add schemaType
737e585
Cleanup test
543c66b
Use Path instead of File for tests
5f1ac64
Remove null checks because it's Kotlin
3a9ae61
Improve test
93d7194
Add test source and output dir
afd90c8
Refactor
b765eb7
Add field visibility property
1b0d7f5
Add excludes property
fafd298
Add stringType and templateDirectory
634cd63
Add properties
f71ba50
Add properties
7c67834
Check if source directories exist
453c7a0
Cleanup
1b449b4
Cleanup
4fdab98
Cleanup
c4a06ae
Add readme
1b6efe7
Move to SourceTask
6c0b29e
Update readme
444d91c
Add dependency for generated sources
6daa02e
Update reamde
626e90c
Remove unneeded adding of dependency
21c8340
Update readme
4beb01d
Update readme
c42fee9
Update readme
0e2a47f
Rename class
frevib e22d2c3
Use different Gradle Task for generating test sources
frevib 3dccc3c
Add support for Velocity class names
frevib 5525f61
Add test for recordSpecificClass
frevib e746bbd
Merge remote-tracking branch 'upstream/main' into feat/gradle-plugin
frevib 529144f
Add generate options
frevib ae791a0
Update README
frevib a989843
AVRO-4223
frevib 1e73f02
AVRO-4223
frevib de150a2
AVRO-4223
frevib 485dbfd
AVRO-4223
frevib 91807d8
AVRO-4223
frevib 916a732
AVRO-4223
frevib 2a5b93c
AVRO-4223
frevib 8cb27ef
Merge remote-tracking branch 'upstream/main' into AVRO-4223-gradle-pl…
frevib 8b1acc5
AVRO-4223
frevib 89378cf
AVRO-4223
frevib e247865
AVRO-4223
frevib 01f1ae7
AVRO-4223
frevib 47b34d4
AVRO-4223
frevib 8094451
AVRO-4223
frevib 61ed721
AVRO-4223
frevib 6a6f3c9
AVRO-4223
frevib cb6fbf4
AVRO-4223
frevib f041b10
AVRO-4223
frevib 3853d9a
AVRO-4223
frevib 3ac3f41
AVRO-4223
frevib 8c805ba
AVRO-4223
frevib cdd6861
AVRO-4223
frevib f8c4152
AVRO-4223
frevib 90c0e66
AVRO-4223
frevib 1809d6f
AVRO-4223
frevib 4eef735
AVRO-4223
frevib 78b67d7
AVRO-4223
frevib f309faf
AVRO-4223
frevib 3519eb8
AVRO-4223
frevib 89a4629
AVRO-4223
frevib 9e7bd24
AVRO-4223
frevib 1cf8762
AVRO-4223
frevib 6183c73
AVRO-4223
frevib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Avro Gradle plugin (in development) | ||
|
|
||
| Gradle plugin that generates Java code from Avro schemas | ||
|
|
||
| ## Version | ||
| `0.0.2` | ||
|
|
||
| first beta | ||
|
|
||
| `0.0.5` | ||
|
|
||
| Possible breaking change: rename `CompileSchemaTask` to `CompileAvroSchemaTask` | ||
|
|
||
| Add logical type factories | ||
|
|
||
| Now released on Gradle plugin portal: https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin | ||
|
|
||
| `0.0.7` | ||
|
|
||
| It is not needed to add `tasks.named("compileKotlin") { dependsOn(tasks.named("avroGenerateJavaClasses")) }` any more | ||
|
|
||
| `0.0.8` | ||
|
|
||
| Add `sourceZipFiles` property to add zip files with schemas in them | ||
| pu | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Add avro extension | ||
| In `build.gradle.kts`: | ||
|
|
||
| ### Add plugin | ||
|
|
||
| ```kotlin | ||
| plugins { | ||
| id("eu.eventloopsoftware.avro-gradle-plugin") version "0.0.8" | ||
| } | ||
| ``` | ||
| ### Add Avro dependency | ||
|
|
||
| ```kotlin | ||
| implementation("org.apache.avro:avro:1.12.1") | ||
| ``` | ||
|
|
||
| ### Configure Avro Gradle plugin | ||
|
|
||
| ```kotlin | ||
| avro { | ||
| sourceDirectory = "src/main/avro" | ||
| // All properties are available in `GradlePluginExtension.kt` | ||
| } | ||
| ``` | ||
|
|
||
| ### Generate Java classes | ||
|
|
||
| `./gradlew avroGenerateJavaClasses` | ||
|
|
||
|
|
||
| ## Example project that uses the Apache Avro gradle-plugin | ||
| https://codeberg.org/frevib/use-gradle-plugin-test | ||
|
|
||
| ## FAQ | ||
|
|
||
| #### How can I benefit from Kotlin's null safety? | ||
| Use `createNullSafeAnnotations = true` and Java getters will be annotated with | ||
| `@org.jetbrains.annotations.NotNull`/ `@org.jetbrains.annotations.Nullable`. This way | ||
frevib marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Kotlin will recognize which value is nullable. | ||
|
|
||
| #### I get my Avro schemas from a Maven dependency, how can I add JAR files that contain schemas? | ||
| Use `sourceZipFiles = listOf("file_path")`, e.g. | ||
|
|
||
| ```kotlin | ||
| avro { | ||
| sourceZipFiles = listOf("/home/user/.gradle/caches/modules-2/files-2.1/eu.eventloopsoftware.group-id/artifact-id/1.0.0/92ac3d0533de9dd79ac35373c892ebaa01763d4d/jar_with_schemas-1.0.0.jar") | ||
| } | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| kotlin("jvm") version "2.2.10" | ||
| `java-gradle-plugin` | ||
| id("com.gradle.plugin-publish") version "2.0.0" | ||
| } | ||
|
|
||
| group = "eu.eventloopsoftware" | ||
| version = "0.0.9-SNAPSHOT" | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| mavenLocal() | ||
| } | ||
|
|
||
| dependencies { | ||
| // TODO: for release use ${version} | ||
| implementation("org.apache.avro:avro-compiler:1.12.1") | ||
| implementation("org.jetbrains.kotlin:kotlin-gradle-plugin-api:2.3.0") | ||
| testImplementation(kotlin("test")) | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| } | ||
| kotlin { | ||
| jvmToolchain(21) | ||
| } | ||
|
|
||
|
|
||
| gradlePlugin { | ||
| plugins { | ||
| website = "https://avro.apache.org/" | ||
| vcsUrl = "https://github.com/apache/avro.git" | ||
| register("gradlePlugin") { | ||
| id = "eu.eventloopsoftware.avro-gradle-plugin" | ||
| displayName = "Avro Gradle Plugin" | ||
| description = "Avro Gradle plugin for generating Java code" | ||
| tags = listOf("avro", "kotlin", "java", "apache") | ||
| implementationClass = "eu.eventloopsoftware.avro.gradle.plugin.AvroGradlePlugin" | ||
| } | ||
| } | ||
| } |
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
lang/java/gradle-plugin/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip | ||
| networkTimeout=10000 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.