Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/check-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

# brew install sbt; cd graphql-java-codegen-sbt-plugin; sbt fmt or sbt check
- name: Check Scala Code Style
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt check

- name: Check Code Style
env:
WORKDIR: ./
Expand Down
2 changes: 1 addition & 1 deletion docs/codegen-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages. |
| `generateModelOpenClasses` | Boolean | False | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future. |
| `initializeNullableTypes` | Boolean | False | Adds a default null value to nullable arguments. Only supported in Kotlin. |
| `generateSealedInterfaces` | Boolean | False | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin. |
| `generateSealedInterfaces` | Boolean | False | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin and Scala. |
| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `com.fasterxml.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
| `supportUnknownFields` | Boolean | False | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map<String,Object>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields. |
Expand Down
23 changes: 23 additions & 0 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version = "3.6.1"
runner.dialect = scala213
maxColumn = 120
align.preset = more
lineEndings = preserve
align.stripMargin = false
docstrings.style = AsteriskSpace
docstrings.oneline = keep
continuationIndent.defnSite = 2
danglingParentheses.preset = true
spaces {
inImportCurlyBraces = true
}
indentOperator.exemptScope = aloneArgOrBody
includeCurlyBraceInSelectChains = false
align.openParenDefnSite = false
optIn.annotationNewlines = true
rewrite.rules = [SortImports, RedundantBraces]
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
11 changes: 0 additions & 11 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/.scalariform.conf

This file was deleted.

25 changes: 13 additions & 12 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ jValidationVersion := "2.0.1.Final"

// keep version is equals with parent project `graphql-java-codegen`.
// Plugin don't need to care about the scala version, just the SBT version.
lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin", base = file(".")).
enablePlugins(SbtPlugin, BuildInfoPlugin).
settings(Publishing.publishSettings).
settings(
sbtPlugin := true,
lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin", base = file("."))
.enablePlugins(SbtPlugin, BuildInfoPlugin)
.settings(Publishing.publishSettings)
.settings(
sbtPlugin := true,
scriptedBufferLog := false,
commands ++= Commands.value,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
scalacOptions += "-target:jvm-1.8",
releaseIgnoreUntrackedFiles := true,
Expand All @@ -31,12 +32,12 @@ lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin
pushChanges
),
libraryDependencies ++= Seq(
"io.github.kobylynskyi" % "graphql-java-codegen" % (version in ThisBuild).value,
"org.freemarker" % "freemarker" % "2.3.31",
"com.graphql-java" % "graphql-java" % "16.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.1",
"com.typesafe" % "config" % "1.4.2"
"io.github.kobylynskyi" % "graphql-java-codegen" % (ThisBuild / version).value,
"org.freemarker" % "freemarker" % "2.3.31",
"com.graphql-java" % "graphql-java" % "16.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.1",
"com.typesafe" % "config" % "1.4.2"
),
buildInfoKeys := Seq[BuildInfoKey](name, version, sbtVersion, jValidationVersion),
buildInfoKeys := Seq[BuildInfoKey](name, version, sbtVersion, jValidationVersion),
buildInfoPackage := "io.github.dreamylost.graphql.codegen"
)
)
20 changes: 20 additions & 0 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/project/Commands.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sbt.Command

/** @author
* 梦境迷离
* @since 2022/1/15
* @version 1.0
*/
object Commands {

val FmtSbtCommand = Command.command("fmt")(state => "scalafmtSbt" :: "scalafmtAll" :: state)

val FmtSbtCheckCommand =
Command.command("check")(state => "scalafmtSbtCheck" :: "scalafmtCheckAll" :: state)

val value = Seq(
FmtSbtCommand,
FmtSbtCheckCommand
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import sbt._
import sbt.Keys._
import xerial.sbt.Sonatype.autoImport.sonatypeProfileName

/**
* sbt publish setting
/** sbt publish setting
*
* @author 梦境迷离
* @since 2020-07-19
* @version v1.0
* @author
* 梦境迷离
* @since 2020-07-19
* @version v1.0
*/
object Publishing {

//publish by sbt publishSigned
// publish by sbt publishSigned
lazy val publishSettings = Seq(
credentials += Credentials(Path.userHome / ".ivy2" / ".sonatype_credentials"),
publishTo := {
Expand All @@ -21,25 +21,27 @@ object Publishing {
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")),
publishMavenStyle := true,
licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
pomIncludeRepository := { _ => false },
developers := List(
Developer(
id = "dreamylost",
name = "梦境迷离",
email = "[email protected]",
url = url("https://dreamylost.cn")
)),
url = url("https://blog.dreamylost.cn")
)
),
sonatypeProfileName := organization.value,
isSnapshot := version.value endsWith "SNAPSHOT",
homepage := Some(url("https://github.com/jxnu-liguobin")),
isSnapshot := version.value endsWith "SNAPSHOT",
homepage := Some(url("https://github.com/jxnu-liguobin")),
scmInfo := Some(
ScmInfo(
//it is fork from https://github.com/kobylynskyi/graphql-java-codegen
// it is fork from https://github.com/kobylynskyi/graphql-java-codegen
url("https://github.com/jxnu-liguobin/graphql-java-codegen"),
"scm:[email protected]:jxnu-liguobin/graphql-java-codegen.git"
))
)
)
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import sbt.io.{ AllPassFilter, SuffixFilter }
import sbt.{ Def, Task }
import sbt.Configuration

/**
*
* @author 梦境迷离
* @since 2020-07-18
* @version v1.0
/** @author
* 梦境迷离
* @since 2020-07-18
* @version v1.0
*/
trait Compat {
self: GraphQLCodegenPlugin =>

import self.GlobalImport._

val watchSourcesSetting: Def.Setting[Task[Seq[WatchSource]]] = {
val watchSourcesSetting: Def.Setting[Task[Seq[WatchSource]]] =
watchSources += new Source(
(sourceDirectory in graphqlCodegen).value,
(graphqlCodegen / sourceDirectory).value,
new SuffixFilter(".graphql") | new SuffixFilter(".graphqls"),
AllPassFilter)
}
AllPassFilter
)

protected[this] lazy val GraphQLCodegenConfig = Configuration.of("GraphQLCodegen", "graphqlCodegen" + configurationPostfix)
protected[this] lazy val GraphQLCodegenConfig =
Configuration.of("GraphQLCodegen", "graphqlCodegen" + configurationPostfix)

}
Loading