Why SBT is publishing a JAR which is skipped? - scala

Need help to understand why SBT would try to publish a JAR which is already skipped? And how to fix this issue?
Like in the following build log, publishing of my-service_2.13-0.45.13-tests.jar was skipped but still the sbt publish shows [error] java.io.IOException in putting it on artifactory.
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-tests.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-sources.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13.pom
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13-it.jar
[warn] Skipping publication of already published artifact: my-service_2.13-0.45.13.jar
[error] java.io.IOException: PUT operation failed because the destination file exists and overwriting is disabled:
[error] source : /home/my-system/my-service/target/scala-2.13/my-service_2.13-0.45.13-tests.jar
[error] destination: https://my-artifactory.com/artifactory/com/my-org/my-service_2.13/0.45.13/my-service_2.13-0.45.13-tests.jar
[error] If you have a staging repository that has failed, drop it and start over.
[error] Otherwise fix the double publishing, or relax the setting as follows:
[error] publishConfiguration := publishConfiguration.value.withOverwrite(true)
[error] publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
I am using SBT 1.3.13 with Scala 2.13.3

Related

Scala SBT Plugin Version Error During Build

I keep getting the following error from my GitHub Actions workflow:
[info] welcome to sbt 1.7.1 (Eclipse Adoptium Java 11.0.16.1)
[info] loading settings for project plant-simulator-build from plugins.sbt ...
[info] loading project definition from /home/runner/work/plant-simulator/plant-simulator/project
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scoverage:sbt-scoverage;sbtVersion=1.0;scalaVersion=2.12:2.0.7
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scoverage/sbt-scoverage_2.12_1.0/2.0.7/sbt-scoverage-2.0.7.pom
[error] not found: /home/runner/.ivy2/localorg.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.typesafe.com/typesafe/ivy-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:345)
[error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$38(CoursierDependencyResolution.scala:314)
[error] at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:314)
I have the following defined in my project/plugins.sbt file:
// For code coverage test
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7? This is ruining my build. Any ideas on how to fix this?
My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7?
It's not. It is trying to find version 2.0.7 of the plugin. The 2.12 refer to the Scala version of plugins expected by SBT (different from the version of your project), and 1.0 refer to SBT major version.
The error message is relatively clear:
Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
This is ruining my build. Any ideas on how to fix this?
There's no version 2.0.7 as of today. Latest is 2.0.5. Check out the GitHub page of the plugin for reference: https://github.com/scoverage/sbt-scoverage.

How do I resolve a versioning error when compiling spark scala project with sbt?

