diff --git a/pom.xml b/pom.xml index 07031eb3..24f3421b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. 4.0.0 org.scoverage scoverage-maven-plugin - 1.4.2-SNAPSHOT + 1.4.11-SNAPSHOT maven-plugin SCoverage Maven Plugin @@ -90,13 +90,14 @@ under the License. 2.2.1 3.6.0 - 1.4.1 + 1.4.11 + 2.12.15 org.scoverage - scalac-scoverage-plugin_2.12 + scalac-scoverage-plugin_${scalac-scoverage-plugin.scala.version} ${scalac-scoverage-plugin.version} @@ -245,7 +246,7 @@ under the License. maven-javadoc-plugin 3.0.1 - 1.6 + 1.8 false org.scoverage.plugin @@ -539,8 +540,8 @@ under the License. - 1.6 - Java 1.6 or later required. + 1.8 + Java 1.8 or later required. diff --git a/src/main/java/org/scoverage/plugin/SCoverageCheckMojo.java b/src/main/java/org/scoverage/plugin/SCoverageCheckMojo.java index b80d0ebe..9f0f7ce4 100644 --- a/src/main/java/org/scoverage/plugin/SCoverageCheckMojo.java +++ b/src/main/java/org/scoverage/plugin/SCoverageCheckMojo.java @@ -29,6 +29,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import scala.Tuple2; import scala.collection.JavaConverters; import scoverage.Coverage; @@ -149,7 +150,8 @@ public void execute() throws MojoFailureException Coverage coverage = Serializer.deserialize( coverageFile ); List measurementFiles = Arrays.asList( IOUtils.findMeasurementFiles( dataDirectory ) ); - scala.collection.Set measurements = IOUtils.invoked( JavaConverters.asScalaBuffer( measurementFiles ) ); + scala.collection.Set> measurements = + IOUtils.invoked( JavaConverters.asScalaBuffer( measurementFiles ) ); coverage.apply( measurements ); int branchCount = coverage.branchCount(); diff --git a/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java b/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java index b77d8e30..813b8229 100644 --- a/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java +++ b/src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java @@ -77,14 +77,7 @@ public class SCoveragePreCompileMojo private boolean skip; /** - * Scala version used for compiler plugin artifact resolution. - *
    - *
  • if specified, and equals {@code 2.10} or starts with {@code 2.10.} - {@code scalac-scoverage-plugin_2.10} will be used
  • - *
  • if specified, and equals {@code 2.11} or starts with {@code 2.11.} - {@code scalac-scoverage-plugin_2.11} will be used
  • - *
  • if specified, and equals {@code 2.12} or starts with {@code 2.12.} - {@code scalac-scoverage-plugin_2.12} will be used
  • - *
  • if specified, and equals {@code 2.13} or starts with {@code 2.13.} - {@code scalac-scoverage-plugin_2.13} will be used
  • - *
  • if specified, but does not meet any of the above conditions or if not specified - plugin execution will be skipped
  • - *
+ * Scala version used for scalac compiler plugin artifact resolution. * * @since 1.0.0 */ @@ -293,7 +286,7 @@ else if ( "2.13".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWi try { - Artifact pluginArtifact = getScalaScoveragePluginArtifact( scalaBinaryVersion, resolvedScalaVersion ); + Artifact pluginArtifact = getScalaScoveragePluginArtifact( resolvedScalaVersion, scalaBinaryVersion ); Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact( scalaBinaryVersion ); if ( pluginArtifact == null ) @@ -434,23 +427,17 @@ private void setProperty( Properties projectProperties, String propertyName, Str } } - private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion, String resolvedScalaVersion ) + private Artifact getScalaScoveragePluginArtifact( String resolvedScalaVersion, String scalaMainVersion ) throws ArtifactNotFoundException, ArtifactResolutionException { - Artifact result = null; - String resolvedScalacPluginVersion = scalacPluginVersion; if ( resolvedScalacPluginVersion == null || "".equals( resolvedScalacPluginVersion ) ) { for ( Artifact artifact : pluginArtifacts ) { if ( "org.scoverage".equals( artifact.getGroupId() ) - && "scalac-scoverage-plugin_2.12".equals( artifact.getArtifactId() ) ) + && artifact.getArtifactId().startsWith( "scalac-scoverage-plugin_" ) ) { - if ( "2.12".equals( scalaMainVersion ) ) - { - return artifact; // shortcut, use the same artifact plugin uses - } resolvedScalacPluginVersion = artifact.getVersion(); break; } @@ -459,33 +446,29 @@ private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion, Strin try { - // Look for plugin artifact matching the scala version (full form like 2.12.14) - // If not found then look for artifact based on major version like 2.12 - result = - getResolvedArtifact( "org.scoverage", "scalac-scoverage-plugin_" + resolvedScalaVersion, - resolvedScalacPluginVersion ); - } catch (ArtifactNotFoundException e) + return getResolvedArtifact( + "org.scoverage", "scalac-scoverage-plugin_" + resolvedScalaVersion, + resolvedScalacPluginVersion ); + } + catch ( ArtifactNotFoundException | ArtifactResolutionException e ) { - result = - getResolvedArtifact( "org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion, - resolvedScalacPluginVersion ); + // for scalac-scoverage-plugin versions up to 1.4.1 + return getResolvedArtifact( + "org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion, + resolvedScalacPluginVersion ); } - - return result; } private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion ) throws ArtifactNotFoundException, ArtifactResolutionException { - Artifact result = null; - String resolvedScalacRuntimeVersion = scalacPluginVersion; if ( resolvedScalacRuntimeVersion == null || "".equals( resolvedScalacRuntimeVersion ) ) { for ( Artifact artifact : pluginArtifacts ) { if ( "org.scoverage".equals( artifact.getGroupId() ) - && "scalac-scoverage-plugin_2.12".equals( artifact.getArtifactId() ) ) + && artifact.getArtifactId().startsWith( "scalac-scoverage-plugin_" ) ) { resolvedScalacRuntimeVersion = artifact.getVersion(); break; @@ -493,10 +476,9 @@ private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion ) } } - result = - getResolvedArtifact( "org.scoverage", "scalac-scoverage-runtime_" + scalaMainVersion, - resolvedScalacRuntimeVersion ); - return result; + return getResolvedArtifact( + "org.scoverage", "scalac-scoverage-runtime_" + scalaMainVersion, + resolvedScalacRuntimeVersion ); } /** @@ -505,7 +487,6 @@ private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion ) * @throws MojoExecutionException */ private void addScoverageDependenciesToClasspath( Artifact scalaScoveragePluginArtifact ) - throws MojoExecutionException { @SuppressWarnings( "unchecked" ) Set set = new LinkedHashSet( project.getDependencyArtifacts() ); diff --git a/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java b/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java index 135ffb01..3e9003fc 100644 --- a/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java +++ b/src/main/java/org/scoverage/plugin/SCoverageReportMojo.java @@ -44,6 +44,7 @@ import org.codehaus.plexus.util.StringUtils; import scala.Option; +import scala.Tuple2; import scala.collection.JavaConverters; import scala.collection.Seq; @@ -422,7 +423,8 @@ private void generateReports() getLog().info( String.format( "Reading scoverage measurements [%s*]...", new File( dataDirectory, Constants.MeasurementsPrefix() ).getAbsolutePath() ) ); List measurementFiles = Arrays.asList( IOUtils.findMeasurementFiles( dataDirectory ) ); - scala.collection.Set measurements = IOUtils.invoked( JavaConverters.asScalaBuffer( measurementFiles ) ); + scala.collection.Set> measurements = + IOUtils.invoked( JavaConverters.asScalaBuffer( measurementFiles ) ); coverage.apply( measurements ); getLog().info( "Generating coverage reports..." );