Skip to content

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

Open
martin-augment wants to merge 40 commits intomainfrom
pr-3614-2026-01-05-08-09-13
Open

3614: AVRO-4223 Gradle plugin for generating Java code#24
martin-augment wants to merge 40 commits intomainfrom
pr-3614-2026-01-05-08-09-13

Conversation

@martin-augment
Copy link
Copy Markdown
Owner

3614: To review by AI

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 5, 2026

Walkthrough

The change introduces a new Avro Gradle plugin module under lang/java/gradle-plugin/ with complete build infrastructure, source implementation, and tests. The module includes Gradle Kotlin DSL build configuration, wrapper scripts, Maven integration, a Kotlin plugin implementation registering schema compilation tasks, an extension class exposing 24+ configurable properties for code generation, task implementations for schema-to-Java compilation, test Avro schema files in multiple formats (AVSC, AVPR, AVDL), and a test suite. Updates to parent pom.xml files add Gradle-related directory exclusions for license checks and disable spotless formatting for the new module.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.



private fun setCompilerProperties(compiler: SpecificCompiler) {
compiler.setTemplateDir(project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath + "/")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Template directory path handling breaks classpath resources

The templateDirectory default value is /org/apache/avro/compiler/specific/templates/java/classic/, a classpath resource path. However, setCompilerProperties converts it to a project-relative file path using project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath. This transforms the classpath resource into an invalid filesystem path (e.g., /project/path//org/apache/avro/...), causing template loading to fail when using the default. The Maven plugin passes templateDirectory directly to setTemplateDir without this conversion.

Additional Locations (1)

Fix in Cursor Fix in Web

<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Spotless disabled for all Java modules in parent pom

The <skip>true</skip> for spotless-maven-plugin was added to the parent lang/java/pom.xml, which disables code formatting checks for ALL Java modules in the project, not just the gradle-plugin. The gradle-plugin already has its own pom.xml with <skip>true</skip> configured correctly. This change in the parent pom appears accidental and would silently disable an important code quality check across the entire codebase.

Fix in Cursor Fix in Web

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Jan 5, 2026

🤖 Augment PR Summary

Summary: This PR introduces an (in-development) Gradle plugin for generating Java classes from Avro schemas.

Changes:

  • Adds a new Kotlin-based Gradle plugin module under lang/java/gradle-plugin with an avro extension and generation tasks.
  • Implements schema compilation via Avro SchemaParser + SpecificCompiler and registers avroGenerateJavaClasses/avroGenerateTestJavaClasses tasks.
  • Adds Gradle TestKit tests plus representative Avro schema/IDL/protocol fixtures and custom Velocity templates.
  • Includes a Gradle wrapper for the new module and updates lang/java/.gitignore for Gradle outputs.
  • Integrates the module into the Maven build (execs Gradle) and updates RAT exclusions for Gradle-generated directories.
  • Removes doc/package-lock.json from the repository.

Technical Notes: Generated sources are written under the project’s build/ directory, and the plugin attempts to add that generated directory to the Java source sets for compilation.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 6 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.internal.cc.base.logger
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

org.gradle.internal.cc.base.logger is an internal Gradle API, which can break across Gradle versions and makes the plugin less compatible. It’s safer to rely on the public project.logger (also applies to the logger.info(...) usage below).

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

sourceDirectory: String,
outputDirectory: String
) {
val schemaType: SchemaType = SchemaType.valueOf(extension.schemaType.get())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SchemaType.valueOf(extension.schemaType.get()) is case-sensitive and the enum doesn’t include protocol even though the extension docs say it’s valid, so some user configs will fail at configuration time with IllegalArgumentException.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

project.logger.debug("Generated sources directory: ${generatedSourcesDir.get()}")

// Add directory that contains the generated Java files to source set
sourceSets.getByName("main").java.srcDir(generatedSourcesDir)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addGeneratedSourcesToProject always adds generated sources to the main source set, so avroGenerateTestJavaClasses output may be compiled into main artifacts instead of test compilation.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎



private fun setCompilerProperties(compiler: SpecificCompiler) {
compiler.setTemplateDir(project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath + "/")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

templateDirectory is documented (and used in the Maven plugin) as a classpath resource path, but here it’s converted into a project filesystem path; with the default value this likely prevents SpecificCompiler from finding its bundled templates.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎


```kotlin
plugins {
id("eu.eventloopsoftware.avro-gradle-plugin") version "0.0.2"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The README references plugin id eu.eventloopsoftware.avro-gradle-plugin (and version 0.0.2), but this PR defines the plugin id as org.apache.avro.avro-gradle-plugin in gradlePlugin { ... }, which will confuse consumers.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Setting <skip>true</skip> for spotless-maven-plugin at lang/java/pom.xml scope disables Spotless checks for all Java submodules, not just the new Gradle plugin module; please double-check that this broad change is intended.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 15

Fix all issues with AI Agents 🤖
In @lang/java/gradle-plugin/pom.xml:
- Line 56: The pom currently hardcodes the Unix wrapper via the
<executable>./gradlew</executable> element which breaks Windows; replace this by
detecting OS and choosing the correct wrapper: add os-maven-plugin
(os-maven-plugin:detect) to set an OS property and use that property in place of
the hardcoded executable, or switch to using
exec-maven-plugin/gradle-maven-plugin with a property (e.g.
${gradle.wrapper.executable}) that is set to "gradlew.bat" on Windows and
"./gradlew" on Unix; update the <executable> element to reference that property
instead of the literal "./gradlew" so Maven runs the correct wrapper
cross-platform.

In @lang/java/gradle-plugin/README.md:
- Around line 12-16: The README's Gradle snippet uses the wrong plugin id
"eu.eventloopsoftware.avro-gradle-plugin" which doesn't match the
implementation; update the snippet to use the actual plugin id
"org.apache.avro.avro-gradle-plugin" and set the version to the project's actual
version (e.g., replace "0.0.2" with the project version such as
"1.13.0-SNAPSHOT" or whatever version defined in the build configuration) so the
example matches the implemented plugin and will work when applied.
- Around line 19-21: Update the Avro dependency version referenced in the
README: replace the implementation line that currently specifies
org.apache.avro:avro:1.12.1 with the current project version
org.apache.avro:avro:1.13.0 so the documentation matches the plugin's Avro
version.
- Around line 56-57: Update the README section headed "Example project that uses
avro-gradle-plugin" to either mark the external Codeberg link as
community-maintained and subject to change (add a short disclaimer next to the
link) or replace it with an official example inside this repo (e.g., add a
pointer to an example project or documented sample under the avro-gradle-plugin
examples folder). Mention the link text
"https://codeberg.org/frevib/use-gradle-plugin-test" explicitly so reviewers can
find and change that reference, and ensure the new text clarifies maintenance
status or points to the in-repo alternative.

In
@lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/extension/GradlePluginExtension.kt:
- Around line 10-13: The KDoc for the GradlePluginExtension.schemaType property
incorrectly lists "protocol" as a valid value; update the comment to match the
actual supported values defined by the SchemaType enum in GradlePlugin.kt (which
currently has only "schema" and "idl") by removing "protocol" from the quoted
list so the documentation and the SchemaType enum are consistent.
- Around line 99-100: The default templateDirectory Property is a classpath
resource but is being turned into a filesystem path via
project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath;
update setCompilerProperties to pass the templateDirectory value directly to
setTemplateDir() (i.e., call setTemplateDir(templateDirectory.get()) instead of
resolving it against project.layout.projectDirectory) so the Velocity classpath
resource loader can find the bundled templates; ensure you only change the
conversion for the default/unchanged value (templateDirectory) and keep any
user-specified filesystem path handling intact if the code explicitly needs it.

In
@lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/GradlePlugin.kt:
- Line 70: The branch handling SchemaType.idl currently uses TODO() which throws
a NotImplementedError at runtime; replace that with a clear, explicit failure by
throwing a descriptive exception (e.g., IllegalArgumentException or
GradleException) from the SchemaType.idl case in the same when/switch so users
receive a readable message like "IDL schemaType is not supported yet; please use
schemaType X or Y" and include any recommended alternatives or migration steps
in the message.
- Around line 8-9: Replace the use of the internal Gradle API import
org.gradle.internal.cc.base.logger with the public project logger: remove the
internal import and change any calls like logger.info(...) to use
project.logger.info(...); ensure usages in GradlePlugin (e.g., where logger.info
is invoked) now reference project.logger so you rely on the public API.
- Around line 74-81: The method addGeneratedSourcesToProject currently always
adds generated files to the "main" source set; change it to accept a
sourceSetName parameter (defaulting to "main") and use
sourceSets.getByName(sourceSetName).java.srcDir(...) instead of hardcoding
"main"; update call sites (e.g., the existing call using
compileTask.outputDirectory.get()) to pass "main" and add a new call for the
test generator/avroGenerateTestJavaClasses to pass "test" so test-only generated
classes are added to the "test" source set.

In
@lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt:
- Around line 115-123: The getFieldV() method swallows the
IllegalArgumentException when parsing fieldVisibility; update the catch in
getFieldV() to include the caught exception in the logger.warn call (e.g.,
logger.warn("Could not parse field visibility, using PRIVATE", e)) so the
exception stack/ message is recorded while still returning
FieldVisibility.PRIVATE; keep the same behavior of using
fieldVisibility.get().trim().uppercase(...) and returning
FieldVisibility.PRIVATE on failure.

In @lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl:
- Line 20: Update the import statement in AvdlClasspathImport.avdl to reference
the local AVDL file by changing the import idl path from "avro/User.avdl" to
"User.avdl" so it points to the User.avdl that resides in the same directory as
AvdlClasspathImport.avdl.

In @lang/java/gradle-plugin/src/test/avro/multipleSchemas/ApplicationEvent.avsc:
- Around line 26-41: ApplicationEvent.avsc currently embeds an inline record
definition for model.MyResponse that duplicates the external MyResponse.avsc;
remove the inline "MyResponse" object inside the "response" field and change the
field type to a reference to the external record (or, if the test is
intentionally exercising duplicate definitions, add a clarifying comment in the
test explaining that duplication is deliberate). Also replace the empty "doc"
strings in ApplicationEvent.avsc (the file-level and record-level docs and any
empty field docs) with concise meaningful descriptions to improve readability.

In @lang/java/gradle-plugin/src/test/avro/multipleSchemas/README.md:
- Line 7: Replace the grammatical error in the sentence referencing
TestSchema.testParseMultipleFile: change "The is written at
TestSchema.testParseMultipleFile." to a correct phrasing such as "This is
written in TestSchema.testParseMultipleFile." or "The test is written in
TestSchema.testParseMultipleFile." to restore proper grammar and clarity.

In @lang/java/pom.xml:
- Line 337: The parent POM has a Spotless <skip>true</skip> entry that
unintentionally disables formatting for all Java submodules; remove the
<skip>true</skip> element from lang/java/pom.xml so only
lang/java/gradle-plugin/pom.xml controls skipping, or alternatively move/retain
the <skip>true</skip> solely in gradle-plugin/pom.xml and ensure other modules
(avro, compiler, tools, mapred, etc.) do not inherit the skip by not including a
parent-level spotless skip setting.
🧹 Nitpick comments (20)
lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl (1)

22-23: Clarify the purpose of "Ignored Doc Comment".

The comment /** Ignored Doc Comment */ followed by /** IDL User */ may be testing Avro IDL's behavior where only the last doc comment is used. However, this could be confusing for developers reviewing the code. Consider adding an inline comment explaining the test intention.

🔎 Suggested clarification
+// Testing that only the last doc comment is used
 /** Ignored Doc Comment */
 /** IDL User */
 record IdlUserWrapper {
lang/java/gradle-plugin/src/test/avro/User.avdl (1)

18-19: Consider consistent namespace declaration style.

This file uses @namespace("test") while AvdlClasspathImport.avdl uses namespace test;. Both are valid Avro IDL syntax, but consistent style across test files improves readability.

lang/java/gradle-plugin/src/test/avro/multipleSchemas/MyResponse.avsc (1)

4-4: Consider adding meaningful documentation or omitting the empty doc field.

The empty "doc": "" field doesn't provide value. Consider either adding a description of the MyResponse record or omitting the doc field entirely.

lang/java/gradle-plugin/src/test/avro/multipleSchemas/DocumentInfo.avsc (1)

4-4: Consider adding meaningful documentation.

The record-level doc field is empty. While acceptable for test files, adding a brief description would improve schema documentation.

🔎 Suggested improvement
-  "doc": "",
+  "doc": "Represents document information including ID and file path",
lang/java/gradle-plugin/build.gradle.kts (2)

33-37: Remove commented-out dependency.

The commented-out gradle-tooling-api dependency is dead code. If it's no longer needed, remove it to keep the build file clean.

🔎 Proposed fix
 dependencies {
-    //implementation("org.gradle:gradle-tooling-api:7.1.1")
     implementation("org.apache.avro:avro-compiler:${version}")
     testImplementation(kotlin("test"))
 }

51-58: Consider simplifying the plugin ID.

The plugin ID org.apache.avro.avro-gradle-plugin has redundant "avro" in the suffix. Consider org.apache.avro.gradle-plugin or org.apache.avro.codegen for a cleaner identifier.

lang/java/gradle-plugin/src/test/avro/multipleSchemas/ApplicationEvent.avsc (1)

4-5: Consider adding meaningful documentation.

Empty "doc": "" strings provide no value. Either add meaningful documentation or remove the doc field entirely to reduce noise.

lang/java/gradle-plugin/gradle/wrapper/gradle-wrapper.properties (1)

1-7: Consider updating to Gradle 9.x series.

The wrapper properties are well-configured with validateDistributionUrl=true for security and reasonable timeout settings. However, Gradle 8.14 is outdated—Gradle 9.2.1 is currently the latest stable release (released November 2025). Consider updating to Gradle 9.x to benefit from the latest features, performance improvements, and security updates.

lang/java/gradle-plugin/src/test/kotlin/org/apache/avro/gradle/plugin/SchemaCompileTaskTest.kt (2)

13-14: Consider @OptIn instead of @ExperimentalPathApi for opt-in annotations.

Using @OptIn(ExperimentalPathApi::class) is the recommended pattern for experimental APIs in Kotlin, as it makes the opt-in more explicit and is the newer approach.

🔎 Suggested change
-@ExperimentalPathApi
+@OptIn(ExperimentalPathApi::class)
 class SchemaCompileTaskTest {

140-141: Remove commented-out debug code.

This appears to be leftover debug code that should be cleaned up before merging.

🔎 Suggested fix
-        //val bla = tempDir.resolve("src/aap").createDirectories()
         val tempVelocityToolClassesDir = tempDir.resolve("src/test/resources/templates").createDirectories()
lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/GradlePlugin.kt (2)

20-30: Task configuration is eager; consider using configure or lazy configuration.

The register block runs at configuration time for all tasks. While acceptable for now, using project.tasks.register(...).configure { } or lazy property wiring would defer configuration until the task is actually needed, improving build performance.


49-49: Includes pattern is hardcoded to "**/*.avsc".

Consider making the includes pattern configurable via the extension for flexibility with different file naming conventions.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/AbstractCompileTask.kt (4)

3-3: Unused import.

DefaultTask is imported but not used since the class extends SourceTask.

🔎 Suggested fix
-import org.gradle.api.DefaultTask

11-15: Consider using @InputDirectory and @OutputDirectory annotations for proper incremental build support.

Using @Input for directory paths means Gradle tracks only the string value, not the directory contents. For proper up-to-date checking and caching, consider using DirectoryProperty with @InputDirectory/@OutputDirectory annotations.

Note: This would require changing from Property<String> to DirectoryProperty and adjusting how paths are resolved.


20-21: Remove or implement the commented-out excludes property.

Commented-out code should either be implemented or removed to keep the codebase clean.

🔎 Suggested fix
-    //@get:Input
-    //abstract val excludes: ListProperty<String>
-

29-33: Consider adding @Optional to properties with sensible defaults.

Properties like velocityToolsClassesNames and templateDirectory have defaults in the extension. Adding @Optional would make the task more flexible and avoid issues if the extension properties aren't set.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt (4)

25-26: Remove commented-out code.

The commented includes property should be removed or implemented.

🔎 Suggested fix
-    /**
-     * A set of Glob patterns used to select files from the source
-     * directory for processing. By default, the pattern "**&#47;*.avsc"
-     * is used to select avsc files.
-     *
-     * @parameter
-     */
-    //@get:Input
-    //val includes: Set<String> = setOf("**/*.avsc")
-

96-97: Template directory path construction may be fragile.

Appending "/" to the path assumes specific behavior. Consider using File.separator or ensuring the path is normalized to avoid double slashes or platform issues.

🔎 Suggested fix
-        compiler.setTemplateDir(project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath + "/")
+        val templateDirPath = project.layout.projectDirectory.dir(templateDirectory.get()).asFile.absolutePath
+        compiler.setTemplateDir(if (templateDirPath.endsWith(File.separator)) templateDirPath else templateDirPath + File.separator)

82-84: customLogicalTypeFactories is declared but not used.

The TODO indicates this feature is incomplete. Consider either implementing it or removing the property to avoid user confusion.

Would you like me to help implement the customLogicalTypeFactories integration, or should this be tracked as a follow-up issue?


125-135: Consider making instantiateAdditionalVelocityTools private.

The method is protected but the class is not open, so it cannot be overridden. Making it private would clarify intent.

🔎 Suggested fix
-    protected fun instantiateAdditionalVelocityTools(velocityToolsClassesNames: List<String>): List<Any> {
+    private fun instantiateAdditionalVelocityTools(velocityToolsClassesNames: List<String>): List<Any> {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0596c55 and a989843.

⛔ Files ignored due to path filters (2)
  • doc/package-lock.json is excluded by !**/package-lock.json
  • lang/java/gradle-plugin/gradle/wrapper/gradle-wrapper.jar is excluded by !**/*.jar
📒 Files selected for processing (30)
  • lang/java/.gitignore
  • lang/java/gradle-plugin/README.md
  • lang/java/gradle-plugin/build.gradle.kts
  • lang/java/gradle-plugin/gradle/wrapper/gradle-wrapper.properties
  • lang/java/gradle-plugin/gradlew
  • lang/java/gradle-plugin/gradlew.bat
  • lang/java/gradle-plugin/pom.xml
  • lang/java/gradle-plugin/settings.gradle.kts
  • lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/GradlePlugin.kt
  • lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/extension/GradlePluginExtension.kt
  • lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/AbstractCompileTask.kt
  • lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt
  • lang/java/gradle-plugin/src/main/resources/META-INF/org.apache.avro.gradle.plugin.properties
  • lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl
  • lang/java/gradle-plugin/src/test/avro/User.avdl
  • lang/java/gradle-plugin/src/test/avro/User.avpr
  • lang/java/gradle-plugin/src/test/avro/User.avsc
  • lang/java/gradle-plugin/src/test/avro/directImport/PrivacyDirectImport.avsc
  • lang/java/gradle-plugin/src/test/avro/extends/Custom.avsc
  • lang/java/gradle-plugin/src/test/avro/imports/PrivacyImport.avsc
  • lang/java/gradle-plugin/src/test/avro/multipleSchemas/ApplicationEvent.avsc
  • lang/java/gradle-plugin/src/test/avro/multipleSchemas/DocumentInfo.avsc
  • lang/java/gradle-plugin/src/test/avro/multipleSchemas/MyResponse.avsc
  • lang/java/gradle-plugin/src/test/avro/multipleSchemas/README.md
  • lang/java/gradle-plugin/src/test/kotlin/org/apache/avro/gradle/plugin/SchemaCompileTaskTest.kt
  • lang/java/gradle-plugin/src/test/resources/templates/enum.vm
  • lang/java/gradle-plugin/src/test/resources/templates/protocol.vm
  • lang/java/gradle-plugin/src/test/resources/templates/record.vm
  • lang/java/pom.xml
  • pom.xml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-04T08:10:05.166Z
Learnt from: martin-augment
Repo: martin-augment/avro PR: 16
File: pom.xml:228-228
Timestamp: 2025-11-04T08:10:05.166Z
Learning: Apache Avro has a conservative development approach regarding Java version upgrades due to its widespread use in old codebases. Major version bumps (e.g., Java 11 to 17) should be discussed on the mailing lists (devavro.apache.org) before proceeding, even when technically required by dependency updates.

Applied to files:

  • lang/java/gradle-plugin/build.gradle.kts
🪛 detekt (1.23.8)
lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt

[warning] 119-119: The caught exception is swallowed. The original exception could be lost.

(detekt.exceptions.SwallowedException)

🔇 Additional comments (30)
lang/java/gradle-plugin/src/test/avro/User.avpr (1)

31-37: Verify that modifiedOn is intentionally required and non-nullable.

Unlike the other fields (id, createdOn, privacy), the modifiedOn field is defined as a required, non-nullable long without a default value. This means any instance of ProtocolUser must provide a value for modifiedOn, whereas the other fields can be null.

If this inconsistency is intentional to test both nullable and required field scenarios, this is fine. However, if all fields should be nullable, the type should be changed to a union like ["null", {"type": "long", "logicalType": "timestamp-millis"}] with a default of null.

🔎 Proposed fix if modifiedOn should be nullable
       {
         "name": "modifiedOn",
-        "type": {
-          "type": "long",
-          "logicalType": "timestamp-millis"
-        }
+        "type": ["null", {
+          "type": "long",
+          "logicalType": "timestamp-millis"
+        }],
+        "default": null
       }
lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl (1)

1-17: LGTM!

The Apache License header is properly formatted and complete.

lang/java/gradle-plugin/src/test/avro/User.avdl (2)

1-17: LGTM!

The Apache License header is properly formatted and complete.


21-30: LGTM!

The enum and record definitions are well-structured. The use of union types for nullable fields and the timestamp_ms logical type follows Avro IDL best practices.

lang/java/gradle-plugin/src/test/avro/multipleSchemas/MyResponse.avsc (1)

1-14: LGTM!

The Avro schema structure is valid and correctly defines a record type with appropriate field-level documentation.

lang/java/gradle-plugin/src/test/avro/directImport/PrivacyDirectImport.avsc (1)

1-7: LGTM!

The Avro enum schema is well-structured with proper documentation and clearly defined symbols.

lang/java/gradle-plugin/src/test/resources/templates/enum.vm (1)

1-19: LGTM!

The placeholder template file is appropriately documented. The comment clearly explains that the file must exist for testing purposes even though it currently has no content.

lang/java/.gitignore (1)

23-25: LGTM!

The ignore patterns are appropriate for the new Gradle plugin module and follow standard Gradle project conventions.

lang/java/gradle-plugin/src/main/resources/META-INF/org.apache.avro.gradle.plugin.properties (1)

1-1: The implementation class path org.apache.avro.gradle.plugin.GradlePlugin is correct. The class exists at lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/GradlePlugin.kt with the matching package declaration and properly implements Plugin<Project> from the Gradle API.

pom.xml (1)

527-529: LGTM! Appropriate exclusions for Gradle artifacts.

The RAT exclusions for Gradle-related directories (.gradle, gradle/, and build/) follow the established pattern in this configuration and correctly prevent license checks on generated build artifacts.

lang/java/gradle-plugin/src/test/avro/extends/Custom.avsc (1)

1-18: LGTM! Valid Avro test schema.

The schema definition is syntactically correct with proper record structure, namespace declaration, and nullable field types using union syntax.

lang/java/gradle-plugin/src/test/resources/templates/protocol.vm (1)

1-19: LGTM!

The placeholder template is appropriately documented and serves its purpose as a required test resource.

lang/java/gradle-plugin/src/test/resources/templates/record.vm (1)

1-21: LGTM!

The test template correctly demonstrates Velocity template processing with a simple string concatenation expression.

lang/java/gradle-plugin/src/test/avro/imports/PrivacyImport.avsc (1)

1-7: LGTM!

The Avro enum schema is well-formed with all required fields present and proper JSON syntax.

lang/java/gradle-plugin/pom.xml (1)

23-28: Parent POM relativePath is correct.

The ../pom.xml reference correctly points to lang/java/pom.xml, which contains the avro-parent artifact.

lang/java/gradle-plugin/settings.gradle.kts (1)

19-25: LGTM! Proper settings configuration for the plugin project.

The foojay-resolver-convention plugin enables automatic JDK toolchain resolution, which aligns well with the Java 17 toolchain requirement in build.gradle.kts.

lang/java/gradle-plugin/src/test/avro/User.avsc (1)

1-45: LGTM! Comprehensive test schema with good coverage of Avro features.

The schema effectively tests:

  • Union types with null defaults
  • Inline enum definitions
  • Imported types from other schema files
  • Logical types (timestamp-millis)

This provides good test coverage for the schema compilation task.

lang/java/gradle-plugin/gradlew.bat (1)

1-94: LGTM! Standard Gradle wrapper batch script.

This is a standard Gradle-generated Windows wrapper script with proper error handling for missing Java installations and environment variable propagation.

lang/java/gradle-plugin/gradlew (1)

1-251: LGTM! Standard Gradle wrapper POSIX script.

This is a standard Gradle-generated wrapper script with comprehensive platform detection (Cygwin, MSYS, Darwin, NonStop) and proper POSIX shell compatibility. No issues identified.

lang/java/gradle-plugin/build.gradle.kts (1)

19-23: Kotlin 2.2.10 is released and available.

This version was released on August 14, 2025, and is available on the Gradle Plugin Portal.

lang/java/gradle-plugin/src/test/kotlin/org/apache/avro/gradle/plugin/SchemaCompileTaskTest.kt (5)

19-74: Test coverage looks good for the main task execution path.

The test sets up a realistic project structure, executes the Gradle task, and verifies both task outcome and generated file content (checking for java.time.Instant). The assertions cover the essential success criteria.


77-132: Good coverage for test source directory configuration.

This test validates the separate testSourceDirectory/testOutputDirectory configuration path with the avroGenerateTestJavaClasses task.


134-200: Velocity template customization test is well-structured.

The test properly sets up custom templates and velocity tools, then verifies the template-driven output contains expected content.


202-257: Good test for custom recordSpecificClass inheritance.

The test validates that generated classes extend the custom base class rather than the default SpecificRecordBase. The line-by-line verification is thorough.


260-269: Generated files are placed flat in the output directory, not in nested package subdirectories.

The assertFilesExist implementation is correct for the actual test structure. All test cases expect flat filenames ("SchemaPrivacy.java", "SchemaUser.java", etc.), and subsequent test code accesses these files directly from the root of testOutPutDirectory without nesting. While Avro schemas define namespaces (like test and model), these do not translate to directory structure in this gradle plugin's output configuration.

Likely an incorrect or invalid review comment.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/GradlePlugin.kt (1)

84-87: Enum values follow Kotlin conventions appropriately.

The enum values are lowercase to match the expected string values from user configuration.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/AbstractCompileTask.kt (1)

9-70: Good abstraction for shared task properties.

The abstract base class cleanly separates the shared configuration properties from the concrete task implementation. The property declarations are well-documented in the extension.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt (2)

28-41: Task action implementation is well-structured.

The task action properly validates input, logs progress, and delegates to helper methods. The empty source check with a warning is a reasonable approach.


50-74: Schema compilation logic is sound.

The use of SchemaParser to collect all schemas before compilation handles cross-file dependencies correctly. Exception handling preserves context with source/output directory information.

lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/extension/GradlePluginExtension.kt (1)

8-225: Comprehensive and well-documented extension configuration.

The extension provides a complete set of configurable properties with sensible defaults and good documentation. The property conventions follow Gradle best practices.

<goal>exec</goal>
</goals>
<configuration>
<executable>./gradlew</executable>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Platform-specific executable breaks Windows builds.

The ./gradlew executable is Unix-specific and will fail on Windows, which requires gradlew.bat. This breaks cross-platform compatibility for Maven builds.

🔎 Consider using os-maven-plugin for cross-platform execution

Add the os-maven-plugin to detect the OS and use the correct wrapper:

+      <plugin>
+        <groupId>kr.motd.maven</groupId>
+        <artifactId>os-maven-plugin</artifactId>
+        <version>1.7.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>detect</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
         <version>3.1.0</version>

         <executions>
           <execution>
             <id>run-gradle-task</id>
             <phase>package</phase>
             <goals>
               <goal>exec</goal>
             </goals>
             <configuration>
-              <executable>./gradlew</executable>
+              <executable>${os.detected.name.startsWith('windows') ? 'gradlew.bat' : './gradlew'}</executable>
               <arguments>
                 <argument>assemble</argument>
               </arguments>
             </configuration>
           </execution>
         </executions>
       </plugin>

Alternatively, use the Gradle Maven Plugin or invoke the wrapper via shell with OS detection.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/pom.xml around line 56, The pom currently hardcodes
the Unix wrapper via the <executable>./gradlew</executable> element which breaks
Windows; replace this by detecting OS and choosing the correct wrapper: add
os-maven-plugin (os-maven-plugin:detect) to set an OS property and use that
property in place of the hardcoded executable, or switch to using
exec-maven-plugin/gradle-maven-plugin with a property (e.g.
${gradle.wrapper.executable}) that is set to "gradlew.bat" on Windows and
"./gradlew" on Unix; update the <executable> element to reference that property
instead of the literal "./gradlew" so Maven runs the correct wrapper
cross-platform.

Comment on lines +12 to +16
```kotlin
plugins {
id("eu.eventloopsoftware.avro-gradle-plugin") version "0.0.2"
}
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Plugin ID doesn't match the implementation.

The README references plugin ID eu.eventloopsoftware.avro-gradle-plugin, but the AI summary and build.gradle.kts implementation define the plugin as org.apache.avro.avro-gradle-plugin. This makes the usage instructions incorrect and non-functional.

🔎 Proposed fix
 ```kotlin
 plugins {
-    id("eu.eventloopsoftware.avro-gradle-plugin") version "0.0.2"
+    id("org.apache.avro.avro-gradle-plugin") version "1.13.0-SNAPSHOT"
 }

Also verify and update the version to match the project version.
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion

🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/README.md around lines 12-16, The README's Gradle
snippet uses the wrong plugin id "eu.eventloopsoftware.avro-gradle-plugin" which
doesn't match the implementation; update the snippet to use the actual plugin id
"org.apache.avro.avro-gradle-plugin" and set the version to the project's actual
version (e.g., replace "0.0.2" with the project version such as
"1.13.0-SNAPSHOT" or whatever version defined in the build configuration) so the
example matches the implemented plugin and will work when applied.

Comment on lines +19 to +21
```kotlin
implementation("org.apache.avro:avro:1.12.1")
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Update Avro version to match project version.

The README references Avro version 1.12.1, but this plugin is part of Avro 1.13.0-SNAPSHOT. Update the documentation to reference the current project version for consistency.

🔎 Proposed fix
 Add Avro dependency

 ```kotlin
-implementation("org.apache.avro:avro:1.12.1")
+implementation("org.apache.avro:avro:1.13.0")
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion

🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/README.md around lines 19-21, Update the Avro
dependency version referenced in the README: replace the implementation line
that currently specifies org.apache.avro:avro:1.12.1 with the current project
version org.apache.avro:avro:1.13.0 so the documentation matches the plugin's
Avro version.

Comment on lines +56 to +57
## Example project that uses avro-gradle-plugin
https://codeberg.org/frevib/use-gradle-plugin-test
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Codeberg frevib use-gradle-plugin-test repository Apache Avro

💡 Result:

I attempted to look up the Codeberg repo but codeberg.org is blocked by robots.txt so I can't fetch it. [1]

I did find related work by the same author on GitHub — a gradle-plugin branch and PR for Apache Avro (frevib/avro). If you want info about the Avro Gradle plugin or that repo I can fetch and summarize it (GitHub results shown below). [2]

Sources:

  • codeberg.org blocked by robots.txt (access failure). [1]
  • frevib/avro (Gradle plugin branch / PR on GitHub). [2]

What would you like me to do next?
(Options: 1) Try GitHub frevib/avro and summarize the gradle-plugin, 2) Give instructions how to test a local Gradle plugin with Avro, 3) you can paste the Codeberg repo URL or files for me to inspect.)


🏁 Script executed:

# Check if there are other example projects referenced in the codebase
find . -name "*.md" -o -name "*.txt" | xargs grep -l "example\|Example" | head -20

Repository: martin-augment/avro

Length of output: 5832


🏁 Script executed:

# Look at the full context of the README to understand the purpose of this link
cd lang/java/gradle-plugin
head -70 README.md | tail -20

Repository: martin-augment/avro

Length of output: 445


🏁 Script executed:

# Check if there's an examples directory in the Apache Avro repository
git ls-files | grep -i example | head -20

Repository: martin-augment/avro

Length of output: 913


Label external example or provide an official alternative.

The README links to a non-Apache external resource (codeberg.org/frevib/use-gradle-plugin-test) that cannot be verified as actively maintained. Either include a disclaimer clearly marking it as community-maintained and subject to change, or provide an example within the Apache Avro repository.

🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/README.md around lines 56-57, Update the README
section headed "Example project that uses avro-gradle-plugin" to either mark the
external Codeberg link as community-maintained and subject to change (add a
short disclaimer next to the link) or replace it with an official example inside
this repo (e.g., add a pointer to an example project or documented sample under
the avro-gradle-plugin examples folder). Mention the link text
"https://codeberg.org/frevib/use-gradle-plugin-test" explicitly so reviewers can
find and change that reference, and ensure the new text clarifies maintenance
status or points to the in-repo alternative.

Comment on lines +10 to +13
/**
* Schema type: "schema", "idl", "protocol" are valid. Default is "schema"
*/
val schemaType = objects.property(String::class.java).convention("schema")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Documentation mentions "protocol" but SchemaType enum only supports "schema" and "idl".

The KDoc states "schema", "idl", "protocol" are valid, but the SchemaType enum in GradlePlugin.kt only defines schema and idl. Update the documentation to match the actual supported values.

🔎 Suggested fix
     /**
-     * Schema type: "schema", "idl", "protocol" are valid. Default is "schema"
+     * Schema type: "schema" or "idl". Default is "schema"
      */
     val schemaType = objects.property(String::class.java).convention("schema")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Schema type: "schema", "idl", "protocol" are valid. Default is "schema"
*/
val schemaType = objects.property(String::class.java).convention("schema")
/**
* Schema type: "schema" or "idl". Default is "schema"
*/
val schemaType = objects.property(String::class.java).convention("schema")
🤖 Prompt for AI Agents
In
@lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/extension/GradlePluginExtension.kt
around lines 10-13, The KDoc for the GradlePluginExtension.schemaType property
incorrectly lists "protocol" as a valid value; update the comment to match the
actual supported values defined by the SchemaType enum in GradlePlugin.kt (which
currently has only "schema" and "idl") by removing "protocol" from the quoted
list so the documentation and the SchemaType enum are consistent.

Comment on lines +115 to +123
private fun getFieldV(): FieldVisibility {
try {
val upperCaseFieldVisibility = fieldVisibility.get().trim().uppercase(Locale.getDefault())
return FieldVisibility.valueOf(upperCaseFieldVisibility)
} catch (e: IllegalArgumentException) {
logger.warn("Could not parse field visibility, using PRIVATE")
return FieldVisibility.PRIVATE
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Exception is swallowed; include the exception in the warning log.

Per the static analysis hint, the caught IllegalArgumentException should be logged to aid debugging when field visibility parsing fails.

🔎 Suggested fix
     private fun getFieldV(): FieldVisibility {
         try {
             val upperCaseFieldVisibility = fieldVisibility.get().trim().uppercase(Locale.getDefault())
             return FieldVisibility.valueOf(upperCaseFieldVisibility)
         } catch (e: IllegalArgumentException) {
-            logger.warn("Could not parse field visibility, using PRIVATE")
+            logger.warn("Could not parse field visibility '${fieldVisibility.get()}', using PRIVATE", e)
             return FieldVisibility.PRIVATE
         }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private fun getFieldV(): FieldVisibility {
try {
val upperCaseFieldVisibility = fieldVisibility.get().trim().uppercase(Locale.getDefault())
return FieldVisibility.valueOf(upperCaseFieldVisibility)
} catch (e: IllegalArgumentException) {
logger.warn("Could not parse field visibility, using PRIVATE")
return FieldVisibility.PRIVATE
}
}
private fun getFieldV(): FieldVisibility {
try {
val upperCaseFieldVisibility = fieldVisibility.get().trim().uppercase(Locale.getDefault())
return FieldVisibility.valueOf(upperCaseFieldVisibility)
} catch (e: IllegalArgumentException) {
logger.warn("Could not parse field visibility '${fieldVisibility.get()}', using PRIVATE", e)
return FieldVisibility.PRIVATE
}
}
🧰 Tools
🪛 detekt (1.23.8)

[warning] 119-119: The caught exception is swallowed. The original exception could be lost.

(detekt.exceptions.SwallowedException)

🤖 Prompt for AI Agents
In
@lang/java/gradle-plugin/src/main/kotlin/org/apache/avro/gradle/plugin/tasks/CompileSchemaTask.kt
around lines 115-123, The getFieldV() method swallows the
IllegalArgumentException when parsing fieldVisibility; update the catch in
getFieldV() to include the caught exception in the logger.warn call (e.g.,
logger.warn("Could not parse field visibility, using PRIVATE", e)) so the
exception stack/ message is recorded while still returning
FieldVisibility.PRIVATE; keep the same behavior of using
fieldVisibility.get().trim().uppercase(...) and returning
FieldVisibility.PRIVATE on failure.

*/
namespace test;

import idl "avro/User.avdl";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find User.avdl files
echo "=== Finding User.avdl files ==="
fd -t f "User.avdl" lang/java/gradle-plugin/src/test/

# Check directory structure under src/test/avro
echo ""
echo "=== Directory structure under src/test/avro ==="
find lang/java/gradle-plugin/src/test/avro/ -type f -o -type d | sort

# Look at the AvdlClasspathImport.avdl file
echo ""
echo "=== Content of AvdlClasspathImport.avdl ==="
cat -n lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl

Repository: martin-augment/avro

Length of output: 2305


🏁 Script executed:

#!/bin/bash
# Search for references to AvdlClasspathImport in test code
echo "=== Searching for references to AvdlClasspathImport ==="
rg "AvdlClasspathImport" lang/java/gradle-plugin/

# Check gradle build file for classpath/resource configurations
echo ""
echo "=== Gradle build configuration ==="
find lang/java/gradle-plugin -name "build.gradle*" -o -name "build.gradle.kts" | head -5

# Look at the gradle build file to see resource handling
if [ -f "lang/java/gradle-plugin/build.gradle.kts" ]; then
  echo ""
  echo "=== Content of build.gradle.kts (first 100 lines) ==="
  head -100 lang/java/gradle-plugin/build.gradle.kts
fi

Repository: martin-augment/avro

Length of output: 1756


🏁 Script executed:

#!/bin/bash
# Search across entire repo for AvdlClasspathImport
echo "=== Searching entire repo for AvdlClasspathImport ==="
rg "AvdlClasspathImport" --type avdl --type java

# Search for test resource setup or classpath configuration
echo ""
echo "=== Searching for test resource or classpath setup ==="
rg "src/test/avro" lang/java/gradle-plugin/

# Look for how AVDL imports are handled in the compiler
echo ""
echo "=== Searching for AVDL import handling ==="
rg "import idl" --type avdl | head -20

# Check if avro/ appears as a classpath prefix elsewhere
echo ""
echo "=== Looking for other avro/ import patterns ==="
rg 'import idl.*"avro/' --type avdl

Repository: martin-augment/avro

Length of output: 2065


🏁 Script executed:

#!/bin/bash
# Search for .avdl files and their content without file type filters
echo "=== All .avdl files in the repository ==="
find lang/java -name "*.avdl" -type f

# Look at imports in all AVDL files
echo ""
echo "=== Import statements in all .avdl files ==="
find lang/java -name "*.avdl" -type f -exec grep -H "import" {} \;

# Search for how the compiler handles classpath imports
echo ""
echo "=== Looking for classpath import handling in compiler ==="
rg "classpath.*import" lang/java/ | head -10

# Check the test file that references src/test/avro
echo ""
echo "=== SchemaCompileTaskTest references ==="
grep -n "AvdlClasspathImport\|avro/User" lang/java/gradle-plugin/src/test/kotlin/org/apache/avro/gradle/plugin/SchemaCompileTaskTest.kt

Repository: martin-augment/avro

Length of output: 7323


🏁 Script executed:

#!/bin/bash
# Check for test setup in maven-plugin
echo "=== Maven-plugin test setup files ==="
find lang/java/maven-plugin/src/test -type f \( -name "*.java" -o -name "*.kt" \) | head -20

# Look at maven-plugin test code to see how AvdlClasspathImport is used
echo ""
echo "=== Searching for test classes that might use AvdlClasspathImport ==="
rg "User\.avdl\|AvdlClasspathImport" lang/java/maven-plugin/src/test/ -A 3 -B 3

# Check if there's a test resource folder setup
echo ""
echo "=== Maven-plugin src/test structure ==="
find lang/java/maven-plugin/src/test -type d | sort

# Look for classpath configuration in gradle-plugin tests
echo ""
echo "=== SchemaCompileTaskTest file content ==="
cat lang/java/gradle-plugin/src/test/kotlin/org/apache/avro/gradle/plugin/SchemaCompileTaskTest.kt | head -150

Repository: martin-augment/avro

Length of output: 7118


Fix incorrect import path in AvdlClasspathImport.avdl.

The import path "avro/User.avdl" is incorrect. User.avdl is located at src/test/avro/User.avdl (same directory as AvdlClasspathImport.avdl), not at src/test/avro/avro/User.avdl. Change the import to:

import idl "User.avdl";
🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/src/test/avro/AvdlClasspathImport.avdl around line
20, Update the import statement in AvdlClasspathImport.avdl to reference the
local AVDL file by changing the import idl path from "avro/User.avdl" to
"User.avdl" so it points to the User.avdl that resides in the same directory as
AvdlClasspathImport.avdl.

Comment on lines +26 to +41
{
"name": "response",
"type": {
"namespace": "model",
"type": "record",
"doc": "",
"name": "MyResponse",
"fields": [
{
"name": "isSuccessful",
"type": "boolean",
"doc": "Indicator for successful or unsuccessful call"
}
]
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if MyResponse.avsc exists
fd -t f "MyResponse.avsc" lang/java/gradle-plugin/src/test/avro

Repository: martin-augment/avro

Length of output: 132


🏁 Script executed:

#!/bin/bash
# Read the external MyResponse.avsc file
echo "=== External MyResponse.avsc ==="
cat -n lang/java/gradle-plugin/src/test/avro/multipleSchemas/MyResponse.avsc

echo -e "\n=== ApplicationEvent.avsc (lines 26-41 with context) ==="
cat -n lang/java/gradle-plugin/src/test/avro/multipleSchemas/ApplicationEvent.avsc | sed -n '20,45p'

Repository: martin-augment/avro

Length of output: 1139


Remove redundant inline MyResponse definition or clarify test intent.

The MyResponse record is defined identically in both the external MyResponse.avsc file and inline in ApplicationEvent.avsc (lines 26-41). Both define model.MyResponse with the same fields and structure, creating a duplicate type definition. Either remove the inline definition and reference the external MyResponse.avsc file instead, or document if this duplication is intentional for testing multi-schema parsing behavior.

Additionally, the empty doc strings (lines 4, 23, 31) in ApplicationEvent.avsc should be replaced with meaningful documentation.

🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/src/test/avro/multipleSchemas/ApplicationEvent.avsc
around lines 26-41, ApplicationEvent.avsc currently embeds an inline record
definition for model.MyResponse that duplicates the external MyResponse.avsc;
remove the inline "MyResponse" object inside the "response" field and change the
field type to a reference to the external record (or, if the test is
intentionally exercising duplicate definitions, add a clarifying comment in the
test explaining that duplication is deliberate). Also replace the empty "doc"
strings in ApplicationEvent.avsc (the file-level and record-level docs and any
empty field docs) with concise meaningful descriptions to improve readability.

The objective is to check that a record schema define in a file can be use in another record schema as a field type.
Here, ApplicationEvent.avsc file contains a field of type DocumentInfo, defined in file DocumentInfo.avsc.

The is written at TestSchema.testParseMultipleFile.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix grammatical error in documentation.

The sentence is missing a word.

🔎 Proposed fix
-The is written at TestSchema.testParseMultipleFile.
+The test is written at TestSchema.testParseMultipleFile.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The is written at TestSchema.testParseMultipleFile.
The test is written at TestSchema.testParseMultipleFile.
🤖 Prompt for AI Agents
In @lang/java/gradle-plugin/src/test/avro/multipleSchemas/README.md around line
7, Replace the grammatical error in the sentence referencing
TestSchema.testParseMultipleFile: change "The is written at
TestSchema.testParseMultipleFile." to a correct phrasing such as "This is
written in TestSchema.testParseMultipleFile." or "The test is written in
TestSchema.testParseMultipleFile." to restore proper grammar and clarity.

<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if gradle-plugin has its own pom.xml and verify spotless configuration

echo "=== Checking gradle-plugin pom.xml ==="
fd -t f "^pom.xml$" lang/java/gradle-plugin

echo ""
echo "=== Spotless configuration in gradle-plugin/pom.xml ==="
if [ -f "lang/java/gradle-plugin/pom.xml" ]; then
  rg -A 10 "spotless-maven-plugin" lang/java/gradle-plugin/pom.xml || echo "No spotless configuration found"
fi

echo ""
echo "=== Checking parent pom.xml structure for plugin configuration ==="
rg -B 5 -A 5 "spotless-maven-plugin" lang/java/pom.xml | head -50

Repository: martin-augment/avro

Length of output: 1826


🏁 Script executed:

#!/bin/bash
# Check spotless configuration in other Java submodules

echo "=== Java submodules in lang/java ==="
fd -type d -maxdepth 1 "^[^.]" lang/java | sort

echo ""
echo "=== Spotless configurations in Java submodules ==="
for dir in lang/java/*/; do
  module=$(basename "$dir")
  if [ -f "$dir/pom.xml" ]; then
    if rg "spotless-maven-plugin" "$dir/pom.xml" -q; then
      echo "Module: $module"
      rg -A 3 "spotless-maven-plugin" "$dir/pom.xml"
      echo ""
    fi
  fi
done

Repository: martin-augment/avro

Length of output: 494


The spotless skip configuration at the parent level affects all Java modules, not just gradle-plugin.

The gradle-plugin module already has its own pom.xml with spotless configured to <skip>true</skip>. Adding this same configuration at the parent lang/java/pom.xml level causes all other Java submodules (avro, compiler, tools, mapred, etc.) to inherit this skip setting unless they explicitly override it.

If the intent is to disable Spotless only for gradle-plugin, the configuration should remain in lang/java/gradle-plugin/pom.xml and removed from the parent to avoid disabling formatting checks across the entire Java codebase.

🤖 Prompt for AI Agents
In @lang/java/pom.xml around line 337, The parent POM has a Spotless
<skip>true</skip> entry that unintentionally disables formatting for all Java
submodules; remove the <skip>true</skip> element from lang/java/pom.xml so only
lang/java/gradle-plugin/pom.xml controls skipping, or alternatively move/retain
the <skip>true</skip> solely in gradle-plugin/pom.xml and ensure other modules
(avro, compiler, tools, mapred, etc.) do not inherit the skip by not including a
parent-level spotless skip setting.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants