hce
hce

Reputation: 1167

intelliJ "unknown artifact. Not resolved or indexed" for scalatest with scala 2.13.1, sbt 1.3.3

The following combination in IntelliJ gives the "unknown artifact" error.

The following combination don't give an error.

The suggestions from an similiar question here didn't help:

What am I missing?

Minimal project on Github: https://github.com/hcetinkaya/sbt-scalatest-error-demo

My system:

Environment (updated):

OS: Windows 10.0 (Build 15063) VM on a VMWare 7.1
Scala Plugin: 2019.2.36
IntelliJ IDEA: 2019.2.3 (Ultimate Edition)
Build #IU-192.6817.14, built on September 23, 2019 
with 
    Runtime version: 11.0.4+10-b304.69 amd64
    VM: OpenJDK 64-Bit Server VM by Jetbrains

JAVA_HOME: E:\apps\java\jdk-13
SBT_HOME: E:\apps\sbt\sbt-1.3.3\sbt

build.sbt:

scalaVersion := "2.13.1" // "2.12.10" is OK. "2.13.1" gives an "unknown artifact" error
lazy val root = project.in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.8" % Test
    )
)

build.properties:

sbt.version = 1.3.3

IntelliJ project structure:

Project Structure 
    Project
        Project SDK: java 13 language level: 13
    Modules
        all sources ->  language level: 13 /project default
                        dependencies Module SDK: project sdk

IntelliJ settings:

Build, Execution, Deployment
    Build Tools
        sbt 
            jre: E:\apps\java\jdk-13
            Launcher: E:\apps\sbt\sbt-1.3.3\bin\sbt-launch.jar
    Compiler
        Scala Compiler Server
            Use compile Server for Scala: checked
            JDK: Project default
            JVM max heap, MB: 1024

UPDATE:

sbt yields following error log:

error: error while loading String, class file '/modules/java.base/java/lang/String.class' is broken
(class java.lang.NullPointerException/null)

Details (chopped):

[info] Loading global plugins from C:\Users\hce\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/hce/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading project definition from E:\learn\sbt\sbt-getting-started\project
[info] Updating ProjectRef(uri("file:/E:/learn/sbt/sbt-getting-started/project/"), "sbt-getting-started-build")...
[info] Done updating.
error: error while loading String, class file '/modules/java.base/java/lang/String.class' is broken
(class java.lang.NullPointerException/null)
[error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI
[error]         at java.base/jdk.internal.jrtfs.JrtPath.toUri(JrtPath.java:176)
[error]         at scala.tools.nsc.classpath.JrtClassPath.asURLs(DirectoryClassPath.scala:204)
[error]         at scala.tools.nsc.classpath.AggregateClassPath.$anonfun$asURLs$1(AggregateClassPath.scala:55)
[error]         at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:240)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:937)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:937)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:70)
...
[error] Caused by: java.lang.RuntimeException: /packages cannot be represented as URI
[error]         at java.base/jdk.internal.jrtfs.JrtPath.toUri(JrtPath.java:176)
[error]         at scala.tools.nsc.classpath.JrtClassPath.asURLs(DirectoryClassPath.scala:204)
[error]         at scala.tools.nsc.classpath.AggregateClassPath.$anonfun$asURLs$1(AggregateClassPath.scala:55)
[error]         at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:240)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:937)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:937)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:70)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error]         at scala.collection.TraversableLike.flatMap(TraversableLike.scala:240)
[error]         at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:237)
[error]         at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
[error]         at scala.tools.nsc.classpath.AggregateClassPath.asURLs(AggregateClassPath.scala:55)
...
[error]         at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
[error]         at xsbt.boot.Launch$.withContextLoader(Launch.scala:130)
[error]         at xsbt.boot.Launch$.run(Launch.scala:111)
[error]         at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
[error]         at xsbt.boot.Launch$.launch(Launch.scala:119)
[error]         at xsbt.boot.Launch$.apply(Launch.scala:20)
[error]         at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]         at xsbt.boot.Boot$.main(Boot.scala:18)
[error]         at xsbt.boot.Boot.main(Boot.scala)
[error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI

UPDATE 2:

The following combination and steps worked for me

steps:

IntelliJ still shows the "unknown artifact" message but sbt compile, test works.

I assume, that a newly installed IntelliJ had Problems to compile the scala2_12 bridge for Cousier.

The commandline recompiled, now I can see scalatest_2.13, which was missing before, in project directory

null\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scalatest\scalatest_2.13

enter image description here

Upvotes: 2

Views: 1908

Answers (1)

hce
hce

Reputation: 1167

The following combination and steps worked for me

scala 2.13.1
Java OpenJDK 13.0.1 (set IntelliJ sbt options to OpenJDK)
sbt 1.3.3 (set IntelliJ sbt-launch.jar option to sbt 1.3.3 directory)

steps:

create a new sample project in commandline (see https://www.scala-sbt.org/1.x/docs/sbt-by-example.html)
sbt compile, test should work
import this project in IntelliJ

IntelliJ still shows the "unknown artifact" message but sbt compile, test works.

Upvotes: 0

Related Questions