Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
update coverage parser and remove unnecessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrocodacy committed Nov 29, 2018
1 parent 21875a0 commit acf04b6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
8 changes: 3 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version := "0.0.1-SNAPSHOT"
crossSbtVersions := Seq("0.13.16", "1.0.1")

scalaVersion := (CrossVersion partialVersion (sbtVersion in pluginCrossBuild).value match {
case Some((0, 13)) => "2.10.6"
case Some((1, _)) => "2.12.2"
case Some((0, 13)) => "2.10.7"
case Some((1, _)) => "2.12.7"
case _ => sys error s"Unhandled sbt version ${(sbtVersion in pluginCrossBuild).value}"
})

Expand All @@ -25,9 +25,7 @@ resolvers ++= Seq(
)

libraryDependencies ++= Seq(
codacyScalaApi,
coverageParser,
raptureJsonCirce,
Codacy.coverageParser,
javaxActivation
)

Expand Down
8 changes: 3 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import sbt._

object Dependencies {

val codacyScalaApi = "com.codacy" %% "codacy-api-scala" % "3.0.7"
val coverageParser = "com.codacy" %% "coverage-parser" % "2.0.7"
val raptureJsonCirce = "com.propensive" %% "rapture-json-circe" % "2.0.0-M8" exclude("org.spire-math", "jawn-parser_2.11")
object Codacy {
val coverageParser = "com.codacy" %% "coverage-parser" % "2.0.12"
}
val javaxActivation = "com.sun.activation" % "javax.activation" % "1.2.0"

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.16
sbt.version=1.2.3
8 changes: 5 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ resolvers ++= Seq(
Classpaths.sbtPluginReleases
)

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.8")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
31 changes: 16 additions & 15 deletions src/main/scala/com/codacy/CodacyCoveragePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ import java.io.File
import com.codacy.api.client.{CodacyClient, FailedResponse, SuccessfulResponse}
import com.codacy.api.helpers.FileHelper
import com.codacy.api.service.CoverageServices
import com.codacy.api.{CoverageFileReport, Language}
import com.codacy.parsers.implementation.CoberturaParser
import rapture.json.{Json, _}
import com.codacy.plugins.api.languages.Languages.Scala
import sbt.Keys._
import sbt._
import sbt.{Def, _}

object CodacyCoveragePlugin extends AutoPlugin {

implicit val (ast, stringParser, jsonSerializer) = {
import rapture.json.jsonBackends.circe._
(implicitJsonAst, implicitJsonStringParser, circeJValueSerializer)
}

private implicit lazy val ser = implicitly[Serializer[CoverageFileReport, Json]]

object AutoImport {
val codacyCoverage = taskKey[Unit]("Upload coverage reports to Codacy.")
Expand All @@ -29,9 +22,14 @@ object CodacyCoveragePlugin extends AutoPlugin {

lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
codacyCoverage := {
codacyCoverageCommand(state.value, baseDirectory.value, coberturaFile.value,
crossTarget.value / "coverage-report" / "codacy-coverage.json",
codacyProjectToken.value, codacyApiBaseUrl.value, codacyCommit.value)
codacyCoverageCommand(
state = state.value,
rootProjectDir = baseDirectory.value,
coberturaFile = coberturaFile.value,
codacyCoverageFile = crossTarget.value / "coverage-report" / "codacy-coverage.json",
codacyToken = codacyProjectToken.value,
codacyApiBaseUrl = codacyApiBaseUrl.value,
sbtCodacyCommit = codacyCommit.value)
},
aggregate in codacyCoverage := false,
codacyProjectToken := None,
Expand All @@ -45,7 +43,7 @@ object CodacyCoveragePlugin extends AutoPlugin {

override def trigger: PluginTrigger = allRequirements

override val projectSettings = baseSettings
override val projectSettings: Seq[Def.Setting[_]] = baseSettings

private val publicApiBaseUrl = "https://api.codacy.com"

Expand All @@ -67,7 +65,10 @@ object CodacyCoveragePlugin extends AutoPlugin {
FileHelper.withTokenAndCommit(codacyToken, commitUUIDOpt) {
case (projectToken, commitUUID) =>

val reader = new CoberturaParser(Language.Scala, rootProjectDir, coberturaFile)
val reader = new CoberturaParser(
language = Scala,
rootProject = rootProjectDir,
coverageReport = coberturaFile)
val report = reader.generateReport()

FileHelper.writeJsonToFile(codacyCoverageFile, report)
Expand All @@ -77,7 +78,7 @@ object CodacyCoveragePlugin extends AutoPlugin {

logger.info(s"Uploading coverage data...")

coverageServices.sendReport(commitUUID, Language.Scala.toString, report) match {
coverageServices.sendReport(commitUUID, Scala.toString, report) match {
case FailedResponse(error) =>
sys.error(s"Failed to upload data. Reason: $error")
state.exit(ok = false)
Expand Down

0 comments on commit acf04b6

Please sign in to comment.