I am working through the Apache Spark fundamentals course on pluralsight and trying to compile one of the example projects but am getting the following error. I have tried this now on two machines and am seeing the same thing. I can only assume this is some kind of versioning error for sbt and scala, and potentially spark?
I am using sbt 1.7.2, scala 2.12.15, spark 3.3.0
Any advice much appreciated!
[info] Updated file C:\Users\mg15\Documents\spark_stuff\LanguageEvaluator - PreTransform\project\build.properties: set sbt.version to 1.7.2
[info] welcome to sbt 1.7.2 (Oracle Corporation Java 16)
[info] loading settings for project languageevaluator-pretransform-build from assembly.sbt,plugins.sbt ...
[info] loading project definition from C:\Users\mg15\Documents\spark_stuff\LanguageEvaluator - PreTransform\project
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-assembly:1.7.2 (sbtVersion=1.0, scalaVersion=2.12)
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading com.eed3si9n:sbt-assembly;sbtVersion=1.0;scalaVersion=2.12:1.7.2```

How to correctly prepare and setting preloaded sbt lib

In my situation, I cannot access internet in my office linux server. Therefore, I installed sbt in my personal computer. I followed instructions on sbt official web-site and run/compile a "hello world" for getting all dependency data.
Then, I copied ~/.ivy2 and ~/.sbt and sbt bin folders to my offline office desktop. But when I run sbt, I got these errors:
[info] welcome to sbt 1.4.9 (Oracle Corporation Java 1.8.0_25)
[info] loading project definition from /proj/mtk07847/test/scala/project
[info] Updating
[info] Resolved dependencies
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-library:2.12.12
[error] Not found
[error] Not found
[error] download error: Caught java.net.SocketException: Connection reset (Connection reset) while downloading https://repo1.maven.org/maven2/org/s
cala-lang/scala-library/2.12.12/scala-library-2.12.12.pom
[error] not found: ~/.ivy2/localorg.scala-lang/scala-library/2.12.12/ivys/ivy.xml
...
It seems that sbt tried to download missing scala-library:2.12.12 which I already prepared.
In my ~/.ivy2 folder,the structure and path looks like the following:
~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.12.jar
~/.ivy2/cache/org.scala-lang/scala-library/ivy-2.12.12.xml
~/.ivy2/cache/org.scala-lang/scala-library/ivy-2.12.12.xml.original
~/.ivy2/cache/org.scala-lang/scala-library/ivydata-2.12.12.properties
which is different from above messages:
[error] not found: ~/.ivy2/localorg.scala-lang/scala-library/2.12.12/ivys/ivy.xml
should I modified any describing files to indicate searching path or rule for sbt? or this method
is totally wrong (if so, can anyone know the flow guide me the better way?)

How do I change the version of a dependency in a Scala application that I haven't set?

I am trying to build a Scala play application and a dependency is suddenly failing to download due to the repo no longer being up
Full stack trace below. I used to get the scalaz-stream v0.7a dependency just fine but it seems to no longer be up on the website. There is a snapshot-0.7a which I would to use.. however I just need to know how to switch the version over to this one?
I have no idea where the scalaz dependency is coming from or where it's defined.. I haven't set it myself and if I search all files within the directory there's no mention of scalaz
There must be somewhere I can just change it from 0.7a to snapshot-0.7a
[info] Resolving jline#jline;2.12.1 ...
[warn] [FAILED ] org.scalaz.stream#scalaz-stream_2.11;0.7a!scalaz-stream_2.11.jar(bundle): (0ms)
[warn] ==== local: tried
[warn] /home/vagrant/.ivy2/local/org.scalaz.stream/scalaz-stream_2.11/0.7a/bundles/scalaz-stream_2.11.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/scalaz/stream/scalaz-stream_2.11/0.7a/scalaz-stream_2.11-0.7a.jar
[warn] ==== maven-central: tried
[warn] https://repo1.maven.org/maven2/org/scalaz/stream/scalaz-stream_2.11/0.7a/scalaz-stream_2.11-0.7a.jar
[warn] ==== LocalIvy: tried
[warn] /home/vagrant/.ivy2/local/org.scalaz.stream/scalaz-stream_2.11/0.7a/bundles/scalaz-stream_2.11.jar
[warn] ==== scalaz-mulesoft: tried
[warn] https://repository.mulesoft.org/nexus/content/repositories/public/org/scalaz/stream/scalaz-stream_2.11/0.7a/scalaz-stream_2.11-0.7a.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalaz.stream#scalaz-stream_2.11;0.7a!scalaz-stream_2.11.jar(bundle)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Wrote /vagrant/dummy-services/target/scala-2.11/dummy-services_2.11-1.1.1.pom
sbt.ResolveException: download failed: org.scalaz.stream#scalaz-stream_2.11;0.7a!scalaz-stream_2.11.jar(bundle)
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
...
at java.lang.Thread.run(Thread.java:748)
[error] (akka-quartz/*:update) sbt.ResolveException: download failed: org.scalaz.stream#scalaz-stream_2.11;0.7a!scalaz-stream_2.11.jar(bundle)
[error] Total time: 7 s, completed Jun 3, 2021 1:38:01 PM
see #mpilquist tweet
https://twitter.com/mpilquist/status/1389586284243476484
The early versions of scalaz-stream were published on bintray, which is no longer in service as of May 1st. Try upgrading to 0.7.3a which is on Maven Central (published August 2015). Alternatively, upgrade to fs2 3.0.x :)
If you don't have any reference to scalaz-stream in your code, that means it comes from another dependency transitively.
You have several options here:
add a dependency to a different version of scalaz-stream in your dependencies, this should override the version brought transitively. (Not really a best practice)
find out which dependency needs scalaz-stream by using sbt dependencyBrowseTree for instance. Then check if this dependency canot be updated itself.
you could also define a dependencyOverrides instead of 1st option
Anyway don't use a version with snapshot, it's likely not a stable version, thus not to be used.

Origin location must be absolute error in building a SBT project, IntelliJ

I am trying to build simple hello world SBT-Scala project using IntelliJ.
When I tried to created the project for the first time, after installing the scala/ SBT plugins, I am getting the following error:
Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving org.scala-lang#scala-reflect;2.11.8 ...
[info] Resolving org.scala-lang#scala-reflect;2.11.8 ...
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[info] Resolving org.scala-lang.modules#scala-parser-combinators_2.11;1.0.4 ...
[info] Resolving jline#jline;2.12.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.scala-lang:scala-reflect:2.11.8
[warn] +- org.scala-lang:scala-compiler:2.11.8
[warn] +- default:supersimplerootscalasbt3_2.11:1.0
[trace] Stack trace suppressed: run 'last *:ssExtractProject' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractProject) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-reflect;2.11.8: org.scala-lang#scala-reflect;2.11.8!scala-reflect.pom(pom.original) origin location must be absolute: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom
[error] Total time: 3 s, completed 22 May, 2017 4:42:05 PM</pre><br/>See complete log in file:/root/.IdeaIC2017.1/system/log/sbt.last.log
Any idea how to solve the origin location must be absolute error in this?
[Kindly note that I am able to find the file scala-reflect-2.11.8.pom unlike the error specifies: file:/root/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.pom]
My build.sbt file:
name := "SuperSimpleRootScalaSBT4"
version := "1.0"
scalaVersion := "2.11.8"
My sbt version is 0.13.15.
For me deleting my ~/.ivy2 helped
Deleting ~/.ivy2 works, but not the best option, then you have to download all the cache again. Rather delete the particular directory from cache where you are facing issue.
In your case, it should be ~/.ivy2/cache/scala.lang and rebuild
i was facing the same issue:
instead of of deleting the .ivy folder, just back it up (rename the folder .ivy2 as .ivy2.backup in instance), then test again eg
$ sbt new scala/hello-world.g8
the project should be created and set up correctly now
For me helped when I granted permissions for full Maven repo:
chmod -R 755 /Users/<your_user>/.m2/
Deleting the specific dependency from ~/.ivy2/ worked for me. At times it is not a good idea to remove all dependencies as it takes long time to get them back onto the machine.