Specify plugins in Build.scala

If I want to use a build.scala file in order to build my project (instead of build.sbt)

how do I specify the plugins?

I want to use the sbt-assmbly plugin. and I am aware that I can create a plugins.sb file and do a addSbtPlugin there.

But i want to put all my build logic in build.scala instead of the sbt files.

Best How To :

No, you can't. You can put it in project/project/Build.scala, which would let you avoid .sbt files, but probably isn't what you want.

The thing is, project directory is itself an SBT project, and SBT handles project/*.sbt files and project/project/*.scala files in it just the same as it does on the top level; but by the time it's working with project/Build.scala, it's too late to add plugins.

The equivalent non-infix version is: xs match { case List(x, _, _) => "yes" case _ => "no" } Scala specification says: An infix operation pattern p;op;q is a shorthand for the constructor or extractor pattern op(p,q). The precedence and associativity of operators in patterns is the same as in...

The slf4j library is really an interface to some underlying logging implementation. You would have log4j, logback or some other logging implementation do the heavy lifting, with an adapter jar, as explained in the slf4j documentation. You would then provide the details in the properties file for log4j for instance,...

to run as scala application, you need to create Scala App and not class In eclipse, package explorer select project/src/package right click new>scala app inform Name e.g. Test and click "finish" select Test.scala right click "run as Scala Application" see results in console window....

var balance = Some(0) is inferred to be of type Some[Int], when you need to tell this explicitly that it's of type Option[Int]: var balance: Option[Int] = Some(0) Then balance will be able to take in either Some(0) or None. By the way, it's sometimes a good practice to always...

You're very close. The problem is that Scala isn't going to propagate implicit requirements up the call chain automatically for you. If you need a Generic[A, T] instance to call convert, then you'll have to make sure that one's in scope every time you call convert convert. If A and...

I guess you are using the RegexParsers (just note that it skips white spaces by default). I'm assuming that it ends with "\n\n--open--" instead (if you can change that otherwise I'll show you how to modify the repsep parser). With this change we see that the text has the following...

The JavaTokenParsers does not implement the Scanners trait. So you would need to extends also from this trait (or a trait that extends it) in order to have access to this class. Unless your expr parser accepts the Reader as a parameter (not from its apply method), you'd need to...

There's no reason to flatMap in the yield. It should be another line in the for-comprehension. for { a <- fa b <- fb c <- fc d <- f(a, b, c) } yield d I don't think it can get more concise than that....

You don't want to block, by waiting on the response of the actor, so you are using Future correctly. The code in the onComplete function is executed, when your actor responds with the list. And since you don't want to block and handle it asynchronously, your last println statement is...

You can use a filter and then map to get the index : scala> val s = "10010010" s: String = 10010010 scala> s.zipWithIndex.withFilter(_._1 == '1').map(_._2) res0: scala.collection.immutable.IndexedSeq[Int] = Vector(0, 3, 6) Note: I'm using withFilter and not filter to avoid creating a temporary collection. Or you can use collect,...

In this case you can use mapPartitions with the preservesPartitioning attribute. x.map((it => it.map { case (k,rr) => (k, someFun(rr, k)) }), preservesPartitioning = true) You just have to make sure you are not changing the partitioning, i.e. don't change the key....

The first problem with your code is that you need to forward from the master actor to the child so that the sender is properly propagated and available for the child to respond to. So change this (in RedisActor): summaryActor ! msg To: summaryActor forward msg That's the primary issue....

So, lots of problems. All that stuff you are doing? It's getting done in the constructor of Book, and redone for every instance. Your main method? That's gets compiled to instance method of Book, not a static method, so it does not serve an an entry point for an executable...

The second call to go on line 4 is not in tail position, it is wrapped inside an anonymous function. (It is in tail position for that function, but not for go itself.) For continuation passing style you need Proper Tail Calls, which Scala unfortunately doesn't have. (In order to...

The %% in the dependency automatically appends a _2.XX scala version to your artifact id. It makes scala dependencies easier to manage, but you can't use it with java dependencies like apache httpcomponents. Instead just use %: "org.apache.httpcomponents" % "httpclient" % "4.5" ...

pure for zip lists repeats the value forever, so it's not possible to define a zippy applicative instance for Scala's List (or for anything like lists). Scalaz does provide a Zip tag for Stream and the appropriate zippy applicative instance, but as far as I know it's still pretty broken....

You can use the \bth\w* pattern to look for words that begin with th followed by other word characters, and then replace all matches with "123" scala> "this is the example, that we think of, anne hathaway".replaceAll("\\bth\\w*", "123") res0: String = 123 is 123 example, 123 we 123 of, anne...

yyy is not a function, it's a method. You have to either convert it to a function using η-expansion yyy _ or use a function in the first place val yyy = (c: Char) => c.toUpper // or val yyy: Char => Char = c => c.toUpper // or val...

In a double quoted string backslash is an escape character. If you mean to use the literal backslash in a double quotes string you must escape it, thus "\d" should be "\\d". Furthermore you do not need to escape the regex dot within a character class, since dot has no...

Try to write your last line as def map(tree:Tree[Int])(f:Int=>Int) : Tree[Int] = fold(tree , EmptyTree:Tree[Int])((l,x,r) => Node(f(x),l,r)) Scala's type inference is very limited compared to haskell, in this case it tries to infere type of fold from it's arguments left to right, and incorectly decides that result type of fold...

You can overcome this by passing a function that calls mergesort to generalizedMergeSort. This call will capture the implicit Ordering: def mergesort[A: Ordering](as: List[A]): List[A] = { generalizedMergeSort(as, mergesort(_: List[A])) } mergesort(_: List[A]) is a closure function of type List[A] => List[A], which calls mergesort with its argument, and the...

It should work out of box for dependencies, which are imported to the project as modules, no additional settings needed. At least for Java. Just do not run a Maven goal, that would use dependencies from the repository. ...

Can you post your Status class definitation .If code is type column[Int] your code should be giving error as like works on column[string]. The below snippet works for doing a like on integer field. class Coffees(tag: Tag) extends Table[(String, Int)](tag, "COFFEES") { def name = column[String]("NAME") def status = column[Int]("STATUS")...

The code that is there now needs two minor changes: The Message trait must be sealed, or otherwise, Shapeless will not provide a Generic.Aux[Message, SomeCoproduct] instance. The call to Codec.coproduct[Message] must be after all the subtypes are defined. Moving the companion to the end of the file is sufficient. With...

Have a look at play documentation: Writing your own field constructor. You can check on errors with @if(elements.hasErrors) within the template of your custom field constructor. <div class="input-with-label text-left @if(elements.hasErrors){field-error}"> ... Edit: You can pass the error state of your field via the args parameter to your input. From the...

I'm only going to comment on findStart for now. There are two things wrong with findStart: findStart is recursively called on every adjacent cell. Unfortunately, the neighbouring cell of any neighbour is the cell itself. The function never checks if you can actually walk on a given cell (I assume...

Your code should be okay provided you have the right implicits in scope. If you have an implicit FlowMaterializer in scope then things should work as expected as this code that compiles shows: import akka.http.scaladsl.server.Route import akka.actor.ActorSystem import akka.stream.ActorFlowMaterializer import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.server.Directives._ import akka.stream.FlowMaterializer implicit val system = ActorSystem("test")...

The conventional way to write a factory in Scala is to define an apply method on the companion object. Here's an example using Either (because null is never/rarely used in Scala, and exceptions are ugly): class A private (n: Int) { override def toString = s"A($n)" } object A {...

Algebraic data types break encapsulation by exposing the internal representation of the type publicly. When you take a functional programming point of view with regards to your design, then mutable state is not something that is a concern normally. Therefore, exposing the internal representation is not really a big deal...

The issue as it seems transitive dependency of the dependency is resulting with two different versions of metrics-core. The best thing to do would be to used the right library dependency so that you end up with a single version of this library. Please use https://github.com/jrudolph/sbt-dependency-graph , if it is...