Skip to content

Commit

Permalink
Scala DBT: refactor to add BuildInfo (#466)
Browse files Browse the repository at this point in the history
* refactor to add buildinfo

* refactor to add buildinfo
  • Loading branch information
jxnu-liguobin committed Dec 25, 2020
1 parent bdc689e commit 0d95791
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 45 deletions.
23 changes: 13 additions & 10 deletions plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import Dependencies._
import sbtrelease.ReleaseStateTransformations._

name := "graphql-codegen-sbt-plugin"
// must be equals to oss Group Id
organization := "io.github.jxnu-liguobin"
val jValidationVersion = settingKey[String]("default java Validation api")
jValidationVersion := "2.0.1.Final"

// publish only root project
//publish / skip := true

//keep version is equals with parent project `graphql-java-codegen`
// 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).
enablePlugins(SbtPlugin, BuildInfoPlugin).
settings(Publishing.publishSettings).
settings(
sbtPlugin := true,
scalaVersion := Versions.scala212,
crossScalaVersions := List(Versions.scala212, Versions.scala211),
scalaVersion := "2.12.12",
scriptedBufferLog := false,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
scalacOptions += "-target:jvm-1.8",
Expand All @@ -32,5 +30,10 @@ lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin
setNextVersion,
commitNextVersion,
pushChanges
)).
settings(Compiles.selfDependencies)
),
libraryDependencies ++= Seq(
"io.github.kobylynskyi" % "graphql-java-codegen" % (version in ThisBuild).value
),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, jValidationVersion),
buildInfoPackage := "io.github.dreamylost.graphql.codegen"
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ object GraphQLCodegenPlugin extends GraphQLCodegenPlugin(Compile, configurationP
class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val configurationPostfix: String = "") extends AutoPlugin with Compat {
self =>

//TODO if impl GraphQLCodegenConfiguration, can not use settingKey in override method

//override this by graphqlJavaCodegenVersion and javaxValidationApiVersion
private val jValidation = "2.0.1.Final"
private val codegen = "4.0.2-SNAPSHOT"
private val jValidation = BuildInfo.jValidationVersion
private val codegen = BuildInfo.version

object GlobalImport extends GraphQLCodegenKeys {

Expand Down Expand Up @@ -121,7 +119,6 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co

private def getMappingConfig(): Def.Initialize[MappingConfig] = Def.setting[MappingConfig] {

//TODO use builder
val mappingConfig = new MappingConfig
mappingConfig.setPackageName((generatePackageName in GraphQLCodegenConfig).value.orNull)
mappingConfig.setCustomTypesMapping((customTypesMapping in GraphQLCodegenConfig).value)
Expand Down Expand Up @@ -168,8 +165,7 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
mappingConfig.setResponseProjectionMaxDepth((responseProjectionMaxDepth in GraphQLCodegenConfig).value)
mappingConfig.setRelayConfig((relayConfig in GraphQLCodegenConfig).value)
mappingConfig.setGeneratedLanguage((generatedLanguage in GraphQLCodegenConfig).value)

// sLog.value.debug(s"Current mapping config is <$mappingConfig>") // NO toString
sLog.value.info(s"Version is <${BuildInfo.toString}>")
mappingConfig
}

Expand Down

0 comments on commit 0d95791

Please sign in to comment.