Skip to content

Commit 4cf5731

Browse files
committed
Add support for maven.test.redirectTestOutputToFile
- disable ANSI codes if enabled - allow customization of the output file name - fix IT verify scripts to catch empty line case - upgrade java version to 8 - IT which verifies output is redirected
1 parent bd51414 commit 4cf5731

File tree

12 files changed

+355
-100
lines changed

12 files changed

+355
-100
lines changed

pom.xml

Lines changed: 97 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
35
<modelVersion>4.0.0</modelVersion>
46

57
<parent>
@@ -12,17 +14,21 @@
1214
<artifactId>scalatest-maven-plugin</artifactId>
1315
<packaging>maven-plugin</packaging>
1416
<version>2.0.1-SNAPSHOT</version>
17+
1518
<name>ScalaTest Maven Plugin</name>
1619
<description>Integrates ScalaTest into Maven</description>
1720

1821
<properties>
1922
<scala.major.version>2.11</scala.major.version>
2023
<scala.minor.version>12</scala.minor.version>
2124
<scala.version>${scala.major.version}.${scala.minor.version}</scala.version>
25+
2226
<scalatest.version>3.0.1</scalatest.version>
2327
<scala.maven.plugin.version>4.3.0</scala.maven.plugin.version>
28+
2429
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2530
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
31+
2632
<build.timestamp>${maven.build.timestamp}</build.timestamp>
2733
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
2834
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
@@ -32,7 +38,8 @@
3238
<junit.version>4.12</junit.version>
3339
<maven.reporting.api.version>3.0</maven.reporting.api.version>
3440
<maven.enforcer.plugin.version>1.4.1</maven.enforcer.plugin.version>
35-
<java.version>6</java.version>
41+
42+
<java.version>8</java.version>
3643
</properties>
3744

3845
<licenses>
@@ -129,16 +136,6 @@
129136
</pluginManagement>
130137

131138
<plugins>
132-
133-
<plugin>
134-
<groupId>org.apache.maven.plugins</groupId>
135-
<artifactId>maven-javadoc-plugin</artifactId>
136-
<version>2.7</version>
137-
<configuration>
138-
<additionalparam>-Xdoclint:none</additionalparam>
139-
</configuration>
140-
</plugin>
141-
142139
<plugin>
143140
<groupId>net.alchim31.maven</groupId>
144141
<artifactId>scala-maven-plugin</artifactId>
@@ -161,8 +158,8 @@
161158
<artifactId>maven-compiler-plugin</artifactId>
162159
<version>3.8.1</version>
163160
<configuration>
164-
<source>1.${java.version}</source>
165-
<target>1.${java.version}</target>
161+
<source>${java.version}</source>
162+
<target>${java.version}</target>
166163
</configuration>
167164
</plugin>
168165
<plugin>
@@ -194,6 +191,7 @@
194191
<pomIncludes>
195192
<pomInclude>lift/pom.xml</pomInclude>
196193
<pomInclude>spaces in path/pom.xml</pomInclude>
194+
<pomInclude>redirect-output/pom.xml</pomInclude>
197195
</pomIncludes>
198196
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
199197
<streamLogs>true</streamLogs>
@@ -206,21 +204,6 @@
206204
</goals>
207205
</configuration>
208206
</plugin>
209-
210-
<plugin>
211-
<groupId>org.apache.maven.plugins</groupId>
212-
<artifactId>maven-gpg-plugin</artifactId>
213-
<version>${maven.gpg.plugin.version}</version>
214-
<executions>
215-
<execution>
216-
<id>sign-artifacts</id>
217-
<phase>verify</phase>
218-
<goals>
219-
<goal>sign</goal>
220-
</goals>
221-
</execution>
222-
</executions>
223-
</plugin>
224207
<plugin>
225208
<groupId>org.apache.maven.plugins</groupId>
226209
<artifactId>maven-enforcer-plugin</artifactId>
@@ -245,58 +228,89 @@
245228
</plugins>
246229
</build>
247230

