@@ -27,7 +27,6 @@ class ScoveragePlugin implements Plugin<PluginAware> {
27
27
28
28
static final String DEFAULT_REPORT_DIR = ' reports' + File . separatorChar + ' scoverage'
29
29
30
- private volatile File pluginFile = null
31
30
private final ConcurrentHashMap<Task , Set<? extends Task > > taskDependencies = new ConcurrentHashMap<> ();
32
31
33
32
@Override
@@ -172,13 +171,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
172
171
}
173
172
174
173
compileTask. configure {
175
- if (pluginFile == null ) {
176
- pluginFile = project. configurations[CONFIGURATION_NAME ]. find {
177
- it. name. startsWith(" scalac-scoverage-plugin" )
178
- }
179
- }
180
-
181
- List<String > parameters = [' -Xplugin:' + pluginFile. absolutePath]
174
+ List<String > parameters = []
182
175
List<String > existingParameters = scalaCompileOptions. additionalParameters
183
176
if (existingParameters) {
184
177
parameters. addAll(existingParameters)
@@ -198,6 +191,18 @@ class ScoveragePlugin implements Plugin<PluginAware> {
198
191
scalaCompileOptions. additionalParameters = parameters
199
192
// the compile task creates a store of measured statements
200
193
outputs. file(new File (extension. dataDir. get(), ' scoverage.coverage.xml' ))
194
+
195
+ dependsOn project. configurations[CONFIGURATION_NAME ]
196
+ doFirst {
197
+ /*
198
+ It is crucial that this would run in `doFirst`, as this resolves the (dependencies of the)
199
+ configuration, which we do not want to do at configuration time (but only at execution time).
200
+ */
201
+ def pluginFile = project. configurations[CONFIGURATION_NAME ]. find {
202
+ it. name. startsWith(" scalac-scoverage-plugin" )
203
+ }
204
+ scalaCompileOptions. additionalParameters. add(' -Xplugin:' + pluginFile. absolutePath)
205
+ }
201
206
}
202
207
203
208
project. gradle. taskGraph. whenReady { graph ->
0 commit comments