Skip to content
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

Could not resolve org.scoverage:scalac-scoverage-plugin_2:1.3.1 #109

Closed
johanneshiry opened this issue Aug 28, 2019 · 12 comments
Closed

Could not resolve org.scoverage:scalac-scoverage-plugin_2:1.3.1 #109

johanneshiry opened this issue Aug 28, 2019 · 12 comments

Comments

@johanneshiry
Copy link

johanneshiry commented Aug 28, 2019

Hi,

I got an error when I tried to apply the plugin to one of my projects, that files for configuration ':scoverage' could not be resolved.

error message (excluded unrelated stuff)

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':scoverage'.
...
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.scoverage:scalac-scoverage-plugin_2:1.3.1.
Required by:
    project :
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.scoverage:scalac-scoverage-plugin_2:1.3.1.

project: mixed scala / java
gradle version: 5.4.1
scala version: 2.13
java version: 1.8

plugins in build.gradle:

plugins {
    id "com.jfrog.artifactory" version "4.9.7"
    id 'groovy' // groovy support
    id 'java' // java support
    id 'scala' // scala support
    id 'application' // creates a JVM executable
    id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
    id 'pmd' // code check, working on source code
    id 'com.github.spotbugs' version '2.0.0' // code check, working on byte code
    id 'com.diffplug.gradle.spotless' version '3.23.0'// code format
    id 'com.simonharrer.modernizer' version '1.6.0-1' // detect deprecated APIs
    id 'com.github.onslip.gradle-one-jar' version '1.0.5' // pack a self contained jar
    id "de.undercouch.download" version "3.4.3" // downloads plugin
    id "kr.motd.sphinx" version "2.5.0" // documentation generation
    id "com.github.johnrengelman.shadow" version "5.1.0" // fat jar
    id 'jacoco' // java code coverage plugin
    id "org.scoverage" version "3.1.5"
}

repositories in build.gradle:

repositories {
    mavenLocal() //searches in local maven repository, typically ~/.m2/repository
    jcenter() //searches in bintray's repository 'jCenter', which contains Maven Central
    maven { url '<internal repo url>' }
    maven { url 'https://jade.tilab.com/maven/' } // Maven repository for jade
    maven { url 'https://jitpack.io' } // allows github repos as dependencies
}

If you need a full config or more information, please let me know.

Thanks,

Johannes

@eyalroth
Copy link
Contributor

eyalroth commented Aug 29, 2019

It looks like the scalac plugin version 1.3.1 is not available for Scala 2.13: https://mvnrepository.com/artifact/org.scoverage/scalac-scoverage-plugin

Try using the 1.4.0 version instead (instructions in the readme), though I'm not sure this (gradle) plugin is compatible with that version of the scalac plugin.

Also, how is the scala-library dependency configured in your project?

@johanneshiry
Copy link
Author

johanneshiry commented Aug 29, 2019

Thanks for the fast reply. I added the scoverage block as follows:

scoverage {
	scoverageVersion = "1.4.0"
        scoverageScalaVersion = "2.13"
}

Now I get an alike error but with the changed version:

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.scoverage:scalac-scoverage-plugin_2:1.4.0.

scala-library is configured in the dependencies-block as follows:
compile "org.scala-lang:scala-library:${scalaVersion}"

where ${scalaVersion} is derived from ext

ext {
	hibernateVersion = '5.3.3.Final'
	unitsOfMeasurementVersion = '1.0.8'
	javaVersion = JavaVersion.VERSION_1_8

	scalaVersion = '2.13'
	akkaVersion = '2.5.23'
	tscfgVersion = '0.9.9'
	slf4jVersion = '1.7.26'
}

@eyalroth
Copy link
Contributor

The scala-library dependency should be defined with its full version; i.e 2.13.0 instead of 2.13.

When the dependency is defined the plugin ignores the scoverageScalaVersion option and interprets Scala's version according to the dependency version, and it expects a full version definition.

@johanneshiry
Copy link
Author

johanneshiry commented Aug 29, 2019

Changing 2.13to 2.13.0 did the trick and it seems working now with scoverageVersion = "1.4.0".