248-
<reporting>
249-
<plugins>
250-
<plugin>
251-
<groupId>org.apache.maven.plugins</groupId>
252-
<artifactId>maven-plugin-plugin</artifactId>
253-
<version>2.6</version>
254-
</plugin>
255-
<plugin>
256-
<groupId>org.codehaus.mojo</groupId>
257-
<artifactId>cobertura-maven-plugin</artifactId>
258-
<version>2.5.1</version>
259-
</plugin>
260-
<plugin>
261-
<groupId>org.apache.maven.plugins</groupId>
262-
<artifactId>maven-changes-plugin</artifactId>
263-
<version>2.6</version>
264-
<configuration>
265-
<filteringChanges>true</filteringChanges>
266-
</configuration>
267-
</plugin>
268-
<plugin>
269-
<groupId>org.apache.maven.plugins</groupId>
270-
<artifactId>maven-dependency-plugin</artifactId>
271-
<version>2.3</version>
272-
</plugin>
273-
<plugin>
274-
<groupId>org.apache.maven.plugins</groupId>
275-
<artifactId>maven-javadoc-plugin</artifactId>
276-
<version>2.7</version>
277-
<configuration>
278-
<charset>UTF-8</charset>
279-
<docencoding>UTF-8</docencoding>
280-
<docfilessubdirs>true</docfilessubdirs>
281-
<show>package</show>
282-
<source>1.${java.version}</source>
283-
<detectLinks>true</detectLinks>
284-
</configuration>
285-
</plugin>
286-
<plugin>
287-
<groupId>org.apache.maven.plugins</groupId>
288-
<artifactId>maven-jxr-plugin</artifactId>
289-
<version>2.2</version>
290-
<configuration>
291-
<inputEncoding>UTF-8</inputEncoding>
292-
<outputEncoding>UTF-8</outputEncoding>
293-
</configuration>
294-
</plugin>
295-
<plugin>
296-
<groupId>org.apache.maven.plugins</groupId>
297-
<artifactId>maven-surefire-report-plugin</artifactId>
298-
<version>2.5</version>
299-
</plugin>
300-
</plugins>
301-
</reporting>
231+
<profiles>
232+
<profile>
233+
<id>release</id>
234+
<build>
235+
<plugins>
236+
<plugin>
237+
<groupId>org.apache.maven.plugins</groupId>
238+
<artifactId>maven-javadoc-plugin</artifactId>
239+
<version>2.7</version>
240+
<configuration>
241+
<additionalparam>-Xdoclint:none</additionalparam>
242+
</configuration>
243+
</plugin>
244+
<plugin>
245+
<groupId>org.apache.maven.plugins</groupId>
246+
<artifactId>maven-gpg-plugin</artifactId>
247+
<version>${maven.gpg.plugin.version}</version>
248+
<executions>
249+
<execution>
250+
<id>sign-artifacts</id>
251+
<phase>verify</phase>
252+
<goals>
253+
<goal>sign</goal>
254+
</goals>
255+
</execution>
256+
</executions>
257+
</plugin>
258+
</plugins>
259+
</build>
260+
<reporting>
261+
<plugins>
262+
<plugin>
263+
<groupId>org.apache.maven.plugins</groupId>
264+
<artifactId>maven-plugin-plugin</artifactId>
265+
<version>2.6</version>
266+
</plugin>
267+
<plugin>
268+
<groupId>org.codehaus.mojo</groupId>
269+
<artifactId>cobertura-maven-plugin</artifactId>
270+
<version>2.5.1</version>
271+
</plugin>
272+
<plugin>
273+
<groupId>org.apache.maven.plugins</groupId>
274+
<artifactId>maven-changes-plugin</artifactId>
275+
<version>2.6</version>
276+
<configuration>
277+
<filteringChanges>true</filteringChanges>
278+
</configuration>
279+
</plugin>
280+
<plugin>
281+
<groupId>org.apache.maven.plugins</groupId>
282+
<artifactId>maven-dependency-plugin</artifactId>
283+
<version>2.3</version>
284+
</plugin>
285+
<plugin>
286+
<groupId>org.apache.maven.plugins</groupId>
287+
<artifactId>maven-javadoc-plugin</artifactId>
288+
<version>2.7</version>
289+
<configuration>
290+
<charset>UTF-8</charset>
291+
<docencoding>UTF-8</docencoding>
292+
<docfilessubdirs>true</docfilessubdirs>
293+
<show>package</show>
294+
<source>${java.version}</source>
295+
<detectLinks>true</detectLinks>
296+
</configuration>
297+
</plugin>
298+
<plugin>
299+
<groupId>org.apache.maven.plugins</groupId>
300+
<artifactId>maven-jxr-plugin</artifactId>
301+
<version>2.2</version>
302+
<configuration>
303+
<inputEncoding>UTF-8</inputEncoding>
304+
<outputEncoding>UTF-8</outputEncoding>
305+
</configuration>
306+
</plugin>
307+
<plugin>
308+
<groupId>org.apache.maven.plugins</groupId>
309+
<artifactId>maven-surefire-report-plugin</artifactId>
310+
<version>2.5</version>
311+
</plugin>
312+
</plugins>
313+
</reporting>
314+
</profile>
315+
</profiles>
302316
</project>

