-
Notifications
You must be signed in to change notification settings - Fork 48
Added support for scalac-scoverage-plugin > 2.0.0 #107
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
Added support for scalac-scoverage-plugin > 2.0.0 #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found two small items which you might want to look at, before merging.
@@ -457,9 +461,9 @@ private Artifact getScalaScoveragePluginArtifact( String resolvedScalaVersion, S | |||
resolvedScalaVersion, resolvedScalacPluginVersion, scalaMainVersion, resolvedScalacPluginVersion ) ); | |||
|
|||
// for scalac-scoverage-plugin versions up to 1.4.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment should be amended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the code to have specific cases for the versions of scalac-scoverage-plugin that were published.
Artifact runtimeArtifact = getScalaScoverageRuntimeArtifact( scalaBinaryVersion ); | ||
|
||
if ( pluginArtifact == null ) | ||
if ( pluginArtifacts == null ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null check looks redundant - I see no code path which dumps a null into this variable. You may want to check for an empty List though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this check now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pr @samantmaharaj. I just let CI run, but it looks like you have some issues. Could you rebase (I just merged a handful of updates) and then address the failing CI. Feel free to ping me when ready for another review.
…verage-plugin Improved comment explaining the artifact resolution process Removed unnecessary null check
d4014d0
to
63e0174
Compare
Hi Chris, The failing part of the CI is the animal sniffer Java API check. Are we targeting a 1.6 API? If so, I'll modify the code to not use Streams. |
No, we can target >= 8. |
@@ -380,7 +380,7 @@ under the License. | |||
<configuration> | |||
<signature> | |||
<groupId>org.codehaus.mojo.signature</groupId> | |||
<artifactId>java16</artifactId> | |||
<artifactId>java18</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to targeting Java 1.8
<scalac-scoverage-plugin.version>1.4.11</scalac-scoverage-plugin.version> | ||
<scalac-scoverage-plugin.scala.version>2.12.15</scalac-scoverage-plugin.scala.version> | ||
<scalac-scoverage-plugin.version>2.0.7</scalac-scoverage-plugin.version> | ||
<scalac-scoverage-plugin.scala.version>2.13</scalac-scoverage-plugin.scala.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may have to be pinned to e.g. 2.13.10, to actually work? (going by available maven coordinates)
You may also want to bump the plugin version to 2.0.8 already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is only being used by the reporter down below, which doesn't need to be the exact version of Scala, only the binary 2.12, 2.13, or 3. The actual compiler plugin is what needs to be the full version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referencing that in the variable name would make it unmistakable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the logic that currently exists in resolveScalaVersion()
will fall apart with Scala 3 builds since the Scala library version you're searching for will never be 3. You'll need to detect Scala 3 in order to not break Maven builds that are using Scala 3. Furthermore, in that case where a user has Scala 3 you also don't need to include the plugin and instead rely on the actual compiler to generate the coverage data.
I know there might be the desire to split that and the update to 2.0.0 apart, but I think it might be a bit dangerous to do that since the logic currently will break for Scala 3 builds. Unless you think that risk is worth it, and then we can just merge in general support for 2.0.0 only for Scala 2, but we should then issue a warning that Scala 3 isn't yet supported.
<scalac-scoverage-plugin.version>1.4.11</scalac-scoverage-plugin.version> | ||
<scalac-scoverage-plugin.scala.version>2.12.15</scalac-scoverage-plugin.scala.version> | ||
<scalac-scoverage-plugin.version>2.0.7</scalac-scoverage-plugin.version> | ||
<scalac-scoverage-plugin.scala.version>2.13</scalac-scoverage-plugin.scala.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is only being used by the reporter down below, which doesn't need to be the exact version of Scala, only the binary 2.12, 2.13, or 3. The actual compiler plugin is what needs to be the full version.
Given there's no support for Scala 3 at the moment, it would probably be better to implement that explicitly in another PR. |
Correct, but we should still warn right now in the case that someone tries this with Scala 3. Or what is the behavior currently? The worse thing would be silent failure because it will just lead to more issues being created and confusion about why it's not working. |
final ArtifactVersion pluginArtifactVersion = new DefaultArtifactVersion(resolvedScalacPluginVersion); | ||
if(pluginArtifactVersion.getMajorVersion() >= 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final ArtifactVersion pluginArtifactVersion = new DefaultArtifactVersion(resolvedScalacPluginVersion); | |
if(pluginArtifactVersion.getMajorVersion() >= 2) { | |
final ArtifactVersion pluginArtifactVersion = new DefaultArtifactVersion(resolvedScalacPluginVersion); | |
if(pluginArtifactVersion.getMajorVersion() > 2) { | |
throw new IllegalArgumentException("Currently Scala version 3 or above are not supported by this Maven plugin. Detected Scala version from scoverage-plugin-version: " + pluginArtifactVersion.getMajorVersion()); | |
} | |
if(pluginArtifactVersion.getMajorVersion() == 2) { |
I guess something like this would make the failure more evident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given there's no support for Scala 3 at the moment, it would probably be better to implement that explicitly in another PR.
Correct, but we should still warn right now in the case that someone tries this with Scala 3. Or what is the behavior currently? The worse thing would be silent failure because it will just lead to more issues being created and confusion about why it's not working.
The current behaviour will be to fail to resolve the scoverage compiler plugin for Scala 3 as no plugins are currently published newer than 2.13.10
(Link to MVNRepository here)
This will cause a build failure. It's not as nice as explicitly notifying the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess something like this would make the failure more evident?
The artifact version in the test you referenced is the version of the scoverage plugin. The scala version is calculated through resolveScalaVersion()
.
That function will default to an explicitly configured scala version or a search for the scala standard library. If I understand correctly, the Scala 3 standard library uses different coordinates from the earlier versions org.scala-lang:scala3-library
.
If the user is depending on the scala 3 standard library resolveScalaVersion()
will fail to detect the scala version resulting in a warning being emitted and the execution of the mojo being skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me that sounds like acceptable behavior - @ckipp01 since an explicit scala-3-warning would need explicit scala-3 detection, I would leave that to a separate fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me that sounds like acceptable behavior - @ckipp01 since an explicit scala-3-warning would need explicit scala-3 detection, I would leave that to a separate fix?
Sure that would be fine, but I'd for sure want to try to get that in before we attempt to do another release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so I'm alright with this with the caveat that I haven't tested it. I don't use Maven at all, so if possible give this a couple 👍🏼 if users out there have actually given this a try.
I built the branch, and tried to run coverage, but the compiler is failing:
because Once I got that in, made sure to get all the source roots populated, it worked! |
|
||
arg = PLUGIN_OPTION + pluginArtifact.getFile().getAbsolutePath(); | ||
arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(":")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this platform independent:
arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(":")); | |
arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(String.valueOf(java.io.File.pathSeparatorChar))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samantmaharaj could you amend this change to the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed that change now.
Hi Rick,
I'm travelling this week. I'll update the PR when I get back next week.
…On Thu, 6 Apr 2023 at 18:18, Rick Moritz ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java
<#107 (comment)>
:
>
- arg = PLUGIN_OPTION + pluginArtifact.getFile().getAbsolutePath();
+ arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(":"));
@samantmaharaj <https://github.com/samantmaharaj> could you amend this
change to the PR?
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGEVFDIZR5KHEABUTKMTREDW7Z34PANCNFSM6AAAAAAS7BHJOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@samantmaharaj Any updates on this PR? Thanks. |
Is there any update on this PR ? I think we're stuck because of this issue :( |
I committed the changes related to platform independent paths on the 23rd of May. Probably should have added a comment in the main thread. To my knowledge, that should resolve the last outstanding issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this locally on a big project with Scala 2.13.10 and it works as expected
@samantmaharaj I'm assuming you also tested that on you project(s) Thank you both! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this @samantmaharaj!
I'm super excited that this PR has been merged. |
It's always been @gslowikowski that has done the releases on these. Would it be possible for you to do a release @gslowikowski ? |
@gslowikowski would you please be so kind to release a new version? thank you! |
@gslowikowski Any update on a new version for this plugin with the changes in this PR ? |
It looks like @gslowikowski is not active (on this project) these days, maybe you could take the release over, @ckipp01? |
On vacation atm. When I get back lemme see what I can do. I should have all the access, just need to slowly go through everything and ensure that I do. |
Alright, I'm back and just gave this a spin, but something isn't working with the version of Maven I'm using and I have very little bandwith to debug something I don't use. Would someone that wants this out the door be willing to add a maven wrapper to this and instructions on what needs to be done? |
As in the Maven Wrapper from https://maven.apache.org/wrapper/? |
🤔 I'm having some issues with:
However I have no idea why
Anyone have any ideas on how to get this goal to succeed? |
I suggest upgrading to the latest version of the Maven plugin, i.e. |
Nope, in and of itself, this change was not enough and I still got the same error when running This UML graph plugin is like 10 years old: https://mvnrepository.com/artifact/org.umlgraph/umlgraph. PS: |
Oh, actually, I see that the CI setup is run with both Java 8 and 17. @ckipp01: to better understand the situation, what process / command do you use to make the release? |
I was basically following https://maven.apache.org/guides/mini/guide-releasing.html but got stuck at |
For the record, running
So what about simply using JDK 8 to make the release? |
I'm still hitting walls. At this point, I've sunk way more time into this than I want. @dalbani you are pretty active here, so if you want, I'm happy to add you as a maintainer here and just give you the creds to do the release. Is this something you're open to? If so, shoot me an email at open-source@chris-kipp.io |
@jozic I just sent you a request to add you to the maven team for scoverage. That should provide the access you need to merge and such. Feel free to shoot me an email if you want to help with the release and I can get you creds. |
Hey @ckipp01 |
👍🏼 send a message to both of you. You should have it and have everything you need. |
An immense thank you to @jozic for pulling it off with the release of the SCoverage Maven plugin v2.0.0! |
Since the 2.0.0 release, scalac-scoverage-plugin has been split into several modules. This has resulted in breaking changes that meant that the scoverage-maven-plugin could not use any version from the v2 series.
This PR implements the changes needed for compatibility with v2 onwards.
The changes are primarily repackaging changes and modifications needed to cope with scoverage no longer using absolute paths.
Reference to the scoverage changes:
scoverage/scalac-scoverage-plugin#368