58
58
* <br>
59
59
* This is internal mojo, executed in forked {@code scoverage} life cycle.
60
60
* <br>
61
- *
61
+ *
62
62
* @author <a href="mailto:[email protected] ">Grzegorz Slowikowski</a>
63
63
* @since 1.0.0
64
64
*/
65
- @ Mojo ( name = "pre-compile" , defaultPhase = LifecyclePhase .GENERATE_RESOURCES )
65
+ @ Mojo ( name = "pre-compile" , defaultPhase = LifecyclePhase .GENERATE_RESOURCES )
66
66
public class SCoveragePreCompileMojo
67
67
extends AbstractMojo
68
68
{
69
69
70
70
/**
71
71
* Allows SCoverage to be skipped.
72
72
* <br>
73
- *
73
+ *
74
74
* @since 1.0.0
75
75
*/
76
76
@ Parameter ( property = "scoverage.skip" , defaultValue = "false" )
@@ -85,7 +85,7 @@ public class SCoveragePreCompileMojo
85
85
* <li>if specified, and equals {@code 2.13} or starts with {@code 2.13.} - <b>{@code scalac-scoverage-plugin_2.13}</b> will be used</li>
86
86
* <li>if specified, but does not meet any of the above conditions or if not specified - plugin execution will be skipped</li>
87
87
* </ul>
88
- *
88
+ *
89
89
* @since 1.0.0
90
90
*/
91
91
@ Parameter ( property = "scala.version" )
@@ -129,7 +129,7 @@ public class SCoveragePreCompileMojo
129
129
/**
130
130
* See <a href="https://github.com/scoverage/sbt-scoverage#highlighting">https://github.com/scoverage/sbt-scoverage#highlighting</a>.
131
131
* <br>
132
- *
132
+ *
133
133
* @since 1.0.0
134
134
*/
135
135
@ Parameter ( property = "scoverage.highlighting" , defaultValue = "true" )
@@ -202,7 +202,7 @@ public class SCoveragePreCompileMojo
202
202
203
203
/**
204
204
* Configures project for compilation with SCoverage instrumentation.
205
- *
205
+ *
206
206
* @throws MojoExecutionException if unexpected problem occurs
207
207
*/
208
208
@ Override
@@ -293,7 +293,7 @@ else if ( "2.13".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWi
293
293
294
294
try
295
295
{
296
- Artifact pluginArtifact = getScalaScoveragePluginArtifact ( scalaBinaryVersion );
296
+ Artifact pluginArtifact = getScalaScoveragePluginArtifact ( scalaBinaryVersion , resolvedScalaVersion );
297
297
Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact ( scalaBinaryVersion );
298
298
299
299
if ( pluginArtifact == null )
@@ -434,7 +434,7 @@ private void setProperty( Properties projectProperties, String propertyName, Str
434
434
}
435
435
}
436
436
437
- private Artifact getScalaScoveragePluginArtifact ( String scalaMainVersion )
437
+ private Artifact getScalaScoveragePluginArtifact ( String scalaMainVersion , String resolvedScalaVersion )
438
438
throws ArtifactNotFoundException , ArtifactResolutionException
439
439
{
440
440
Artifact result = null ;
@@ -457,9 +457,20 @@ private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion )
457
457
}
458
458
}
459
459
460
- result =
461
- getResolvedArtifact ( "org.scoverage" , "scalac-scoverage-plugin_" + scalaMainVersion ,
462
- resolvedScalacPluginVersion );
460
+ try
461
+ {
462
+ // Look for plugin artifact matching the scala version (full form like 2.12.14)
463
+ // If not found then look for artifact based on major version like 2.12
464
+ result =
465
+ getResolvedArtifact ( "org.scoverage" , "scalac-scoverage-plugin_" + resolvedScalaVersion ,
466
+ resolvedScalacPluginVersion );
467
+ } catch (ArtifactNotFoundException e )
468
+ {
469
+ result =
470
+ getResolvedArtifact ( "org.scoverage" , "scalac-scoverage-plugin_" + scalaMainVersion ,
471
+ resolvedScalacPluginVersion );
472
+ }
473
+
463
474
return result ;
464
475
}
465
476
0 commit comments