Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Commit

Permalink
Upgrade to Cats 1.0.0 (#15)
Browse files Browse the repository at this point in the history
* Upgrade to cats 1.0.0

Add simple sbt plugin tests

* Update travis.yml
  • Loading branch information
suhasgaddam authored Oct 26, 2017
1 parent 65e0fe7 commit d6b52ca
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ before_install:

script:
- sbt ++$TRAVIS_SCALA_VERSION orgScriptCI
- sbt ++$TRAVIS_SCALA_VERSION scripted

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
9 changes: 7 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ lazy val root = project
lazy val plugin = project
.in(file("plugin"))
.aggregate(core)
.dependsOn(core)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
Expand All @@ -28,8 +27,14 @@ lazy val core = project
.settings(
libraryDependencies ++= Seq(
%%("frees-rpc-common", "0.1.1"),
%%("cats-core", "0.9.0"),
%%("cats-core"),
%%("scalameta-contrib", "1.8.0"),
%%("simulacrum")
)
)

scriptedLaunchOpts := {
scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
}

scriptedBufferLog := false
2 changes: 1 addition & 1 deletion core/src/main/scala/ProtoCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object ProtoCodeGen {
ProtoAnnotationsProcessor[Try]
.process(inputFile)
.map {
case pd if pd.options.nonEmpty && pd.messages.nonEmpty && pd.services.nonEmpty =>
case pd if pd.options.nonEmpty || pd.messages.nonEmpty || pd.services.nonEmpty =>
val protoContents = ProtoEncoder[ProtoDefinitions].encode(pd)
val outputFile =
new File(output.toPath + "/" + inputFile.getName.replaceAll(".scala", ".proto"))
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/scala/proto/encoders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ object encoders {
override def encode(d: ProtoDefinitions): String =
s"""${d.prelude}
|
|${d.options.map(POM.encode).mkString("\n")}
|${d.options.map(POM.encode).mkString("\n").trim}
|
|${d.messages.map(PEM.encode).mkString("\n")}
|${d.services.map(PES.encode).mkString("\n")}
|${d.messages.map(PEM.encode).mkString("\n").trim}
|
|${d.services.map(PES.encode).mkString("\n").trim}
""".stripMargin

}
Expand Down
3 changes: 1 addition & 2 deletions plugin/src/main/scala/ProtoGenPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package freestyle

import freestyle.rpc.protocol._
import sbt._
import sbt.Keys._

Expand Down Expand Up @@ -64,6 +63,6 @@ object ProtoGenPlugin extends AutoPlugin {

override def projectSettings: Seq[Def.Setting[_]] =
defaultSettings ++ protoGenTaskSettings ++ Seq(
libraryDependencies += "io.frees" %% "frees-protogen-core" % BuildInfo.version
libraryDependencies += "io.frees" %% "frees-protogen-core" % freestyle.rpc.protocol.BuildInfo.version
)
}
1 change: 1 addition & 0 deletions project/scripted.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
1 change: 1 addition & 0 deletions src/sbt-test/sbt-freestyle-protogen/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/main/proto/model.proto
7 changes: 7 additions & 0 deletions src/sbt-test/sbt-freestyle-protogen/basic/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version := "1.0"

resolvers += Resolver.bintrayRepo("beyondthelines", "maven")

libraryDependencies ++= Seq(
"io.frees" %% "frees-rpc" % "0.1.1"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("io.frees" % "sbt-frees-protogen" % sys.props("plugin.version"))
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import freestyle.rpc.protocol._

@message
case class Person(id: Long, name: String, email: Option[String])
5 changes: 5 additions & 0 deletions src/sbt-test/sbt-freestyle-protogen/basic/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> protoGen

$ exists src/main/proto/model.proto

$ delete src/main/proto/model.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/main/proto/model.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version := "1.0"

resolvers += Resolver.bintrayRepo("beyondthelines", "maven")

libraryDependencies ++= Seq(
"io.frees" %% "frees-rpc" % "0.1.1"
)

scalaMetaSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addSbtPlugin("io.frees" % "sbt-frees-protogen" % sys.props("plugin.version"))
addSbtPlugin("io.frees" % "sbt-freestyle" % "0.3.7")
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import freestyle.rpc.protocol._

@message
case class Person(id: Long, name: String, email: Option[String])
5 changes: 5 additions & 0 deletions src/sbt-test/sbt-freestyle-protogen/with-sbt-freestyle/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> protoGen

$ exists src/main/proto/model.proto

$ delete src/main/proto/model.proto

0 comments on commit d6b52ca

Please sign in to comment.