override sbt internal dependency - scala

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

Related

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

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'
}

Compilation error in the Scala/Play example application for Heroku using Intellij

I am trying to compile the scala/Play framework example application on my local machine, but I am getting compilation errors when trying to compile using the SBT console in IntelliJ:
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
I also got this message in the event log related to different SBT versions:
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Any suggestions on how to fix this?
For the first error
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
You might want to try and ensure that you are using a compatible java version. Like #cbley suggested, try making you are using version 8 of the JDK.
For the second error
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Its just suggesting you update the version of sbt (which is most likely declared in your build.properties file in a folder called project. You can just search for it by double tapping shift in IntelliJ. But you are safe to ignore it if you cloned some example repository as well.
check

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'
}

Understanding eclipse maven dependency hierarchy

I want to understand the dependencies for a multi-module maven project and for that referred to eclipse dependency hierarchy.
I did understand fairly, however some of the things I am not able to understand at all.
Below is the screen shot.
The things which I didn't understand are:
--> managed from 1.0.2 [Compile}
--> managed from 1.0.2 (omitted for conflict with 1.0.0) [Compile]
I did search online but I got information in traces. Can anyone help me understand what they mean in easy to understand?
Thanks.
Maven builds a flat classpath from the dependency tree each for compiling ([compile]), for testing, and for running.
In a flat classpath, unlike OSGi, a dependency can only exist in one version. In your cropped screenshot, there is on the second level among other things:
kafka-streams 1.0.2 and
kafka-clients 1.0.0.
kafka-streams 1.0.2 requires kafka-clients 1.0.2 which conflicts to kafka-clients 1.0.0. Therefore kafka-streams 1.0.2 is omitted for conflicts with 1.0.0 even if the version 1.0.2 is required here ("managed from 1.0.2").
More detailed:The classpath which is used to compile or run a plain Java application is flat: all required libraries are globally specified as an ordered list. It is not possible to use a library of a specific version for one package and for another package the same library in a different version.In Maven dependencies builds a tree: each dependency might have its own dependencies. Maven maps the tree of dependencies to the classpath, an ordered list of libraries. If in the Maven dependencies tree the same library exists in different versions, it is not possible to create a flat classpath. This is a conflict.This conflict is resolved by picking one version and omitting all other versions. At the place where the picked version is used instead of the required version, (managed from <required but not picked version>) and (omitted for conflict with <picked version to use instead>) is displayed.In addition, Maven can create different classpaths to compile, to test or to run a Java application via so-called scopes. The [compile] scope is the default scope for using a library in all tasks: compiling, testing and running.
Make sure that the versions specified in the pom.xml file are compatible with each other (which is not yet the case in your screenshot): you have to upgrade kafka-clients from 1.0.0 to 1.0.2 (or downgrade the other libraries).

Running scalatest and Maven with two scala libraries - one for Maven, the other for Scala Eclipse plugin

The scala Eclipse plugin requires scala 2.10.0 to run :
To run the 'test' goal on Maven I require the dependency :
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.0-1</artifactId>
<version>2.0.M5</version>
</dependency>
As part of this dependency 'scala-library-2.9.0-1.jar' is also added to build path :
This causes an error to be displayed on problems tab in Eclipse :
More than one scala library found in the build path. At least one has
an incompatible version. Please update the project build path so it
contains only compatible scala libraries.
How can I fix this error ? I need both scala libraries, one is for the scala eclipse plugin and the other for the scalatest maven plugin. I don't want to just delete the error from the problems tab.
The scala Eclipse plugin requires scala 2.10.0 to run :
It has versions for both 2.10 and 2.9, install the one for 2.9.2 (and use ScalaTest for version 2.9.2 as well). Or use a version of ScalaTest for 2.10, but it seems you'll need to build and install it locally, there isn't one for 2.10.0-RC2 listed at http://mvnrepository.com/artifact/org.scalatest.