i have problems top use sbteclipse
What I have done:
went to my global sbt folder.
created a plugins folder
created the file plugins.sbt with addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
went to my eclipse project and created a build.sbt file
it contains:
name := "foo"
version := "1.0"
scalaVersion := "2.9.2"
libraryDependencies += "net.java.dev.jna" % "jna" % "3.4.0"
I am selecting the project folder in my cmd. and type sbt eclipse
But I always get the following error
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':'
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
ps: I am using Windows. I am also using sbt 0.12
Your global sbt folder is at %USERPROFILE%\.sbt (C:\Users\<username>\.sbt most likely). So your plugins should be defined at %USERPROFILE%\.sbt\plugins\plugins.sbt
Failing this you can add it to your project directly. Add the file path is <project_root>\project\plugins.sbt. If the project directory doesn't exist you will need to create it.
I think that I might have found a solution. First, the default directory checked for plugins configuration is 'USER_HOME/.sbt/plugins' and NOT 'USER_HOME/.sbt/0.13/plugins'.
Secondly, the sbt version specified seems to matter. In 'PROJECT_HOME/project/build.properties', there's an 'sbt.version' property. If the version of sbt specified in this file is different from the actually installed version of sbt, there's likely to be an issue. I think I was affected more so by this because I'm using an Activator template and it already had 'sbt.version' specified in this 'build.properties' file.
While nosing around, I came across this
"Support for plugin configuration in project/plugins/ has been removed. It was deprecated since 0.11.2" from sbt website at http://www.scala-sbt.org/0.13.0/docs/Community/ChangeSummary_0.13.0.html. I still see a lot of guys pointing that it should be configured in 'PROJECT_HOME/projects/plugins.sbt'. I think this is very confusing.
I had similar a issue and answered to a similar question.
I tried "everything" and, eventually, I just had to update my sbt from 0.13.1 to 0.13.9.
Related
I just started a clean project in Scala using SBT and have run into some issues once attempting to add dependencies. Specifically I tried adding cats-core to my dependencies in my build.sbt file:
scalaVersion := "2.13.1"
name := "hello-world"
libraryDependencies += "org.typelevel" %% "cats-core" % "2.1.0"
My sbt version is set to 1.3.7 in build.properties. However once I run compile, it shoots a bunch of angry errors saying it can't resolve the dependency, and rightfully so since the paths it is using don't exist:
[error] sbt.librarymanagement.ResolveException: Error downloading org.typelevel:cats-core:2.1.0
[error] Not found
[error] Not found
[error] not found: /home/lambda/.ivy2/local/org.typelevel/cats-core/2.1.0/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/typelevel/cats-core/2.1.0/cats-core-2.1.0.pom
I'm a bit confused as I don't seem to be running into this issue on other machines on the same network, however this persists on my local machine despite deleting ~/.ivy2 and ~/.sbt. I've also tried completely reinstalling sbt, and even building it through a clean Docker image, but the same error persists. It looks to me to be an issue with ivy trying to look for an ivy.xml although I'm fairly certain cats uses a POM.xml, but I'm unsure how to resolve this. Looking for any help resolving this!
I am using scala version 2.11.4, I have tried various options like sbt-assembly, build artifact (Intellij Idea feature), sbt package. Unfortunately, none of them worked form me.
I attempted following things :
With sbt-assembly :
Created assembly.sbt file and added following line :
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
build.sbt :
scalaVersion in ThisBuild := "2.11.4"
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
I got the following error
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-assembly:0.12.0 (sbtVersion=0.13, scalaVersion=2.11)
With 'build artifact' feature using Intellij Idea 15
Able to create a jar. However, not able to execute it. Was getting following error:
Invalid or corrupt jarfile
For this I tried the command : java -jar JAR_FILE
With sbt package :
Able to create JAR. However, not able to execute it. Was getting following error :
java.lang.NoClassDefFoundError scala/Function0
I was trying with the command :
java -cp scala-library.jar -jar JAR_FILE
Resolved
I am able to create jar by switching to scala version 2.10.5 and then used sbt-assembly plugin. Slightly disappointed with the fact that there is no available solution to create executable jar with latest version of scala.
If you are using sbt-assembly plugin, the correct task to perform is called assembly. When using IntelliJ IDEA, sbt assembly needs to be performed from a command line, the IDE is still unable to perform such SBT tasks.
The resulting jar, which includes all dependencies, is usually called a fat jar - if you need some more searching, this is what to search for.
Since I can't comment yet, I'll use answer, but more of a question - I have been using sbt package extensively for exactly this. I cd into the directory that holds src/main/scala|java and running sbt package, and then pushing jar/war file to the desired destination, in my case jetty.
Can you explain exactly what you're doing, the output and details on the issue?
IntelliJ IDEA 15 is reporting an unresolved symbol for my project definition in my build.sbt file
lazy val root = (project in file(".")).enablePlugins(PlayScala)
It's reporting an error with project and in.
Cannot resolve symbol project.
Cannot resolve symbol in.
Everything else resolves perfectly and the project is otherwise all set up, sbt builds fine, activator runs fine.
In my case, after upgrading Intellij forgot that the project was a Scala project.
Delete .idea/ and import the project to fix this.
To fix this issue, I imported: import sbt.project on top of my build.sbt
I am working with IntelliJ IDEA 16 EAP
I looked on jetbrains' error tracker and found this is a known bug.
"Cannot resolve symbol project" in build.sbt
https://youtrack.jetbrains.com/issue/SCL-9512
This happened to me when when the "external library" referenced was a different version than the one stated in the build.sbt file. Specifically:
External Libraries -> SBT: org.scala-lang:scala-library:2.12.1
build.sbt -> scalaVersion := "2.12.2"
I had an issue with http references in my ~/sbt/repositories file. When I changed this to https all was well.
typesafe-releases: https://repo.typesafe.com/typesafe/releases
typesafe-ivy-releasez: https://repo.typesafe.com/typesafe/ivy-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
I just created a new project using activator new, and am now trying to eclipsify it using activator eclipse. But I am facing an issue:
D:\work\firebase>activator eclipse
[info] Loading project definition from D:\work\firebase\project
[info] Set current project to firebase (in build file:/D:/work/firebase/)
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
I am using Typesafe Activator 1.3.2
Append this piece to your plugins.sbt file:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
Play no longer includes the sbteclipse or sbt-idea plugins, which enables users to upgrade IDE support independently of Play.
Source
According to James Ward:
I think the shims only get installed by the UI. But jsuereth can confirm. If so we need to fix this. A workaround is to first run the UI (activator ui) on the project, then you can use activator eclipse
Source: https://github.com/typesafehub/activator/issues/212
I solved by this way:
1 add line addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
2 then run activator eclipse
I am having some serious difficulty installing sbteclipse as a global plugin. It seams like the global plugins are not being loaded. I created the .sbt directory and added a plugins directory. In the plugins directory I added the following build.sbt definition:
resolvers += Classpaths.typesafeSnapshots
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-SNAPSHOT")
the above definition is in the ~/.sbt/plugins directory. When I search online I see plenty of sbt startups that look like the following: (notice the global plugin load and the project definition path)
Now here is an example of my sbt startup and my attempt to run eclipse:
Any thoughts on what I am doing wrong. I have been working on this for hours.
EDIT:
The error I get for not running sbt as superuser:
> mkemnetz#ubuntu:~/git/GymWebApp$ sbt
bash: /bin/sbt: Permission denied
mkemnetz#ubuntu:~/git/GymWebApp$
EDIT2:
mkemnetz#ubuntu:~/git/GymWebApp$ sbt
[info] Loading global plugins from /home/mkemnetz/.sbt/plugins
[info] Set current project to default-18287a (in build file:/home/mkemnetz/git/GymWebApp/)
> eclipse
[info] About to create Eclipse project files for your project(s).
[error] java.io.FileNotFoundException: /home/mkemnetz/git/GymWebApp/target/streams/$global/project-descriptors/$global/out (Permission denied)
[error] Use 'last' for the full log.
This is the current error I am getting. Still not working but much improved thanks to darwin
Instead of build.sbt in my ~/.sbt/plugins dir I have plugins.sbt with the content like in your example. And everything works fine for me.
UPD:
The problem occurs because of you run sbt command under superuser's environment so sbt conf is not resolved properly.
Just run sbt under your user after removing project target dir.
This is my ~/.sbt/plugins/build.sbt:
resolvers += Classpaths.typesafeResolver
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")
Quoting sbteclipse github
For sbt 0.13 and up Add sbteclipse to your plugin definition file. You
can use either: the global file (for version 0.13 and up) at
~/.sbt/0.13/plugins/plugins.sbt the project-specific file at
PROJECT_DIR/project/plugins.sbt
AND I want to comment on this "backward compatibility is very important!"