The change caused another error with a different gradle plugin but I was able to solve that. (scalac-scapegoat-plugin doesn't accept 2.13.0 -> com.sksamuel.scapegoat:scalac-scapegoat-plugin_2.13.0:1.3.10 has to be set manually to com.sksamuel.scapegoat:scalac-scapegoat-plugin_2.13:1.3.10)

Don't have time to try the full functionality right now, but I will check this in the next 24h and report back if it's fully working now and provide the final, working config.

Thank you very much for your help!

@maiflai
Copy link
Contributor

maiflai commented Aug 29, 2019

For what it's worth, 1.4.0 support is pending a couple of upstream changes - #107 will be updated when they are available.

@johanneshiry
Copy link
Author

Just wanted to let you know, that it doesn't fully work yet. :-(
I'm able to execute gradle reportTestScoverage but it fails.

Stacktrace (unrelevant stuff excluded):

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':reportTestScoverage'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)

Caused by: java.lang.NoClassDefFoundError: scala/collection/JavaConversions
        at org.scoverage.ScoverageReport$_report_closure1.doCall(ScoverageReport.groovy:51)
        at org.scoverage.ScoverageReport$_report_closure1.doCall(ScoverageReport.groovy)
        at org.scoverage.ScoverageRunner.run(ScoverageRunner.groovy:30)
        at org.scoverage.ScoverageRunner$run.call(Unknown Source)
        at org.scoverage.ScoverageReport.report(ScoverageReport.groovy:42)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)

scala.collection.JavaConversions is deprecated since scala 2.13.0 but still available. I'm wondering if there is anything inside gradle that holds back using pieces of code that are marked as deprecated?

Dunno if this is scoverage-plugin related or a missconfiguration on my side. If you have any thoughts on this I would be happy to read them.

@eyalroth
Copy link
Contributor

eyalroth commented Aug 31, 2019

I just tried adding a functional test for Scala 2.13 and I got this error:

Compat.scala:152: error: postfix operator headOption needs to be enabled

It might be that Scala 2.13 isn't working properly with Gradle at the moment. See gradle/gradle#9857.

Edit: I tried running the 2.13 functional test from WSL and this resolved the Compat error, and now I got the same error as you did. Resuming investigation 🎩

@eyalroth
Copy link
Contributor

eyalroth commented Aug 31, 2019

Yeah it seems that JavaConversions is no longer available in Scala 2.13 (and JavaConverters is deprecated): https://docs.scala-lang.org/overviews/core/collections-migration-213.html (Look for the "Deprecated things in 2.12 that have been removed in 2.13" section)

Actually, #106 addresses this problem (I didn't notice it before for some reason).

@maiflai I'm wondering why have we switched away from JavaConverters. It should be backward-compatible with Scala 2.11.8.

@eyalroth
Copy link
Contributor

eyalroth commented Aug 31, 2019

It looks like version 1.4.0 of the scalac plugin is definitely not compatible with the current version of the gradle plugin (not just for Scala 2.13).

I'm tracking at least one breaking change where the IOUtils.reportFileSearch -- used by the gradle plugin -- was removed and replaced by IOUtils.scoverageDataDirsSearch. See scoverage/scalac-scoverage-plugin#241.

We need to first make this plugin work with 1.4.0 and only then we can also fix the compatibility with 2.13, which seems to be rather simple.

@johanneshiry
Copy link
Author

Are there any updates on this issue or #106?

@maiflai
Copy link
Contributor

maiflai commented Oct 23, 2019

Sorry, we’re still waiting on a 1.4.1 release of the scalac plugin.

@johanneshiry
Copy link
Author

johanneshiry commented Nov 30, 2019

First of all: Thank you very much for your effort and the new release! :-) I can confirm that the plugin works now (at least the issue here is resolved).

Now I'm struggling with a different, already reported issue. I added specific information in the corresponding issue thread here #98

SamTheisens added a commit to Vandebron/mpyl that referenced this issue Mar 6, 2023
SamTheisens added a commit to SamTheisens/mpyl that referenced this issue Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants