Skip to content

Commit

Permalink
Remove dependency on internal libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
markvandertol committed Aug 17, 2021
1 parent f5fc5d8 commit 705d8e6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
7 changes: 1 addition & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jV
val slf4jSimple = "org.slf4j" % "slf4j-simple" % slf4jV
val specs2 = "org.specs2" %% "specs2-core" % specs2V % "it,test"
val specs2Mock = "org.specs2" %% "specs2-mock" % specs2V % "test"
val enumUtils = "com.thenewmotion" %% "enum-utils" % "0.3"
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.14.3" % "test"
val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % specs2V % "test"
val json4sjackson = "org.json4s" %% "json4s-jackson" % json4sV % "test"
Expand All @@ -17,7 +16,6 @@ val mockServer = "org.mock-server" % "mockserver-client-java" % "5.8.0" % "test"
val mockServerNetty = "org.mock-server" % "mockserver-netty" % "5.8.0" % "test"

def module(name: String) = Project(name, file(name))
.enablePlugins(OssLibPlugin)
.configs(IntegrationTest)
.settings(
organization := "com.thenewmotion.ocpp",
Expand All @@ -26,7 +24,6 @@ def module(name: String) = Project(name, file(name))
)

val messages = module("ocpp-messages")
.settings(libraryDependencies += enumUtils)

val json = module("ocpp-json")
.dependsOn(messages)
Expand Down Expand Up @@ -77,8 +74,6 @@ val exampleJsonServer20 =
publish := {}
)

crossScalaVersions := Seq(tnm.ScalaVersion.curr, tnm.ScalaVersion.prev, tnm.ScalaVersion.aged)

enablePlugins(OssLibPlugin)
crossScalaVersions := Seq("2.13.1", "2.12.10", "2.11.12")

publish := {}
12 changes: 12 additions & 0 deletions ocpp-messages/src/main/scala/enums/EnumUtils.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package enums


object EnumUtils {
trait Nameable {
def name: String
}
trait Enumerable[T <: Nameable] {
def values: Iterable[T]
def withName(name: String): Option[T] = values.find(_.name == name)
}
}
20 changes: 20 additions & 0 deletions ocpp-messages/src/main/scala/enums/reflection/EnumUtils.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package enums.reflection

/**
* This version of the enum utils can
* only be used in top-level definitions,
* otherwise the reflective .getSimpleName
* call throws an exception.
*/
object EnumUtils {

trait Nameable {
def name: String = this.getClass.getSimpleName
.replaceAll("minus", "-").replaceAll("\\$", "")}

trait Enumerable[T <: Nameable] {
def values: Iterable[T]
def withName(name: String): Option[T] = values.find(_.name == name)
}

}
4 changes: 0 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
resolvers += "TNM" at "https://nexus.thenewmotion.com/content/groups/public"

addSbtPlugin("com.newmotion" % "sbt-build-seed" % "5.0.4")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
Expand Down

0 comments on commit 705d8e6

Please sign in to comment.