From 1e9ffc12b3b6d515daa7b263582d46a0e54179db Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 13 Aug 2021 15:42:45 -0700 Subject: [PATCH] Add @JvmStatic annotation to Kotlin builders --- CONTRIBUTING.md | 19 ++++++++++--------- .../kotlin-lang/kotlinClassGraphqlRequest.ftl | 2 +- .../kotlin-lang/kotlinClassGraphqlType.ftl | 2 +- .../kt/Commit_no_final_class.kt.txt | 2 +- .../kt/optional/TypeWithMandatoryField.kt.txt | 2 +- .../restricted-words/FunQueryRequest.kt.txt | 2 +- .../kt/restricted-words/Super.kt.txt | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f89eb5fa5..57e627d2a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,19 +16,20 @@ Before sending your pull requests, make sure you followed this list: Please follow the steps below in order to make the changes: 1. Clone the repository -2. Checkout **develop** branch. -3. Open repository in your favourite IDE. -4. Enable and configure CheckStyle plugin in your IDE (for IntelliJ it is CheckStyle-IDEA). +2. Set the local java version to 1.8 +3. Checkout **develop** branch. +4. Open repository in your favourite IDE. +5. Enable and configure CheckStyle plugin in your IDE (for IntelliJ it is CheckStyle-IDEA). Import [graphql-codegen-check-style.xml](config/checkstyle/graphql-codegen-check-style.xml) as a . -5. Make code changes to the core library of `graphql-java-codegen`. -6. If changes are required in the plugin code, then **build** and **install** `graphql-java-codegen` first. +6. Make code changes to the core library of `graphql-java-codegen`. +7. If changes are required in the plugin code, then **build** and **install** `graphql-java-codegen` first. ```shell script # This will install the library (including your recent changes) in your local maven repository. ./gradlew clean build publishToMavenLocal ``` -7. Build the plugin project with updated `graphql-java-codegen` library. +8. Build the plugin project with updated `graphql-java-codegen` library. ```shell script # Build Gradle plugin @@ -39,8 +40,8 @@ Please follow the steps below in order to make the changes: mvn clean verify ``` -8. Make changes to the plugin code -9. Install the plugin (copy to your local maven repository). +9. Make changes to the plugin code +10. Install the plugin (copy to your local maven repository). ```shell script # Install Gradle plugin @@ -51,4 +52,4 @@ Please follow the steps below in order to make the changes: mvn clean install ``` -10. Make sure that `example` projects are compiling and running. +11. Make sure that `example` projects are compiling and running. diff --git a/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlRequest.ftl b/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlRequest.ftl index c510cbda2..7354edda1 100755 --- a/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlRequest.ftl +++ b/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlRequest.ftl @@ -32,7 +32,7 @@ open class ${className}(private val alias: String?) : GraphQLOperationRequest { val OPERATION_TYPE: GraphQLOperation = GraphQLOperation.${operationType} <#if builder> - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } diff --git a/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlType.ftl b/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlType.ftl index 02177fad8..bf4c000a2 100755 --- a/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlType.ftl +++ b/src/main/resources/templates/kotlin-lang/kotlinClassGraphqlType.ftl @@ -75,7 +75,7 @@ open class ${className}()<#if implements?has_content> : <#list implements as int <#if builder> companion object { - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } diff --git a/src/test/resources/expected-classes/kt/Commit_no_final_class.kt.txt b/src/test/resources/expected-classes/kt/Commit_no_final_class.kt.txt index dc4cf3834..d99ceb5bd 100644 --- a/src/test/resources/expected-classes/kt/Commit_no_final_class.kt.txt +++ b/src/test/resources/expected-classes/kt/Commit_no_final_class.kt.txt @@ -60,7 +60,7 @@ open class Commit( ) : Closer, IssueTimelineItem, PullRequestTimelineItem, Subscribable, Node, GitObject, UniformResourceLocatable { companion object { - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } // In the future, it maybe change. diff --git a/src/test/resources/expected-classes/kt/optional/TypeWithMandatoryField.kt.txt b/src/test/resources/expected-classes/kt/optional/TypeWithMandatoryField.kt.txt index 95ee51bf8..877c7f112 100644 --- a/src/test/resources/expected-classes/kt/optional/TypeWithMandatoryField.kt.txt +++ b/src/test/resources/expected-classes/kt/optional/TypeWithMandatoryField.kt.txt @@ -10,7 +10,7 @@ data class TypeWithMandatoryField( ) : InterfaceWithOptionalField { companion object { - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } // In the future, it maybe change. diff --git a/src/test/resources/expected-classes/kt/restricted-words/FunQueryRequest.kt.txt b/src/test/resources/expected-classes/kt/restricted-words/FunQueryRequest.kt.txt index 0f5be311c..d62346845 100644 --- a/src/test/resources/expected-classes/kt/restricted-words/FunQueryRequest.kt.txt +++ b/src/test/resources/expected-classes/kt/restricted-words/FunQueryRequest.kt.txt @@ -14,7 +14,7 @@ open class FunQueryRequest(private val alias: String?) : GraphQLOperationRequest const val OPERATION_NAME: String = "fun" val OPERATION_TYPE: GraphQLOperation = GraphQLOperation.QUERY - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } private val input: MutableMap = LinkedHashMap() diff --git a/src/test/resources/expected-classes/kt/restricted-words/Super.kt.txt b/src/test/resources/expected-classes/kt/restricted-words/Super.kt.txt index 368e5c497..1ef9e5d43 100644 --- a/src/test/resources/expected-classes/kt/restricted-words/Super.kt.txt +++ b/src/test/resources/expected-classes/kt/restricted-words/Super.kt.txt @@ -16,7 +16,7 @@ data class Super( ) { companion object { - fun builder(): Builder = Builder() + @JvmStatic fun builder(): Builder = Builder() } // In the future, it maybe change.