How can IntelliJ find remote dependencies? - plugins

I added the Mailer plugin to my Play Framework 2 project. It compiles and works fine, but IntelliJ can't resolve any of its classes. I would normally just add the jar as a module in my IntelliJ project settings, but I don't have a jar. As far as I understand, the plugin is automatically being pulled from some repository. So how do I make IntelliJ aware of it?
I added this to conf/play.plugins
1500:com.typesafe.plugin.CommonsMailerPlugin
And this as a dependency in project/build.scala
"com.typesafe" %% "play-plugins-mailer" % "2.0.4"

I resolve problems like this with the sbt-idea SBT plugin. Just add this to your project/plugins.sbt file:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")
Then, whenever you change your project dependencies, run sbt idea and your IntelliJ project will be updated.

I had to delete the reference to com.github.mpeltonen in my plugins.sbt file first. Then as Bill said, I needed to run play idea. If I tried to run play idea without deleting the reference I got this exception:
java.lang.NoSuchMethodError: org.sbtidea.SbtIdeaPlugin$.ideaSettings()Lscala/collection/Seq;

Related

Trouble adding Mapper as dependency in a Lift project

I am doing my first Lift project and want to add a database. Following a book, I added the following dependency to build.sbt:
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
And then, in Boot.scala, the import
import net.liftweb.mapper._
Now the project doesn't compile, with Boot.scala giving the error
object mapper is not a member of package net.liftweb
But other sources around the Internet seem to suggest that my imports are OK.
Where does the dependency problem come from?
It turned out that this is a problem of Eclipse, which cannot setup the dependencies correctly.
I had to close the project in Eclipse and delete the hidden files .classpath and .project. Then get into SBT and run
eclipse
(the project has to use the sbteclipse plugin as described in the Lift cookbook). This recreates the project files with the correct dependencies.
Afterwards, Eclipse compiled the code as expected. It seems this will be needed every time a change is made to build.sbt.

How to add a scala library to eclipse

I am trying to add this Scala Library into Eclipse so as to add available functions I can use on Actors.
I've downloaded the file and extracted it and tried adding it to my workspace in the project explorer, but when I try, Eclipse tells me it can't find any projects in the file. I'm sure that there is a tutorial or something online that explains exactly how to do this, but like I said, I'm not sure about all the terminology, so I don't know what to search for to get the result I want.
The easiest way is to create an sbt project and use the sbteclipse plugin.
Your project structure should look like this:
build.sbt
project/build.properties
project/eclipse.sbt
build.sbt
(note that lines of code should be separated by a white line)
name := "ProjectName"
libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.2"
build.properties
sbt.version=0.13.5
eclipse.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
Then from the root directory execute sbt and within the sbt command line execute eclipse or eclipse with-sources=true
You can use sbt-extras or activator to get a specialized version that will automatically download the correct sbt version based on the build.properties file.
You could add the sbteclipse plugin as a default plugin, making it available in all projects by creating eclipse.sbt in the ~/.sbt/0.13/plugins directory instead of the project directory
If you created your project via sbt, please follow the instruction on the github page of async. Namely, add this libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.2" to build.sbt, run sbt, regenerate eclipse files with "eclipse" command and finally re-import project into eclipse

IntelliJ 13 with SBT plugin does not recognize Scalding dependency

I am trying to add Scalding 2.10 as a managed dependency via build.sbt like so:
name := "ss"
version := "1.0"
libraryDependencies += "com.twitter" % "scalding_2.10" % "0.10.0"
IntelliJ downloads the jar and adds it as an external library (see screen below) but fails to resolve the com.twitter namespace.
I have tried both invalidating the IntelliJ cache and generating project files via sbt gen-idea but neither solutions have worked. Any ideas would be greatly appreciated.
The scalding jar file scalding_2.10 has no code in it to compile against. Its just 300 Bytes in size.
The correct dependency I feel should be
libraryDependencies += "com.twitter" % "scalding-core_2.10" % "0.11.1"
As the comment suggest try rm-ing your ivy2 cache, and try sbt gen-idea. If that doesn't work, other things to check:
makes sure you have indeed got the scala plugin installed.
Most likely you're java SDK is not set or pointing somewhere wrong; right click the project dir, click "Open Module Settings", go to SDK and make sure the path is correctly set to the jdk otherwise syntax highlighting will likely break.
To test your deps have been properly pulled in from tinternet, try sbt compile; if it compiles then you should indeed have downloaded the dependency properly.

Typesafe Activator compilation error

I'm using Typesafe Activator on Ubuntu 13.04. It was working, but when I create a new project sometimes it doesn't do anything and sometimes it reports that the template is cloned (without downloading anything). When the project is created I get the following compile error:
Refreshing list of source files to watch for changes...
Loading project definition from
/home/myusername/activator-play-autosource-reactivemongo/project
Set current project to activator-play-autosource-reactivemongo (in
build file:/home/myusername/activator-play-autosource-reactivemongo/)
Applying State transformations com.typesafe.sbtrc.SetupSbtChild from
"""/home/myusername/.sbt/boot/scala-2.9.2/com.typesafe.sbtrc/sbt-rc-probe-0-12/1.0-28edcfb4984c8be5e556bad192b62551504aa23d/sbt-rc-props-1.0-28edcfb4984c8be5e556bad192b62551504aa23d.jar:/home/myusername/.sbt/boot/scala-2.9.2/com.typesafe.sbtrc/sbt-rc-probe-0-12/1.0-28edcfb4984c8be5e556bad192b62551504aa23d/sbt-rc-probe-0-12-1.0-28edcfb4984c8be5e556bad192b62551504aa23d.jar"""
java.lang.ClassNotFoundException: com.typesafe.sbtrc.SetupSbtChild$
Use 'last' for the full log.
Failed to reload source file list: sbt process never got in touch, so
unable to handle request WatchTransitiveSourcesRequest(true)
In project/build.properties change the sbt.version from 0.12.3 to 0.13.0 (or 0.12.4 alternatively).
I just had the same issue, for me this fixed it.
I just deleted all the activator generated files and it worked fine for me with following
In build.sbt:
scalaVersion := "2.10.4"
In project/plugin.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
Activator version: 1.1.3

setting sbt scalafx project

javafx is now in oracle-jdk.
scalafx gives delicious examples in its repository
The main questions I'm not being able to answer is "How to get started with scalafx"?
How can I add scalafx libary dependencies on my sbt project?
ScalaFX is soon to reach a stable release state.
As I write this you can find the published artifacts for version 1.0.0-M2 on the maven central repo
Adding the dependency to your sbt build should suffice
libraryDependencies += "org.scalafx" %% "scalafx" % "1.0.0-M2"
I did it the following way: I cloned the scalafx repository, build the jar using sbt package, then just copied the resulting jar into lib/ directory of my project. Make sure to reference your ${JAVAFX_HOME}/lib/jfxrt.jar as well.
If you want to use local maven, just run sbt publish-local in your scalafx dir, then add the following dependency to your project:
"org.scalafx" % "scalafx" % "1.0-SNAPSHOT"
(Look up that version in scalafx build.sbt, I pasted what was in mine)
#ayvango i have created a giter8 scalafx project template.just use
g8 jugchennai/scalafx.g8
You just need a new version of JDK, Giter8 and SBT. Dependency settings for javafx, scala, scalafx are predefined! IDE support also available.
URL : https://github.com/jugchennai/scalafx.g8