IntelliJ can't find Scala/SBT GetClassifiersModule - scala

Brand new to SBT here, which may very well be the culprit. I'm trying to get IntelliJ Community 2017.2 to import a simple Scala/SBT project of mine.
When you clone that repo you can (if you want) run sbt compile and/or sbt run to verify that the dinky little Driver.scala source compiles and runs as expected.
But when I try importing it into IntelliJ:
Oops! That is a huge stacktrace but ends with:
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: sbt/internal/librarymanagement/GetClassifiersModule
[error] Use 'last' for the full log.
Any idea what is going on here? Anything in my project (see the GH repo) that jumps out?

Looks like https://youtrack.jetbrains.com/issue/SCL-12336, this problem was fixed in 2017.3, please try 2017.3 EAP https://www.jetbrains.com/idea/nextversion/

Related

Maven dependency: import cannot be resolved but is present in local repository (Eclipse Oomph Unzip Setup Task)

I have problems using Maven.
A Maven mvn clean package of the submodule "task-unzip" from the Eclipse Oomph's Unzip Setup Task repository (https://github.com/maybeec/oomph-task-unzip) fails with the following error on several machines/setups:
[INFO] --- tycho-compiler-plugin:0.22.0:compile (default-compile) # com.github.maybeec.oomph.task.unzip ---
[INFO] Compiling 13 source files to C:\FOLDER\repositories\oomph-task-unzip\task-unzip\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.983 s
[INFO] Finished at: 2020-10-28T18:35:49+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.22.0:compile (default-compile) on project com.github.maybeec.oomph.task.unzip: Compilation failure: Compilation failure:
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[7]
[ERROR] import org.apache.commons.compress.archivers.ArchiveEntry;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[8]
[ERROR] import org.apache.commons.compress.archivers.ArchiveInputStream;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[9]
[ERROR] import org.apache.commons.compress.archivers.ArchiveStreamFactory;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[10]
[ERROR] import org.apache.commons.compress.compressors.CompressorInputStream;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[11]
[ERROR] import org.apache.commons.compress.compressors.CompressorStreamFactory;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[12]
[ERROR] import org.apache.commons.compress.utils.IOUtils;
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] The import org.apache.commons cannot be resolved
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[47]
[ERROR] CompressorInputStream cIS = new CompressorStreamFactory().createCompressorInputStream(in);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^
[ERROR] CompressorInputStream cannot be resolved to a type
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[47]
[ERROR] CompressorInputStream cIS = new CompressorStreamFactory().createCompressorInputStream(in);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] CompressorStreamFactory cannot be resolved to a type
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[64]
[ERROR] ArchiveInputStream archiveIS = new ArchiveStreamFactory().createArchiveInputStream(fileIS);
[ERROR] ^^^^^^^^^^^^^^^^^^
[ERROR] ArchiveInputStream cannot be resolved to a type
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[64]
[ERROR] ArchiveInputStream archiveIS = new ArchiveStreamFactory().createArchiveInputStream(fileIS);
[ERROR] ^^^^^^^^^^^^^^^^^^^^
[ERROR] ArchiveStreamFactory cannot be resolved to a type
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[65]
[ERROR] ArchiveEntry entry;
[ERROR] ^^^^^^^^^^^^
[ERROR] ArchiveEntry cannot be resolved to a type
[ERROR] C:\FOLDER\repositories\oomph-task-unzip\task-unzip\src\com\github\maybeec\oomph\task\unzip\core\impl\UnzipUtilImpl.java:[77]
[ERROR] IOUtils.copy(archiveIS, out);
[ERROR] ^^^^^^^
[ERROR] IOUtils cannot be resolved
[ERROR] 12 problems (12 errors)
[ERROR] -> [Help 1]
Maven is actually downloading the Apache commons-compress-1.19.jar to the local Maven repository and it is also being copied to the project's lib folder. So that is working and the dependency is actually present on the filesystem.
However, Maven can not find this dependency. Adding it manually to the project, the resolve failure can be solved, but that is not a solution to the problem it's not working with Maven.
Importing the submodule in Eclipse shows the same. Eclipse isn't able to auto-complete an "import" statement to "org.apache.commons.*":
The Properties > Build path of that submodule doesn't show any Maven dependencies (actually the "Maven Dependencies" list wasn't even there! I had to follow https://stackoverflow.com/a/27337064/5446400 and edit the .classpath file for that). However it's still empty:
Searching and working for hours on that problem I couldn't come up with an explanation why Maven behaves the way it does.
Thank you for any support!
Maven dependencies shouldn't need to be added to the build path of Eclipse plugins. The plugin dependencies are enough and in this case commons-compress-1.19.jar will be loaded as a library from within the plugin's lib directory (this is defined in the build.properties file), not directly as a Maven dependency.
I'm not sure if downloading a Maven dependency and using it in the same build will work this way. If it gets copied to the correct location, you might just need to refresh the workspace, otherwise the jar could get ignored in the Eclipse build.
For debugging the issue I would probably download the artifact and place the jar in the lib directory manually once and ditch the automated process. Then at least you see if this unusual handling of Maven dependencies is the issue or something else.

scala project does not work in intellij

I am getting the following error log when setting up a scala project in intellij:
Error:Error while importing SBT project:<br/>...<br/><pre>[error] at
sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:107)
[error] at sbt.io.Using.apply(Using.scala:22)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:101)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:57)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:42)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:34)
[error] at sbt.StandardMain$.runManaged(Main.scala:113)
[error] at sbt.xMain.run(Main.scala:76)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.ClassNotFoundException: org.jetbrains.sbt.CreateTasks$
[error] Use 'last' for the full log.
[info] shutting down server</pre><br/>See complete log in file:/home/xxxx/.IdeaIC2017.2/system/log/sbt.last.log
My build.sbt looks as follows:
name := "someProjectName"
version := "0.1"
scalaVersion := "2.12.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
Please also note that my "old" projects still work, i.e. this issue occurcs only when doing a new project. Further, I noticed that when I click on SBT projects on the very right, it opens an empty window "SBT projects", for my other projects that window is non-empty.
Any idea what I am doing wrong here?
Many thanks
c
In case you don't want the hassle of upgrading Intellij, you can downgrade the sbt version in sbt.properties file from 1.1.0 (the project default) to, for instance, 1.0.3.
I have been experiencing this problem myself, and solved it by upgrading to intellij version: 2017.3.2 build #IU-173.4127.27.
I think this may have to do with sbt 1.X series no longer being available on the typesafe bintray repository, as I was also having a problem performing some Docker builds.
I had the same problem, so I could not create any Scala class in my project. Found a workaround, by creating a scala module in my project:
Select your project folder, go to File menu, File->New->Module.
In module select Scala and setup your Scala SDK there.
Then you can create scala classes in this module.
downgrade the sbt version in sbt.properties and remove target folder from project and project/project

sbt new RuntimeException

I got lost trying to start with a scala toy example, when running sbt new scala/hello-world.g8 or even sbt new, the program crashes with the following error. Any ideas what might be wrong? Thanks in advance!
(In fact, I am running sbt -java-home /usr/lib/jvm/jdk-8-oracle-x64 new since my system uses older version of jdk by defualt)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.antlr#ST4;4.0.8: org.sonatype.oss#oss-parent;9!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
[warn] :: com.googlecode.javaewah#JavaEWAH;0.7.9: org.sonatype.oss#oss-parent;5!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/5/oss-parent-5.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] java.lang.RuntimeException: Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.TemplateCommandUtil$.classpathForInfo(TemplateCommand.scala:119)
[error] at sbt.TemplateCommandUtil$.infoLoader(TemplateCommand.scala:81)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1(TemplateCommand.scala:48)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1$adapted(TemplateCommand.scala:47)
[error] at sbt.TemplateCommandUtil$$$Lambda$1762/658781536.apply(Unknown Source)
...
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] Use 'last' for the full log.
I had this problem too. I fixed it by blowing away my ~/.ivy2 directory
I had this problem too, had an out-of-date ~/.sbt/repositories file.
Either:
remove or rename ~/.sbt/repositories
add missing repositories to ~/.sbt/repositories from the current repositories list, see https://github.com/sbt/sbt/blob/v1.0.2/launch/src/main/input_resources/sbt/sbt.boot.properties
Upgrade your SBT version
Create a new user, to have a clean configuration, make sure that it is available for this user JDK and SBT with a "-version". I executed it and everything worked perfectly. Sometimes you have both installed or configured for your user that the programs conflict with each other.
P.S. I do not recommend using openjdk in this case.

object scalatest is not a member of package org [error] Cygwin

I was wondering if I could get some help with this one. I know there are many different issues with the same title, however, after following all the instructions (I hope), I could not get it to compile still. I've been at this for over 7 hours.
This is my issue. I am using Cygwin64 terminal to do some scala programming with sbt. I run the test and make sure that the test file is in the test folder but nothing is working. I have tried to compile it without the test file and then bring it back in but it does not work either.
$ sbt test
[info] Loading project definition from C:\cygwin64\home\Sam\hof\project
[info] Set current project to hof (in build file:/C:/cygwin64/home/Sam/hof/)
[info] Compiling 1 Scala source to C:\cygwin64\home\Sam\hof\target\scala-2.10\test-classes...
[error] C:\cygwin64\home\Sam\hof\src\test\scala\TestSuite.scala:3: object scalatest is not a member of package org
[error] class TestSuite extends org.scalatest.FunSuite {
[error] ^
[error] C:\cygwin64\home\Sam\hof\src\test\scala\TestSuite.scala:5: not found: value test
[error] test("map2 with add"){
[error] ^
[error] two errors found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Sep 19, 2016 1:07:10 AM
Is there anything I can do?
I had the same problem. Running sbt test in the project root gave me the object scalatest is not a member of package org error. But when I changed to src/test directory, it completed successfully.

How to include a library on bintray in Scala Maven project

I'm making a project in Scala (2.11), using Maven as my build tool. I'd like to use this library, but I can't get it to work.
I have a minimal (2 files) example repository here: https://github.com/evertheylen/scala-maven-bintray-example
I added two dependencies, kafka and scala-kafka-client. Both times I followed the instructions on their respective websites, but the last one (from bintray) is giving me problems. I would like the repository to be defined in the project, and not in my personal settings.xml (though I did try that and it didn't work).
The error given to me by mvn package exec:java -Dexec.mainClass=be.evertheylen.SampleApplication is:
[ERROR] .../src/main/scala/SampleApplication.scala:3: error: not found: object cakesolutions
[ERROR] import cakesolutions.kafka.KafkaProducer
[ERROR] ^
[ERROR] .../src/main/scala/SampleApplication.scala:4: error: not found: object cakesolutions
[ERROR] import cakesolutions.kafka.KafkaProducer.Conf
[ERROR] ^
[ERROR] two errors found
Although mvn dependency:list does in fact list the library:
[INFO] The following files have been resolved:
...
[INFO] net.cakesolutions:scala-kafka-client_2.11:pom:0.10.0.0-RC2:compile
...
Try removing <type>pom</type> from the dependency declaration in your pom.xml.