src/it/lift/verify.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ if (testSummaryLines.size == 0) {
1717
throw new Exception("Found more than one scalatest summary line in build.log")
1818
}
1919

20-
if (testSummaryLines[0].contains("Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0")) {
20+
def theLine = testSummaryLines[0]
21+
22+
if (theLine.isEmpty()) {
23+
throw new Exception("Could not find scalatest's non empty summary line in build.log")
24+
}
25+
26+
if (theLine.contains("Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0")) {
2127
throw new Exception("No tests were run by scalatest!")
2228
}
2329

src/it/redirect-output/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# redirect output
2+
3+
This project is part of scalatest-maven-plugin's suite of integration tests. It is meant to check that scalatest-maven-plugin can run for projects that use test output redirect.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# A comma or space separated list of goals/phases to execute, may
2+
# specify an empty list to execute the default goal of the IT project
3+
invoker.goals = clean test

src/it/redirect-output/pom.xml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>redirect-output-it</artifactId>
5+
<version>1.0-SNAPSHOT</version>
6+
<packaging>jar</packaging>
7+
<name>redirect-output</name>
8+
<description>Runs the plugin for a project that uses test output redirect.</description>
9+
10+
<parent>
11+
<groupId>maven.scalatest.plugin.its</groupId>
12+
<artifactId>it-parent</artifactId>
13+
<version>1.0-SNAPSHOT</version>
14+
<relativePath>../it-parent</relativePath>
15+
</parent>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.scala-lang</groupId>
20+
<artifactId>scala-library</artifactId>
21+
<version>@scala.version@</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.scalatest</groupId>
25+
<artifactId>[email protected]@</artifactId>
26+
<version>@scalatest.version@</version>
27+
<scope>test</scope>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<sourceDirectory>src/main/scala</sourceDirectory>
33+
<testSourceDirectory>src/test/scala</testSourceDirectory>
34+
<plugins>
35+
<plugin>
36+
<groupId>net.alchim31.maven</groupId>
37+
<artifactId>scala-maven-plugin</artifactId>
38+
<version>@scala.maven.plugin.version@</version>
39+
<configuration>
40+
<recompileMode>incremental</recompileMode>
41+
<scalaVersion>${scala.version}</scalaVersion>
42+
</configuration>
43+
<executions>
44+
<execution>
45+
<id>scala-compile</id>
46+
<phase>process-resources</phase>
47+
<goals>
48+
<goal>add-source</goal>
49+
<goal>compile</goal>
50+
</goals>
51+
</execution>
52+
<execution>
53+
<id>scala-test-compile</id>
54+
<phase>process-test-resources</phase>
55+
<goals>
56+
<goal>testCompile</goal>
57+
</goals>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
<!-- disable surefire -->
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-surefire-plugin</artifactId>
65+
<version>2.7</version>
66+
<configuration>
67+
<skipTests>true</skipTests>
68+
</configuration>
69+
</plugin>
70+
<!-- enable scalatest -->
71+
<plugin>
72+
<groupId>org.scalatest</groupId>
73+
<artifactId>scalatest-maven-plugin</artifactId>
74+
<configuration>
75+
<logForkedProcessCommand>true</logForkedProcessCommand>
76+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
77+
</configuration>
78+
<executions>
79+
<execution>
80+
<goals>
81+
<goal>test</goal>
82+
</goals>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
<reporting>
89+
<plugins>
90+
<plugin>
91+
<groupId>org.scalatest</groupId>
92+
<artifactId>scalatest-maven-plugin</artifactId>
93+
</plugin>
94+
</plugins>
95+
</reporting>
96+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.example
2+
3+
class App {
4+
def runApp(): String = {
5+
"It ran!"
6+
}
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.example
2+
3+
import org.scalatest.{FlatSpec, Matchers}
4+
5+
class AppTest extends FlatSpec with Matchers {
6+
"Our example App" should "run" in {
7+
val app = new App
8+
app.runApp() shouldBe "It ran!"
9+
}
10+
}

0 commit comments

Comments
 (0)