Git Product home page Git Product logo

Comments (16)

retronym avatar retronym commented on June 20, 2024

It's just a warning, you should be able to use the console (although without tab completion).

I'll leave this open, as we can probably find a system property to set to avoid trying JLine in the first place.

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

Yes, it does seem to work following the warning. Thanks for replying so quickly.

Mike

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

I will demo SBT running from IDEA at Googleplex Wednesday April 18 in front of 300+ people. It would be great to not have to explain away this big bad stack dump. Is there a solution?

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024
> eval System.setProperty("jline.terminal" , "")
[info] ans: java.lang.String = jline.UnsupportedTerminal
> console
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 

You can run this in your build definition to hide it a better.

import sbt._
import Keys._

object build extends Build {
  // for the scala REPL
  System.setProperty("jline.terminal" , "")

  ...
}

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

My project has a build.sbt file. I created a project/build.scala file and put the code you suggested in it.

$ sbt update gen-idea
[info] Loading global plugins from C:\Users\Mike Slinn\.sbt\plugins
[info] Loading project definition from E:\work\books\akkafutures\akkaFutures\project
[error] No projects defined in build unit E:\work\books\akkafutures\akkaFutures
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

In that case, add this to build.sbt instead:

{System.setProperty("foo", "bar"); seq()} // for the Scala REPL JLine, runs just after SBT JLine initialization.

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

No better. Perhaps I did it wrong? Here is the complete build.sbt

// see https://github.com/sbt/sbt-assembly
import AssemblyKeys._ // put this at the top of the file

organization := "Micronautics Research"

name := "AkkaFutures"

version := "0.1"

scalaVersion := "2.9.1-1"

scalaVersion in update := "2.9.1"

autoCompilerPlugins := true

addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.1")

scalacOptions ++= Seq("-deprecation") //, "-P:continuations:enable")

scalacOptions in (Compile, console) += "-Yrepl-sync"

scalacOptions in (Compile, doc) <++= baseDirectory.map {
  (bd: File) => Seq[String](
     "-sourcepath", bd.getAbsolutePath,
     "-doc-source-url", "https://bitbucket.org/mslinn/akkafutures/src/9fa9548ce587/akkaFutures€{FILE_PATH}.scala"
  )
}

fork in run := true

// Use -Xbatch for benchmarks

javaOptions in run += "-server -Xmx1G -Xms1G" 

resolvers ++= Seq(
  "Akka Snapshots"        at "http://akka.io/snapshots",
  "Typesafe Snapshots"    at "http://repo.typesafe.com/typesafe/snapshots",
  "Typesafe Releases"     at "http://repo.typesafe.com/typesafe/releases",
  "Scala-Tools Snapshots" at "http://scala-tools.org/repo-snapshots",
  "Scala Tools Releases"  at "http://scala-tools.org/repo-releases"
)

libraryDependencies <+= scalaVersion { v => compilerPlugin("org.scala-lang.plugins" % "continuations" % v) }

libraryDependencies ++= Seq(
  "org.scalatest"                 % "scalatest_2.9.1"     % "1.7.1"   % "test" withSources(),
  "com.typesafe.akka"             % "akka-actor"          % "2.0"     withSources(),
  "com.github.scala-incubator.io" % "scala-io-core_2.9.1" % "0.3.0"   withSources(),
  "com.github.scala-incubator.io" % "scala-io-file_2.9.1" % "0.3.0"   withSources(),
  "org.apache.httpcomponents"     % "httpclient"          % "4.1.2"   withSources(),
  "org.scala-tools"               % "scala-stm_2.9.1"     % "0.5"     withSources()
)

seq(assemblySettings: _*)


logLevel := Level.Error

// Optional settings from https://github.com/harrah/xsbt/wiki/Quick-Configuration-Examples follow

{System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); seq()} // for the Scala REPL JLine, runs just after SBT JLine initialization.

