Skip to content

Commit 8989cf8

Browse files
chetanmehgslowikowski
authored andcommitted
Look for specific version of plugin
1 parent 24546c5 commit 8989cf8

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@
5858
* <br>
5959
* This is internal mojo, executed in forked {@code scoverage} life cycle.
6060
* <br>
61-
*
61+
*
6262
* @author <a href="mailto:[email protected]">Grzegorz Slowikowski</a>
6363
* @since 1.0.0
6464
*/
65-
@Mojo( name = "pre-compile", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
65+
@Mojo( name = "pre-compile", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
6666
public class SCoveragePreCompileMojo
6767
extends AbstractMojo
6868
{
6969

7070
/**
7171
* Allows SCoverage to be skipped.
7272
* <br>
73-
*
73+
*
7474
* @since 1.0.0
7575
*/
7676
@Parameter( property = "scoverage.skip", defaultValue = "false" )
@@ -85,7 +85,7 @@ public class SCoveragePreCompileMojo
8585
* <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>
8686
* <li>if specified, but does not meet any of the above conditions or if not specified - plugin execution will be skipped</li>
8787
* </ul>
88-
*
88+
*
8989
* @since 1.0.0
9090
*/
9191
@Parameter( property = "scala.version" )
@@ -129,7 +129,7 @@ public class SCoveragePreCompileMojo
129129
/**
130130
* See <a href="https://github.com/scoverage/sbt-scoverage#highlighting">https://github.com/scoverage/sbt-scoverage#highlighting</a>.
131131
* <br>
132-
*
132+
*
133133
* @since 1.0.0
134134
*/
135135
@Parameter( property = "scoverage.highlighting", defaultValue = "true" )
@@ -202,7 +202,7 @@ public class SCoveragePreCompileMojo
202202

203203
/**
204204
* Configures project for compilation with SCoverage instrumentation.
205-
*
205+
*
206206
* @throws MojoExecutionException if unexpected problem occurs
207207
*/
208208
@Override
@@ -293,7 +293,7 @@ else if ( "2.13".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWi
293293

294294
try
295295
{
296-
Artifact pluginArtifact = getScalaScoveragePluginArtifact( scalaBinaryVersion );
296+
Artifact pluginArtifact = getScalaScoveragePluginArtifact( scalaBinaryVersion, resolvedScalaVersion );
297297
Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact( scalaBinaryVersion );
298298

299299
if ( pluginArtifact == null )
@@ -434,7 +434,7 @@ private void setProperty( Properties projectProperties, String propertyName, Str
434434
}
435435
}
436436

437-
private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion )
437+
private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion, String resolvedScalaVersion )
438438
throws ArtifactNotFoundException, ArtifactResolutionException
439439
{
440440
Artifact result = null;
@@ -457,9 +457,20 @@ private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion )
457457
}
458458
}
459459

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+
463474
return result;
464475
}
465476

0 commit comments

Comments
 (0)