Skip to content

Add serialVersionUID to generated classes that implement Serializable#811

Merged
kobylynskyi merged 3 commits into
kobylynskyi:developfrom
rolevinks:810
Nov 7, 2021
Merged

Add serialVersionUID to generated classes that implement Serializable#811
kobylynskyi merged 3 commits into
kobylynskyi:developfrom
rolevinks:810

Conversation

@rolevinks

@rolevinks rolevinks commented Sep 15, 2021

Copy link
Copy Markdown
Contributor

This pull request adds a serialVersionUID to the java template type.ftl. This prevent warnings from for example the maven-compiler-plugin, that are raised when a class that implements Serializable does not has a serialVersionUID field.

Related to #810


Changes were made to:

  • Codegen library - Java
  • Codegen library - Kotlin
  • Codegen library - Scala
  • Maven plugin
  • Gradle plugin
  • SBT plugin

@kobylynskyi

Copy link
Copy Markdown
Owner

@rolevinks please change target branch to develop

@rolevinks rolevinks changed the base branch from master to develop September 15, 2021 09:36
@rolevinks

Copy link
Copy Markdown
Contributor Author

@kobylynskyi Yes, sorry! Target branch is now develop

public class ${className} implements java.io.Serializable<#if implements?has_content><#list implements as interface>, ${interface}<#if interface_has_next></#if></#list></#if> {

@java.io.Serial
private static final long serialVersionUID = 1L;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

welcome to create pr.
I only have one questions.

  1. The library is based on 1.8, and the annotation comes from Java 11.

So It is not appropriate to introduce this annotation directly. With configuration, placeholders can be more generic for compatibility with Java 1.8 and other languages.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I removed the annotation. It is not really needed anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi,
Is there any update on this issue?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can check the JDK version in the template.

<#assign MapperUtil=statics["com.kobylynskyi.graphql.codegen.java.Utils"]>

and <# if checkJdk /> ? @kobylynskyi

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think we need that annotation anyway.
Sorry for a long delay in reply!

@kobylynskyi kobylynskyi merged commit 69dee51 into kobylynskyi:develop Nov 7, 2021
@kobylynskyi kobylynskyi added this to the 5.3.1 milestone Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants