What is wrong with my project hierarchy? - scala

I have created a project by importing existing sources in Intellij IDEA.
When I run from my comand line,sbt and then console I got this
[info] Compiling 7 Scala sources to
/home/milenko/example/project/target/scala-2.10/classes...
[error] /home/milenko/example/project/CommonBuild.scala:20: not found: type ModuleID
[error] dependencies: Seq[ModuleID] = Seq(),
[error] ^
[error] /home/milenko/example/project/CommonBuild.scala:26: not found: type Build
[error] trait CommonBuild extends Build {
[error] ^
[error] /home/milenko/example/project/CommonBuild.scala:28: not found: value SettingKey
[error] val course = SettingKey[String]("course")
[error] ^
[error] /home/milenko/example/project/CommonBuild.scala:30: not found: value SettingKey
[error] val assignment = SettingKey[String]("assignment")
[error] ^
[error] /home/milenko/example/project/CommonBuild.scala:32: not found: value SettingKey
[error] val assignmentsMap = SettingKey[Map[String, Assignment]]("assignmentsMap")
My example folder
milenko#milenko-desktop:~/example$ ls
assignment.sbt build.sbt project src target
Then I have changed directory to project,and run sbt and console in project.
My IDEA import is here
It seems that CommonBuild.scala is not positioned at the wright place.How to change this?

You should run sbt command from the root of your build, not in the project directory. project directory is used to build the build definition of your project, because sbt is recursive.
In other words, in your case you need to run sbt in ~/example directory.

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.

IntelliJ can't import sbt project

Error while importing sbt project:
d; set _root_.org.jetbrains.sbt.StructureKeys.sbtStructureOptions in Global := "download resolveClassifiers" ;*/*:dumpStructureTo /private/var/folders/5v/g3zxt_7d64g3sd_56bzpqbvh0000gn/T/sbt-structure.xml; session clear-all
[error] Expected ID character
[error] Not a valid command: d
[error] Expected 'debug'
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: d
[error] d; set _root_.org.jetbrains.sbt.StructureKeys.sbtStructureOptions in Global := "download resolveClassifiers" ;*/*:dumpStructureTo /private/var/folders/5v/g3zxt_7d64g3sd_56bzpqbvh0000gn/T/sbt-structure.xml; session clear-all
[error] ^
The error appeared after I upgraded the sbt version to sbt.version=0.13.16 in ./project/build.properties. Using sbt from the terminal works just fine.
Update: A workaround I found is to disable importing the project via the sbt shell.
Try deleting the target folder and running the commands again

Iteratee is not a member of package play.api.libs

While upgrading from play 2.4 -> 2.5 I hit an issue where
Symbol 'type <none>.iteratee.Iteratee' is missing from the classpath
I checked the migration guide and included the dependency "com.typesafe.play" % "play-iteratees_2.11" % 2.5.18 into sbt. From the new play-iteratees repo, I was under the impression that package play.api.libs.iteratee is where I'd find what to import. But it doesnt seem to work?
Error log:
[error] /Users/arnogau/Documents/alice/common/src/main/scala/common/util/Autodesk.scala:23: object iteratee is not a member of package play.api.libs
[error] import play.api.libs.iteratee.Iteratee
[error] ^
[error] /Users/arnogau/Documents/alice/common/src/main/scala/common/util/Autodesk.scala:158: Symbol 'type <none>.iteratee.Iteratee' is missing from the classpath.
[error] This symbol is required by 'method play.api.libs.ws.WSRequest.get'.
[error] Make sure that type Iteratee is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'WSRequest.class' was compiled against an incompatible version of <none>.iteratee.
[error] val req = client.url(MANIFEST_URL(urn)).withToken(token).get()
[error] ^
[error] two errors found

How to install sbt-sh plugin

https://github.com/steppenwells/sbt-sh
I'm using sbt 0.13.9 and try to install sbt-sh with given instructions. However sbt does not recognize sh command:
> sh ls
[error] Expected ID character
[error] Not a valid command: sh
[error] Expected 'show'
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: sh
[error] sh ls
[error] ^
>
Instructions are for sbt 0.10, maybe things have changed since those days and this guide is out of date?
The instructions are a bit outdated. Instead of ~/.sbt/plugins/project, you should put the MyPlugins object in ~/.sbt/0.13/plugins/project/MyPlugins.scala.
However, sbt-sh doesn't seem to work, even with that correction:
[error] $HOME/.sbt/0.13/staging/1375c2d4ab8153e18523/sbt-sh/src/main/scala/org/sbtsh/SbtShPlugin.scala:4: object CommandSupport is not a member of package sbt
[error] import sbt.CommandSupport._
[error] ^
[error] one error found
[error] ({git://github.com/steppenwells/sbt-sh.git}sbt-sh/compile:compileIncremental) Compilation failed
Can you try xsbt-sh instead?
Create a file ~/.sbt/0.13/plugins/xsbt-sh.sbt with this content:
resolvers += "Element Releases" at "http://repo.element.hr/nexus/content/repositories/releases/"
addSbtPlugin("hr.element.xsbt" % "xsbt-sh" % "0.0.2")
The Github README refers to 0.1.0 but that doesn't seem to have been yet released to the repository.

scala breeze compilation error

I am trying to compile the scala breeze library (release 0.9) with sbt 2.13.
I am getting the following error:
[info] Loading project definition from C:\scala\breeze-releases-v0.9\project
[info] Set current project to breeze-parent (in build file:/C:/scala/breeze-releases-v0.9/)
[info] Compiling 280 Scala sources to C:\scala\breeze-releases-v0.9\math\target\scala-2.11\classes...
[error] C:\scala\breeze-releases-v0.9\math\src\main\scala\breeze\util\HeapDump.scala:5: object management is not a member of package com.sun
[error] import com.sun.management.HotSpotDiagnosticMXBean
[error] C:\scala\breeze-releases-v0.9\math\src\main\scala\breeze\util\HeapDump.scala:21: not found: type HotSpotDiagnosticMXBean
[error] private lazy val hotspotMBean: HotSpotDiagnosticMXBean = getHotspotMBean();
[error] C:\scala\breeze-releases-v0.9\math\src\main\scala\breeze\util\HeapDump.scala:38: not found: type HotSpotDiagnosticMXBean
[error] private def getHotspotMBean():HotSpotDiagnosticMXBean = {
[error] C:\scala\breeze-releases-v0.9\math\src\main\scala\breeze\util\HeapDump.scala:42: not found: type HotSpotDiagnosticMXBean
[error] HOTSPOT_BEAN_NAME, classOf[HotSpotDiagnosticMXBean]);
[error] four errors found
I am on java sdk 1.7.0_02
What should I do?
Thanks,
Mike
I answered this on Breeze's mailing list, but this is because you're using a non-HotSpot VM. I'll delete this class in the next release of Breeze.