// define the statements initially evaluated when entering 'console', 'console-quick', or 'console-project'
initialCommands := """
  import akka.dispatch._
  import akka.util.Duration
  import akka.util.duration._
  import com.micronautics.akka.dispatch.futureScala._
  import com.micronautics.concurrent._
  import com.micronautics.util._
  import java.net.URL
  import java.util.concurrent.Executors
  import scala.MatchError
  import scala.util.Random
  import scalax.io.JavaConverters.asInputConverter
  import scalax.io.Codec
  //
  val random = new Random()
  //
  val executorService = Executors.newCachedThreadPool()
  implicit val context = ExecutionContext.fromExecutor(executorService)
  //
  val daemonExecutorService = DaemonExecutors.newFixedThreadPool(10)
  //implicit val daemonContext = ExecutionContext.fromExecutor(daemonExecutorService)
  //
  def expensiveCalc(x:Int) = { x * x }
  //
  def expCalc(a:Int, b:Int) = {
    Thread.sleep(random.nextInt(200))
    a + b
  }
  //
  def httpGet(urlStr:String):String =
    new URL(urlStr).asInput.slurpString(Codec.UTF8)
  //
  //val f = Future { httpGet("http://akka.io") }
  //
  val urlStrs = List (
    "http://akka.io",
    "http://www.playframework.org",
    "http://nbronson.github.com/scala-stm"
  )
"""

// Only show warnings and errors on the screen for compilations.
// This applies to both test:compile and compile and is Info by default
logLevel in compile := Level.Warn

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

Sorry, it should be:

{System.setProperty("jline.terminal", ""); seq()} // for the Scala REPL JLine, runs just after SBT JLine initialization.

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

Hot diggety-dawg! It works!

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

Not so fast. After the initialCommands run, and I type in an expression, no further output is generated from the sbt console

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

post a transcript please...

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024
[info] Loading global plugins from C:\Users\Mike Slinn\.sbt\plugins
[info] Loading project definition from E:\work\books\akkafutures\akkaFutures\project
[info] Set current project to AkkaFutures (in build file:/E:/work/books/akkafutures/akkaFutures/)
> console
import akka.dispatch._
import akka.util.Duration
import akka.util.duration._
import com.micronautics.akka.dispatch.futureScala._
import com.micronautics.concurrent._
import com.micronautics.util._
import java.net.URL
import java.util.concurrent.Executors
import scala.MatchError
import scala.util.Random
import scalax.io.JavaConverters.asInputConverter
import scalax.io.Codec
random: scala.util.Random = scala.util.Random@10cb191
executorService: java.util.concurrent.ExecutorService = java.util.concurrent.ThreadPoolExecutor@5dae4f
context: akka.dispatch.ExecutionContext with java.util.concurrent.Executor = akka.dispatch.ExecutionContext$WrappedExecutor@5ec9da
daemonExecutorService: java.util.concurrent.ExecutorService = com.micronautics.concurrent.DaemonExecutors$DaemonThreadPoolExecutor@11...Welcome to Scala version 2.9.1-1 (Java HotSpot(TM) Client VM, Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 1+2

Nothing further prints

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

I'm guessing this workaround doesn't work on Windows. Setting that property to "" triggers automatic detection of the terminal. [1]

Instead, you can explicitly set it to use "no terminal":

{System.setProperty("jline.terminal" , "none"); seq()} // for the Scala REPL.

[1] https://github.com/scala/scala/blob/master/src/jline/src/main/java/scala/tools/jline/TerminalFactory.java#L69

from idea-sbt-plugin.

mslinn avatar mslinn commented on June 20, 2024

OK, that did the job. Many thanks!

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

Sorry about the hassle, SBT and scalac have a pretty intimate relationship, but they don't always agree on such matters...

from idea-sbt-plugin.

retronym avatar retronym commented on June 20, 2024

Closing this issue; the workaround above is available for now; when SBT and the REPL move to a common JLine we can avoid this altogether.

from idea-sbt-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.