-
Notifications
You must be signed in to change notification settings - Fork 321
Add @Generated
annotation to generated Java types
#1075
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! This generally looks good, but I have some minor comments.
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** Annotation marking this type as generated. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Annotation marking this type as generated. */ | |
/** Indicates that the annotated class was generated by Pkl. */ |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.pkl.config.java.mapper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not related to object mapping, let's move this up one level, to package org.pkl.config.java
/** | ||
* @return who generated the annotated type | ||
*/ | ||
String value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's any purpose to this field. Remove?
@@ -19,6 +19,8 @@ | |||
|
|||
/** Configuration options for Java code generators. Documented in user manual. */ | |||
public interface JavaCodeGenSpec extends CodeGenSpec { | |||
Property<Boolean> getGeneratedAnnotation(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to CodeGenSpec
instead? This way, we can add this same flag to the kotlin code generator. And let's rename this to getAddGeneratedAnnotation
. Same for JavaCodeGenTask
.
d38549c
to
36f4e27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
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 valuefalse
) one could enable writing@Generated
on Java types to be generated.