Skip to content

Consider scala patch version for scalac-scoverage-plugin #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@
* <br>
* This is internal mojo, executed in forked {@code scoverage} life cycle.
* <br>
*
*
* @author <a href="mailto:[email protected]">Grzegorz Slowikowski</a>
* @since 1.0.0
*/
@Mojo( name = "pre-compile", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
@Mojo( name = "pre-compile", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
public class SCoveragePreCompileMojo
extends AbstractMojo
{

/**
* Allows SCoverage to be skipped.
* <br>
*
*
* @since 1.0.0
*/
@Parameter( property = "scoverage.skip", defaultValue = "false" )
Expand All @@ -85,7 +85,7 @@ public class SCoveragePreCompileMojo
* <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>
* <li>if specified, but does not meet any of the above conditions or if not specified - plugin execution will be skipped</li>
* </ul>
*
*
* @since 1.0.0
*/
@Parameter( property = "scala.version" )
Expand Down Expand Up @@ -129,7 +129,7 @@ public class SCoveragePreCompileMojo
/**
* See <a href="https://github.com/scoverage/sbt-scoverage#highlighting">https://github.com/scoverage/sbt-scoverage#highlighting</a>.
* <br>
*
*
* @since 1.0.0
*/
@Parameter( property = "scoverage.highlighting", defaultValue = "true" )
Expand Down Expand Up @@ -202,7 +202,7 @@ public class SCoveragePreCompileMojo

/**
* Configures project for compilation with SCoverage instrumentation.
*
*
* @throws MojoExecutionException if unexpected problem occurs
*/
@Override
Expand Down Expand Up @@ -293,7 +293,7 @@ else if ( "2.13".equals( resolvedScalaVersion ) || resolvedScalaVersion.startsWi

try
{
Artifact pluginArtifact = getScalaScoveragePluginArtifact( scalaBinaryVersion );
Artifact pluginArtifact = getScalaScoveragePluginArtifact( scalaBinaryVersion, resolvedScalaVersion );
Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact( scalaBinaryVersion );

if ( pluginArtifact == null )
Expand Down Expand Up @@ -434,7 +434,7 @@ private void setProperty( Properties projectProperties, String propertyName, Str
}
}

private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion )
private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion, String resolvedScalaVersion )
throws ArtifactNotFoundException, ArtifactResolutionException
{
Artifact result = null;
Expand All @@ -457,9 +457,20 @@ private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion )
}
}

result =
getResolvedArtifact( "org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion,
resolvedScalacPluginVersion );
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an exception were thrown from both the above try-block the below catch-block caught, then the error message will only report not finding the scalaMainVersion (rather than both the scalaMainVersion and resolvedScalaVersion).

(I could be wrong though. Even if my comment is correct I don't whether a slightly inaccurate error message would be considered a good reason to block the pull request.)

{
result =
getResolvedArtifact( "org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion,
resolvedScalacPluginVersion );
}

return result;
}

Expand Down