@@ -17,6 +17,18 @@ import org.gradle.api.tasks.testing.Test
17
17
*/
18
18
class ScoverageExtension {
19
19
20
+ private static boolean isEscaped (String argument ) {
21
+ return (argument. startsWith(' "' ) && argument. endsWith(' "' )) || (argument. startsWith(' \' ' ) && argument. endsWith(' \' ' ))
22
+ }
23
+
24
+ static String escape (String argument ) {
25
+ if (isEscaped(argument)) {
26
+ return argument
27
+ } else {
28
+ return " \" $argument \" "
29
+ }
30
+ }
31
+
20
32
/* * a directory to write working files to */
21
33
File dataDir
22
34
/* * a directory to write final output to */
@@ -83,24 +95,22 @@ class ScoverageExtension {
83
95
FileCollection pluginDependencies = configuration. filter { it != pluginFile }
84
96
85
97
t. tasks[ScoveragePlugin . COMPILE_NAME ]. configure {
86
-
87
-
88
- List<String > plugin = [' -Xplugin:' + pluginFile. absolutePath]
89
- List<String > parameters = scalaCompileOptions. additionalParameters
90
- if (parameters != null ) {
91
- plugin. addAll(parameters)
98
+ List<String > parameters = [' -Xplugin:' + pluginFile. absolutePath]
99
+ List<String > existingParameters = scalaCompileOptions. additionalParameters
100
+ if (existingParameters) {
101
+ parameters. addAll(existingParameters)
92
102
}
93
- plugin . add(" -P:scoverage:dataDir:${ extension.dataDir.absolutePath} " . toString())
103
+ parameters . add(" -P:scoverage:dataDir:${ extension.dataDir.absolutePath} " . toString())
94
104
if (extension. excludedPackages) {
95
- plugin . add(" -P:scoverage:excludedPackages:${ extension.excludedPackages.join(';')} " . toString())
105
+ parameters . add(" -P:scoverage:excludedPackages:${ extension.excludedPackages.join(';')} " . toString())
96
106
}
97
107
if (extension. excludedFiles) {
98
- plugin . add(" -P:scoverage:excludedFiles:${ extension.excludedFiles.join(';')} " . toString())
108
+ parameters . add(" -P:scoverage:excludedFiles:${ extension.excludedFiles.join(';')} " . toString())
99
109
}
100
110
if (extension. highlighting) {
101
- plugin . add(' -Yrangepos' )
111
+ parameters . add(' -Yrangepos' )
102
112
}
103
- scalaCompileOptions. additionalParameters = plugin
113
+ scalaCompileOptions. additionalParameters = parameters . collect { escape(it) }
104
114
// exclude the scala libraries that are added to enable scala version detection
105
115
classpath + = pluginDependencies
106
116
}
0 commit comments