Sbt plugin for jruby

Is there a plugin for sbt that automatically installs JRuby and adds some hooks to automatically run scripts at specific points (for example, before compilation).

Reference Information. For a project (elevator), I want to use sass or, more specifically, compass as a tool for creating css. Unfortunately, Java or Scala sass clone is not enough.

Of course, it would not be a problem at all to simply generate css manually and then place it both inside the repository, and no one should ever care about it.

On the other hand, to facilitate development on several systems, Id rather has an explicit dependency inside sbt that just does the job.

Is there any way to achieve this?
Or in general: is there a way to run JRuby scripts from inside Scala?

Edit Added maven-2 to tags. Maybe there is a maven repo for JRuby that allows me to somehow deliver and use it.

+5
source share
2 answers

Although this may not be the most elegant solution, you can always invoke external scripts using the process support in SBT.

import sbt._
import Process._

class Project(info: ProjectInfo) extends DefaultProject(info) {
  lazy val runSomething = task {
    "ruby somescript.rb" ! log
    None
  }
}

Here is a bit more information on external process support available here: http://code.google.com/p/simple-build-tool/wiki/Process

+4
source

sbt plugin github. , jruby jar .rb .

:

    import sbt._

    object SbtJRuby extends Plugin {
      object SbtJRubySettings {
        lazy val settings = Seq(Keys.commands += jirb, tx, jrubyFile := file("fnord.rb"))
      }

      def jirb = Command.args("jirb", "<launch jirb>") { (state, args) =>
        org.jruby.Main.main(List("-S", "jirb").toArray[String])
        state
      }

      val jruby = TaskKey[Unit]("jruby", "run a jruby file")
      val jrubyFile = SettingKey[File]("jruby-file", "path to file to run with JRuby")

      val tx = jruby <<= (jrubyFile, Keys.baseDirectory) map { (f: File, b: File) =>
        val rb = (b / f.toString).toString
        //    println("jruby with " + rb)
        org.jruby.Main.main(List(rb).toArray[String])
      }
    }

, , jruby jar rb, . , , jruby :

libraryDependencies ++= Seq(
  "org.jruby" % "jruby-complete" % "1.6.5"
)

"jirb" Scala, jirb.

+1

All Articles