@@ -77,14 +77,7 @@ public class SCoveragePreCompileMojo
77
77
private boolean skip ;
78
78
79
79
/**
80
- * Scala version used for compiler plugin artifact resolution.
81
- * <ul>
82
- * <li>if specified, and equals {@code 2.10} or starts with {@code 2.10.} - <b>{@code scalac-scoverage-plugin_2.10}</b> will be used</li>
83
- * <li>if specified, and equals {@code 2.11} or starts with {@code 2.11.} - <b>{@code scalac-scoverage-plugin_2.11}</b> will be used</li>
84
- * <li>if specified, and equals {@code 2.12} or starts with {@code 2.12.} - <b>{@code scalac-scoverage-plugin_2.12}</b> will be used</li>
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
- * <li>if specified, but does not meet any of the above conditions or if not specified - plugin execution will be skipped</li>
87
- * </ul>
80
+ * Scala version used for scalac compiler plugin artifact resolution.
88
81
*
89
82
* @since 1.0.0
90
83
*/
@@ -293,7 +286,7 @@ else if ( "2.13".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWi
293
286
294
287
try
295
288
{
296
- Artifact pluginArtifact = getScalaScoveragePluginArtifact ( scalaBinaryVersion , resolvedScalaVersion );
289
+ Artifact pluginArtifact = getScalaScoveragePluginArtifact ( resolvedScalaVersion , scalaBinaryVersion );
297
290
Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact ( scalaBinaryVersion );
298
291
299
292
if ( pluginArtifact == null )
@@ -434,23 +427,17 @@ private void setProperty( Properties projectProperties, String propertyName, Str
434
427
}
435
428
}
436
429
437
- private Artifact getScalaScoveragePluginArtifact ( String scalaMainVersion , String resolvedScalaVersion )
430
+ private Artifact getScalaScoveragePluginArtifact ( String resolvedScalaVersion , String scalaMainVersion )
438
431
throws ArtifactNotFoundException , ArtifactResolutionException
439
432
{
440
- Artifact result = null ;
441
-
442
433
String resolvedScalacPluginVersion = scalacPluginVersion ;
443
434
if ( resolvedScalacPluginVersion == null || "" .equals ( resolvedScalacPluginVersion ) )
444
435
{
445
436
for ( Artifact artifact : pluginArtifacts )
446
437
{
447
438
if ( "org.scoverage" .equals ( artifact .getGroupId () )
448
- && "scalac-scoverage-plugin_2.12" . equals ( artifact . getArtifactId () ) )
439
+ && artifact . getArtifactId (). startsWith ( "scalac-scoverage-plugin_" ) )
449
440
{
450
- if ( "2.12" .equals ( scalaMainVersion ) )
451
- {
452
- return artifact ; // shortcut, use the same artifact plugin uses
453
- }
454
441
resolvedScalacPluginVersion = artifact .getVersion ();
455
442
break ;
456
443
}
@@ -459,44 +446,39 @@ private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion, Strin
459
446
460
447
try
461
448
{
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 )
449
+ return getResolvedArtifact (
450
+ "org.scoverage" , "scalac-scoverage-plugin_" + resolvedScalaVersion ,
451
+ resolvedScalacPluginVersion );
452
+ }
453
+ catch ( ArtifactNotFoundException | ArtifactResolutionException e )
468
454
{
469
- result =
470
- getResolvedArtifact ( "org.scoverage" , "scalac-scoverage-plugin_" + scalaMainVersion ,
471
- resolvedScalacPluginVersion );
455
+ // for scalac-scoverage-plugin versions up to 1.4.1
456
+ return getResolvedArtifact (
457
+ "org.scoverage" , "scalac-scoverage-plugin_" + scalaMainVersion ,
458
+ resolvedScalacPluginVersion );
472
459
}
473
-
474
- return result ;
475
460
}
476
461
477
462
private Artifact getScalaScoverageRuntimeArtifact ( String scalaMainVersion )
478
463
throws ArtifactNotFoundException , ArtifactResolutionException
479
464
{
480
- Artifact result = null ;
481
-
482
465
String resolvedScalacRuntimeVersion = scalacPluginVersion ;
483
466
if ( resolvedScalacRuntimeVersion == null || "" .equals ( resolvedScalacRuntimeVersion ) )
484
467
{
485
468
for ( Artifact artifact : pluginArtifacts )
486
469
{
487
470
if ( "org.scoverage" .equals ( artifact .getGroupId () )
488
- && "scalac-scoverage-plugin_2.12" . equals ( artifact . getArtifactId () ) )
471
+ && artifact . getArtifactId (). startsWith ( "scalac-scoverage-plugin_" ) )
489
472
{
490
473
resolvedScalacRuntimeVersion = artifact .getVersion ();
491
474
break ;
492
475
}
493
476
}
494
477
}
495
478
496
- result =
497
- getResolvedArtifact ( "org.scoverage" , "scalac-scoverage-runtime_" + scalaMainVersion ,
498
- resolvedScalacRuntimeVersion );
499
- return result ;
479
+ return getResolvedArtifact (
480
+ "org.scoverage" , "scalac-scoverage-runtime_" + scalaMainVersion ,
481
+ resolvedScalacRuntimeVersion );
500
482
}
501
483
502
484
/**
@@ -505,7 +487,6 @@ private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion )
505
487
* @throws MojoExecutionException
506
488
*/
507
489
private void addScoverageDependenciesToClasspath ( Artifact scalaScoveragePluginArtifact )
508
- throws MojoExecutionException
509
490
{
510
491
@ SuppressWarnings ( "unchecked" )
511
492
Set <Artifact > set = new LinkedHashSet <Artifact >( project .getDependencyArtifacts () );
0 commit comments