Skip to content

Commit a463dcc

Browse files
committed
multi-module sample project
1 parent b05e3d8 commit a463dcc

File tree

10 files changed

+117
-0
lines changed

10 files changed

+117
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.idea_modules
3+
target

samples/sbt/multi-module/build.sbt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
organization := "com.buransky"
2+
3+
scalaVersion := "2.10.3"
4+
5+
lazy val root = project.in(file(".")).aggregate(module1, module2)
6+
7+
lazy val module1 = project.in(file("module1"))
8+
9+
lazy val module2 = project.in(file("module2"))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
organization := Common.organization
2+
3+
name := Common.baseName + "-module1"
4+
5+
version := Common.version
6+
7+
scalaVersion := "2.10.3"
8+
9+
libraryDependencies ++= Seq(
10+
"org.scalatest" %% "scalatest" % "2.0" % "test"
11+
)
12+
13+
ScoverageSbtPlugin.instrumentSettings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.buransky.plugins.scoverage.samples.sbt.multiModule.module1
2+
3+
import scala.util.Random
4+
5+
trait Beer {
6+
val volume: Double
7+
def isGood: Boolean = (volume > 0.0)
8+
}
9+
10+
case object EmptyBeer extends {
11+
val volume = 0.0
12+
} with Beer
13+
14+
trait SlovakBeer extends Beer {
15+
override def isGood = Random.nextBoolean
16+
}
17+
18+
trait BelgianBeer extends Beer {
19+
if (volume > 0.25)
20+
throw new IllegalArgumentException("Too big beer for belgian beer!")
21+
22+
override def isGood = true
23+
}
24+
25+
case class HordonBeer(volume: Double) extends SlovakBeer {
26+
override def isGood = false
27+
}
28+
29+
case class ChimayBeer(volume: Double) extends BelgianBeer
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.buransky.plugins.scoverage.samples.sbt.multiModule.module1
2+
3+
trait Pub {
4+
def offer: Iterable[_ <: Beer]
5+
def giveMeGreat: Beer
6+
}
7+
8+
object Delirium extends Pub {
9+
def offer = List(HordonBeer(0.5), ChimayBeer(0.2))
10+
def giveMeGreat = offer.filter(_.isGood).filter(_.volume > 0.3).head
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.buransky.plugins.scoverage.samples.sbt.multiModule.module1
2+
3+
import org.scalatest.{Matchers, FlatSpec}
4+
5+
class BeerSpec extends FlatSpec with Matchers {
6+
behavior of "Beer"
7+
8+
"isGood" must "be true if not empty" in {
9+
val beer = new Beer { val volume = 0.1 }
10+
beer.isGood should equal(true)
11+
}
12+
13+
behavior of "EmptyBeer"
14+
15+
it must "be empty" in {
16+
EmptyBeer.volume should equal(0.0)
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.buransky.plugins.scoverage.samples.sbt.multiModule.module1
2+
3+
import org.scalatest.{FlatSpec, Matchers}
4+
5+
class PubSpec extends FlatSpec with Matchers {
6+
behavior of "Delirium"
7+
8+
it must "give me what I want" in {
9+
the[NoSuchElementException] thrownBy Delirium.giveMeGreat
10+
}
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Common {
2+
val organization = "com.buransky"
3+
val baseName = "multi-module"
4+
val version = "1.0.0"
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resolvers += Classpaths.sbtPluginReleases
2+
3+
addSbtPlugin("com.sksamuel.scoverage" %% "sbt-scoverage" % "0.95.7")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sonar.projectKey=com.buranskt:multi-module
2+
sonar.projectName=Sonar Scoverage plugin multi-module sample project
3+
sonar.projectVersion=1.0.0
4+
5+
sonar.language=scala
6+
7+
sonar.modules=module1
8+
9+
module1.sonar.sources=src/main/scala
10+
module1.sonar.tests=src/test/scala
11+
module1.sonar.scoverage.reportPath=target/scala-2.10/scoverage-report/scoverage.xml
12+
13+
module2.sonar.sources=src/main/scala
14+
module2.sonar.tests=src/test/scala
15+
#module2.sonar.scoverage.reportPath=target/scala-2.10/scoverage-report/scoverage.xml

0 commit comments

Comments
 (0)