Digital Alpha
Digital Alpha

Reputation: 300

"/packages cannot be represented as URI"

I am working on a Scala project that use maven POM.xml file to build.

the build failed after adding test file that import "org.scalatest.FunSuite" or "...Matchers" with error message "/packages cannot be represented as URI"

plugin "scalatest-maven-plugin" is in used in the pom.xml but works file as long as there is no FunSuite or Matchers is imported

the test dependency in the pom looks like this

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
            <version>3.0.5</version>
            <scope>test</scope>
        </dependency>

scala version: 2.12.7

maven version: 3.8.6

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

Upvotes: 0

Views: 2579

Answers (4)

Jirayu S
Jirayu S

Reputation: 391

If you're using intelliJ

  • Go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> sbt
  • Make sure Use sbt shell for build is checked

Upvotes: 1

Matthias Berndt
Matthias Berndt

Reputation: 4587

This is a Scala compiler bug. Please upgrade to the latest Scala point release, 2.12.16.

Upvotes: 4

Digital Alpha
Digital Alpha

Reputation: 300

Found the solution:

The Project Build of IntelliJ doesn't really care about the path of JDK in env var JAVA_HOME, it takes the one from project settings, so to solve this I have to:

  • go to File -> Project Structure (Command + ;)
  • On the left select Project Settings, Modules
  • Select the module and from Module SDK drop list pick one of the compatible SDK like:
  • jdk1.8.0_202 or jdk1.8.0_251, correto1.8 or AdoptOpenJDK 1.8, ....
  • The ones that does NOT work with me are:
  • jbr17, correto16, temurin-17, ...

enter image description here

Upvotes: 2

Vashishth Patel
Vashishth Patel

Reputation: 105

In My Case I had resolved this issue by installing a java version of 1.8 and set JAVA_HOME to this version.

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home"

Upvotes: 0

Related Questions