Skip to content

WIP: AVRO-4223 Gradle plugin for generating Java code#3614

Open
frevib wants to merge 88 commits intoapache:mainfrom
frevib:AVRO-4223-gradle-plugin
Open

WIP: AVRO-4223 Gradle plugin for generating Java code#3614
frevib wants to merge 88 commits intoapache:mainfrom
frevib:AVRO-4223-gradle-plugin

Conversation

@frevib
Copy link

@frevib frevib commented Jan 5, 2026

What is the purpose of the change

Gradle plugin to generate Java code from Avro files

Verifying this change

This change added tests and can be verified as follows:

cd to avro/lang/java/gradle-plugin

./gradlew test

Documentation

Release

0.0.2 is released and fully works with AVSC files: https://central.sonatype.com/artifact/eu.eventloopsoftware.avro-gradle-plugin/eu.eventloopsoftware.avro-gradle-plugin.gradle.plugin/versions - read docs (above) how to use

0.0.5 https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin

0.0.8 https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin

0.1.0 https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin - this release adds Protocol support.

Protocol support has been added in this release

Installation instructions: https://github.com/frevib/avro/blob/AVRO-4223-gradle-plugin/lang/java/gradle-plugin/README.md#version

An official release will be done in the coming month

frevib added 16 commits January 11, 2026 09:10
Add classpath in a compile-safe way
Add Maven phase hooks for compiling, testing, building and publishing the Gradle plugin
Improve Javadoc

Add information to warning
Remove unused task property

Rename field
Add Gradle plugin to root POM

Add windows profile
Remove unused file
Template directory is inside the classpath, so it should not be an @get:InputDirectory
Move reusable methods to abstract class
refactor
refactor
Rename
Add Protocol support
Fix tests
Refactor
Refactor
Release 0.1.0
@frevib
Copy link
Author

frevib commented Jan 26, 2026

Avro gradle plugin 0.1.0 is released: https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin

Protocol support has been added in this release

@frevib
Copy link
Author

frevib commented Jan 27, 2026

@raphaelauv did you test the latest release https://plugins.gradle.org/plugin/eu.eventloopsoftware.avro-gradle-plugin? No need to add compileJava.source(avroGenerateJavaClasses) any more.


```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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, we probably want to add some pre-configured configuration, called avroSources or something that way people can add their dependencies as normal, like

dependencies {
    avroSources("eu.eventloopsoftware.group-id:artifact-id:1.0.0") // ...

Certain plugins ship their own dependencies block (like in Gradle's test suites plugin) so perhaps something like

avro {
    sourceZipFiles {
        dependencies {
            avroSources("eu.eventloopsoftware.group-id:artifact-id:1.0.0") // ...

could be used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is possible to add the compile- & runtime dependencies while generating code? Then we wouldn't need any configuration at all.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@opwvhk I'm not quite following? I think the dependencies here was just to allow people to add avro sources that are zipped in jars deployed to a standard maven repo.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, if we at least made sourceZipFiles a ConfigurableFileCollection, then users could configure either via files, or a their own custom configuration.

Copy link
Author

@frevib frevib Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sineaggi you're right, this is to allow ppl to add Avro sources that are in JAR files. Maybe the example with the full path isn't the best one. I've added an example with Configuration. What do think now @Sineaggi ?

Copy link
Contributor

@opwvhk opwvhk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is yet another marked improvement. Thank you!

I have a few open comments, and we'll want to fix the build, but otherwise I'm happy with the result.

<executable>./gradlew</executable>
<arguments>
<argument>assemble</argument>
<argument>-i</argument>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass the Maven log level here? I doubt it, but it would be convenient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which Maven log level? The Maven log level can be passed when this Maven command is run, which in turn runs this Gradle command: ./gradlew assemble -i. Passing a Maven argument here would be on the wrong level, one too deep.

Improve docs on add sources from JAR files
Add license files
Format with Spotless
Add Spotless config
Format
Format
@frevib frevib marked this pull request as ready for review February 2, 2026 15:42
Format
@martin-g
Copy link
Member

martin-g commented Feb 3, 2026

I have created https://issues.apache.org/jira/browse/INFRA-27616 for the requirement from Gradle to prove the ownership of avro.apache.org DNS domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants