Skip to content

scala-major version detection fails when 'scala-library' actual version customized via resolutionStrategy #97

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

Closed
maslovalex opened this issue May 10, 2019 · 5 comments · Fixed by #115

Comments

@maslovalex
Copy link

For example using gradle-scoverage with gradle-scala-multiversion-plugin impossible

build.gradle

plugins {
    id 'com.adtran.scala-multiversion-plugin' version '1.0.35'
    id 'org.scoverage' version '3.0.0'
}

repositories {
    jcenter()
}
dependencies {
    compile "org.scala-lang:scala-library:%scala-version%"
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.scalatest:scalatest_%%:3.0.5'

    testRuntimeOnly 'org.scala-lang.modules:scala-xml_%%:1.1.1'
}

gradle.properties

scalaVersions = 2.12.8, 2.11.12

./gradlew --stacktrace

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java_lang_String$substring$4.call(Unknown Source)
        at org.scoverage.ScoveragePlugin$_applyProject_closure4.doCall(ScoveragePlugin.groovy:79)
        at org.gradle.configuration.internal.DefaultListenerBuildOperationDecorator
        $BuildOperationEmittingClosure$1$1.run(DefaultListenerBuildOperationDecorator.java:181)
@maiflai
Copy link
Contributor

maiflai commented May 22, 2019

Sorry about this - please could you try:

scoverage.scoverageScalaVersion = project.scalaVersion

as a workaround?

Thanks,
Stu

@maslovalex
Copy link
Author

changing build.gradle to

plugins {
    id "com.adtran.scala-multiversion-plugin" version "1.0.35"
    id "org.scoverage" version "3.0.0"
}

repositories {
    jcenter()
}

scoverage.scoverageScalaVersion = project.scalaVersion

dependencies {
    // compile -> implementation
    implementation "org.scala-lang:scala-library:%scala-version%"
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.scalatest:scalatest_%%:3.0.5'

    testRuntimeOnly 'org.scala-lang.modules:scala-xml_%%:1.1.1'
}

renders following error

* What went wrong:
A problem occurred configuring root project 'multiscala-scoverage'.
> Could not resolve all files for configuration ':scoverage'.
   > Could not find org.scoverage:scalac-scoverage-plugin_2.12.8:1.3.1.
     Searched in the following locations:
       - https://jcenter.bintray.com/org/scoverage/scalac-scoverage-plugin_2.12.8/1.3.1/scalac-scoverage-plugin_2.12.8-1.3.1.pom
       - https://jcenter.bintray.com/org/scoverage/scalac-scoverage-plugin_2.12.8/1.3.1/scalac-scoverage-plugin_2.12.8-1.3.1.jar
     Required by:
         project :
   > Could not find org.scoverage:scalac-scoverage-runtime_2.12.8:1.3.1.
     Searched in the following locations:
       - https://jcenter.bintray.com/org/scoverage/scalac-scoverage-runtime_2.12.8/1.3.1/scalac-scoverage-runtime_2.12.8-1.3.1.pom
       - https://jcenter.bintray.com/org/scoverage/scalac-scoverage-runtime_2.12.8/1.3.1/scalac-scoverage-runtime_2.12.8-1.3.1.jar
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

@maiflai
Copy link
Contributor

maiflai commented May 23, 2019

Ah.

Can you try project.scalaSuffix? I expect you will need to strip the underscore first.

@maslovalex
Copy link
Author

putting scoverage.scoverageScalaVersion = project.scalaSuffix.substring(1) in build.gradle fixes the build.

@eyalroth
Copy link
Contributor

I created a PR to support any resolution strategy. Spring's dependency management was supported earlier by manually checking if it's configured; with this PR, the plugin is not aware of Spring's plugin directly, but indirectly via the resolution strategy.

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