@@ -17,6 +17,18 @@ import org.gradle.api.tasks.testing.Test
1717 */
1818class ScoverageExtension {
1919
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+
2032 /* * a directory to write working files to */
2133 File dataDir
2234 /* * a directory to write final output to */
@@ -83,24 +95,22 @@ class ScoverageExtension {
8395 FileCollection pluginDependencies = configuration. filter { it != pluginFile }
8496
8597 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)
92102 }
93- plugin . add(" -P:scoverage:dataDir:${ extension.dataDir.absolutePath} " . toString())
103+ parameters . add(" -P:scoverage:dataDir:${ extension.dataDir.absolutePath} " . toString())
94104 if (extension. excludedPackages) {
95- plugin . add(" -P:scoverage:excludedPackages:${ extension.excludedPackages.join(';')} " . toString())
105+ parameters . add(" -P:scoverage:excludedPackages:${ extension.excludedPackages.join(';')} " . toString())
96106 }
97107 if (extension. excludedFiles) {
98- plugin . add(" -P:scoverage:excludedFiles:${ extension.excludedFiles.join(';')} " . toString())
108+ parameters . add(" -P:scoverage:excludedFiles:${ extension.excludedFiles.join(';')} " . toString())
99109 }
100110 if (extension. highlighting) {
101- plugin . add(' -Yrangepos' )
111+ parameters . add(' -Yrangepos' )
102112 }
103- scalaCompileOptions. additionalParameters = plugin
113+ scalaCompileOptions. additionalParameters = parameters . collect { escape(it) }
104114 // exclude the scala libraries that are added to enable scala version detection
105115 classpath + = pluginDependencies
106116 }
0 commit comments