JaCoCo automatically excludes methods and classes annotated with @Generated from the coverage reports. This is very important to us as generated code should not normally be included in the coverage report. We want to measure the coverage of the code that we actually wrote and maintain, not the code that was automatically generated by tools.
By introducing a property generatedAnnotation (default value false) one could enable writing @Generated on Java types to be generated.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/1075
**Author:** [@arouel](https://github.com/arouel)
**Created:** 5/23/2025
**Status:** ✅ Merged
**Merged:** 7/8/2025
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `generated-annotation`
---
### 📝 Commits (2)
- [`b4cc448`](https://github.com/apple/pkl/commit/b4cc448a0b328216e062079b3c7834d92b2e76a2) Add `@Generated` annotation to generated Java types
- [`36f4e27`](https://github.com/apple/pkl/commit/36f4e2740fa784d610ca4ac213a73d07ac9fa216) Apply PR comments
### 📊 Changes
**11 files changed** (+141 additions, -4 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt` (+4 -0)
📝 `pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/JavaCodeGenerator.kt` (+8 -0)
📝 `pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/Main.kt` (+8 -0)
📝 `pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt` (+18 -0)
➕ `pkl-codegen-java/src/test/resources/org/pkl/codegen/java/GeneratedAnnotation.jva` (+63 -0)
➕ `pkl-config-java/src/main/java/org/pkl/config/java/Generated.java` (+26 -0)
📝 `pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java` (+2 -0)
📝 `pkl-gradle/src/main/java/org/pkl/gradle/spec/CodeGenSpec.java` (+3 -1)
📝 `pkl-gradle/src/main/java/org/pkl/gradle/spec/JavaCodeGenSpec.java` (+1 -1)
📝 `pkl-gradle/src/main/java/org/pkl/gradle/task/CodeGenTask.java` (+6 -1)
📝 `pkl-gradle/src/main/java/org/pkl/gradle/task/JavaCodeGenTask.java` (+2 -1)
</details>
### 📄 Description
# Why?
JaCoCo automatically excludes methods and classes annotated with `@Generated` from the coverage reports. This is very important to us as generated code should not normally be included in the coverage report. We want to measure the coverage of the code that we actually wrote and maintain, not the code that was automatically generated by tools.
By introducing a property `generatedAnnotation` (default value `false`) one could enable writing `@Generated` on Java types to be generated.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1075
Author: @arouel
Created: 5/23/2025
Status: ✅ Merged
Merged: 7/8/2025
Merged by: @bioball
Base:
main← Head:generated-annotation📝 Commits (2)
b4cc448Add@Generatedannotation to generated Java types36f4e27Apply PR comments📊 Changes
11 files changed (+141 additions, -4 deletions)
View changed files
📝
pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/CliJavaCodeGeneratorOptions.kt(+4 -0)📝
pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/JavaCodeGenerator.kt(+8 -0)📝
pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/Main.kt(+8 -0)📝
pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt(+18 -0)➕
pkl-codegen-java/src/test/resources/org/pkl/codegen/java/GeneratedAnnotation.jva(+63 -0)➕
pkl-config-java/src/main/java/org/pkl/config/java/Generated.java(+26 -0)📝
pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java(+2 -0)📝
pkl-gradle/src/main/java/org/pkl/gradle/spec/CodeGenSpec.java(+3 -1)📝
pkl-gradle/src/main/java/org/pkl/gradle/spec/JavaCodeGenSpec.java(+1 -1)📝
pkl-gradle/src/main/java/org/pkl/gradle/task/CodeGenTask.java(+6 -1)📝
pkl-gradle/src/main/java/org/pkl/gradle/task/JavaCodeGenTask.java(+2 -1)📄 Description
Why?
JaCoCo automatically excludes methods and classes annotated with
@Generatedfrom the coverage reports. This is very important to us as generated code should not normally be included in the coverage report. We want to measure the coverage of the code that we actually wrote and maintain, not the code that was automatically generated by tools.By introducing a property
generatedAnnotation(default valuefalse) one could enable writing@Generatedon Java types to be generated.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.