Problem building scala 2.13.1 with Gradle 6.2 (worked with 5.6.2) - scala

I want to use Gradle 6.2 because of the recently fixed scaladoc issue.
Here is a build scan of my Gradle build using version 5.6.2 and Scala 2.13.1 - which works fine.
Without changing the Gradle build file at all, other than changing the version to 6.2, I now get this error:
> Could not resolve all dependencies for configuration ':zinc'.
> Conflict(s) found for the following module(s):
- org.scala-lang:scala-library between versions 2.12.8, 2.12.2, 2.12.1 and 2.12.0
- com.google.protobuf:protobuf-java between versions 3.7.0 and 3.3.1
- org.scala-lang.modules:scala-xml_2.12 between versions 1.0.6 and 1.0.5
I studied the suggested dependency graph but don't know how I am supposed to resolve the conflicts. I don't know why it is trying to use scala 2.12 at all.
Here is the corresponding build scan for this failing build.
I see that dependency configurations like "compile" are now deprecated. I tried changing to the newer preferred configurations, but I'm not certain that I mapped them all correctly.
I tried this:
dependencies {
implementation "java3d:vecmath:$vecmathVersion"
testImplementation 'junit:junit:4.12'
compileOnly("org.scala-lang:scala-library") {
version {
require "2.13.1"
}
}
testImplementation 'org.scalatest:scalatest_2.13:3.1.1'
testRuntimeOnly 'org.pegdown:pegdown:1.6.0'
}
but get the same error as above.

Please see this post for a bit more detail about how gradle works with Scala dependencies.
I suggest simplifying your dependencies section first, and using a specific version of scala, to get it working. I don't see why you you only want the scala-library at compile time and not runtime? The Gradle Scala plugin requires it to be a generally compile-time dependency: https://docs.gradle.org/current/userguide/scala_plugin.html.
The same documentation says that Gradle uses 2.12 to compile 2.13 sources... so I suspect that the 2.12 dependency is creeping in because you did not explicitly declare your scala-library version.
Without knowing the value of $vecmathVersion, I suggest the following:
dependencies {
implementation group: 'java3d', name: 'vecmath', version: '1.3.1'
implementation group: 'org.scala-lang', name: 'scala-library', version: '2.13.1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.scalatest', name: 'scalatest_2.13', version: '3.1.1'
testImplementation 'org.pegdown:pegdown:1.6.0'
}

Related

override sbt internal dependency

sbt contains internal dependency - util logging:
https://mvnrepository.com/artifact/org.scala-sbt/util-logging_2.10/1.2.0
and util logging dependency contain org.apache.logging.log4j ยป log4j-api:
https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api/2.8.1
the problem is that project download dependencies behind the proxy, and proxy does not contain 2.8.1 version of log4j-api(because of vulnerabilities), but proxy contains 2.17.1 version of log4j-api. So I want to use 2.17.1 version instead of 2.8.1. Is there an opportunity to do it. I mean I've got and error during dowloading dependencies:
module not found: org.apache.logging.log4j#log4j-core;2.8.1
Even I don't want to download org.apache.logging.log4j#log4j-core;2.8.1 because it leads to error during build
scala 2.10.4
sbt 1.2.0

Illegal entry in Gradle Dependencies for org.apache.commons commons-imaging 1.0-alpha2-SNAPSHOT

I just add compile 'org.apache.commons:commons-imaging:1.0-alpha2-SNAPSHOT' to file build.gradle, when I run Gradle Refresh Dependencies, I got an error as below, what can I do?
Illegal entry in Gradle Dependencies: C:/eclipse/unresolved dependency - org.apache.commons commons-imaging 1.0-alpha2-SNAPSHOT
Not sure why you want to use version 1.0-alpha2-SNAPSHOT of this lib which does not seem to be available on public maven repos (even not in apache snapshots repo.)
Try to use a released version instead (1.0-alpha1)
dependencies{
compile group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-alpha1'
}

IntelliJ "Cannot infer Scala class path..." but Gradle testCompile is correct?

I've got a Spring Boot project building through Gradle that recently saw the addition of some Gatling tests. The Gatlings stuff, which needs Scala support, is all down in src/test/scala. The build.gradle file got a new testCompile dependency to support it and, from a gradle perspective, all is well...
build.gradle
apply plugin: 'scala'
...
dependencies {
...
testCompile "org.scala-lang:scala-library:2.11.1"
testCompile "io.gatling.highcharts:gatling-charts-highcharts:2.2.5"
...
}
The gradle docs suggest that testCompile is all we need here: https://docs.gradle.org/current/userguide/scala_plugin.html
IntelliJ is unhappy with this configuration insisting
Warning:<i><b>root project 'tenderfoot': Unable to build Scala project configuration</b>
Details: org.gradle.api.GradleException: Cannot infer Scala class path because no Scala library Jar was found. Does root project 'tenderfoot' declare dependency to scala-library? Searched classpath: configuration ':compileClasspath'.</i>
If I lift the dependency up from testCompile to compile, the intellij warning goes away, but now my spring boot uber jar thing is unnecessarily bloated.
What's the way out? How do I get IntelliJ to stop Warning on this?
Is this actually an IntelliJ bug?
I ran into this problem also (having to set the dependency manually from IntelliJ).
I "fixed" it by setting the dependency as compileOnly as opposed to compile, this scope does not include the JAR in the final distribution.
The code I use is (please note that my dependency includes Scala as a transitive dependency):
compileOnly("io.gatling.highcharts:gatling-charts-highcharts:$gatlingVersion")

Gradle Scala plugin - How to specify scala version

How can I specify the Scala version in a Gradle Scala project?
The official documentation states that the scala-library dependency is used to get hold of the compiler.
dependencies {
compile 'org.scala-lang:scala-library:2.11.1'
}
Does this mean that Scala 2.11.1 will be used?
Specify the Scala library in the dependencies like so:
dependencies {
compile 'org.scala-lang:scala-library:2.11.1'
}

Using Gradle for Scala and ScalaTest (IntelliJ 2016.3.6)

Here is a quick build.gradle file I put together:
apply plugin: 'scala'
apply plugin: 'idea'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile "org.scala-lang:scala-library:2.12.2"
compile "org.scala-lang:scala-compiler:2.12.2"
testCompile 'org.scalatest:scalatest_2.11:3.0.1'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
If understood correctly, when running gradle idea, the external dependencies defined above appear in the External Libraries folder.
While I do see the dependencies in the folder, the issue I am facing is that I am unable to import anything from my external libraries provided by Gradle. Anything I manually provide (i.e. a downloaded version of the Scala SDK) works perfectly fine.
I have src and test marked as my sources root and test sources root, respectively.
What could possibly be the issue? Detailed explanations are also appreciated; I'm coming from a Maven background and struggling with the Gradle documentation.