Skip to content

Commit 56f2732

Browse files
committed
Add Scala 3 support
1 parent 5d41789 commit 56f2732

File tree

13 files changed

+220
-26
lines changed

13 files changed

+220
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This can be set as project property.
6969

7070
##### Scala version configuration
7171

72-
Plugin supports Scala 2.12.x and 2.13.x versions by automatically loading and configuring matching `scalac-scoverage-plugin` Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining `scalaVersion` plugin configuration parameter or `scala.version` project property. Without this setting, coverage will not be calculated.
72+
Plugin supports Scala 2.12.8+, 2.13.0+ and 3.2.0+ versions by automatically loading and configuring matching `scalac-scoverage-plugin` Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining `scalaVersion` plugin configuration parameter or `scala.version` project property. Without this setting, coverage will not be calculated.
7373

7474
```xml
7575
<project>

src/it/integration_tests_parent/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
<scala.compat.version>2.13</scala.compat.version>
2727
<scala.minor.version>12</scala.minor.version>
2828
<scala.version>${scala.compat.version}.${scala.minor.version}</scala.version>
29+
<scala.library.artifact.id>scala-library</scala.library.artifact.id>
2930
</properties>
3031

3132
<dependencies>
3233
<dependency>
3334
<groupId>org.scala-lang</groupId>
34-
<artifactId>scala-library</artifactId>
35+
<artifactId>${scala.library.artifact.id}</artifactId>
3536
<version>${scala.version}</version>
3637
</dependency>
3738

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals=clean verify site -e -ntp
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>it.scoverage-maven-plugin</groupId>
9+
<artifactId>integration_tests_parent</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
<relativePath>../integration_tests_parent/pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>test_ScalaMavenPlugin_Scala32Plus_ScalaTest</artifactId>
15+
<version>1.0-SNAPSHOT</version>
16+
<packaging>jar</packaging>
17+
<name>Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest</name>
18+
<description>Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest</description>
19+
20+
<properties>
21+
<scala.compat.version>3</scala.compat.version>
22+
<scala.version>3.3.1</scala.version>
23+
<scala.library.artifact.id>scala3-library_3</scala.library.artifact.id>
24+
</properties>
25+
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-compiler-plugin</artifactId>
31+
</plugin>
32+
<plugin>
33+
<groupId>net.alchim31.maven</groupId>
34+
<artifactId>scala-maven-plugin</artifactId>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.scalatest</groupId>
38+
<artifactId>scalatest-maven-plugin</artifactId>
39+
</plugin>
40+
<plugin>
41+
<groupId>@project.groupId@</groupId>
42+
<artifactId>@project.artifactId@</artifactId>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package service
2+
3+
object HelloServiceScala {
4+
def hello = { "Hello" }
5+
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package service
2+
3+
import org.scalatest.wordspec.AnyWordSpec
4+
5+
class HelloServiceScalaTest extends AnyWordSpec {
6+
7+
"HelloService" should {
8+
"say hello" in {
9+
assert(HelloServiceScala.hello == "Hello")
10+
}
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
try {
2+
3+
def logFile = new File(basedir, "build.log")
4+
def lines = logFile.readLines()
5+
assert lines.contains("[INFO] Statement coverage.: 100.00%")
6+
assert lines.contains("[INFO] Branch coverage....: 100.00%")
7+
8+
def scoverageFile = new File(basedir, "target/scoverage.xml")
9+
assert scoverageFile.exists()
10+
11+
def reportFile = new File(basedir, "target/site/scoverage/index.html")
12+
assert reportFile.exists()
13+
14+
return true
15+
16+
} catch (Throwable e) {
17+
e.printStackTrace()
18+
return false
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals=clean verify site -e -ntp
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>it.scoverage-maven-plugin</groupId>
9+
<artifactId>integration_tests_parent</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
<relativePath>../integration_tests_parent/pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>test_ScalaMavenPlugin_Scala32Plus_ScalaTest_ScalaVersion_Not_Set</artifactId>
15+
<version>1.0-SNAPSHOT</version>
16+
<packaging>jar</packaging>
17+
<name>Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest when scala.version is not set</name>
18+
<description>Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest when scala.version is not set</description>
19+
20+
<properties>
21+
<scala.compat.version>3</scala.compat.version>
22+
<scala.version/>
23+
<scala.library.artifact.id>scala3-library_3</scala.library.artifact.id>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.scala-lang</groupId>
29+
<artifactId>${scala.library.artifact.id}</artifactId>
30+
<version>3.3.1</version>
31+
</dependency>
32+
</dependencies>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-compiler-plugin</artifactId>
39+
</plugin>
40+
<plugin>
41+
<groupId>net.alchim31.maven</groupId>
42+
<artifactId>scala-maven-plugin</artifactId>
43+
</plugin>
44+
<plugin>
45+
<groupId>org.scalatest</groupId>
46+
<artifactId>scalatest-maven-plugin</artifactId>
47+
</plugin>
48+
<plugin>
49+
<groupId>@project.groupId@</groupId>
50+
<artifactId>@project.artifactId@</artifactId>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package service
2+
3+
object HelloServiceScala {
4+
def hello = { "Hello" }
5+
6+
}

0 commit comments

Comments
 (0)