These are chat archives for sbt/sbt

18th
Jul 2017
Matt Hicks
@darkfrog26
Jul 18 02:17
how about this question: is it possible to use a plugin in the same multi-project build?
Shanon Jackson
@ShanonJackson
Jul 18 04:42
Hey guys i'm a scala newbie here trying to get a Play Back-end up.
For some reason when i add "com.typesafe.slick" %% "slick-extensions" % "2.1.0" my IDE tells me its a unresolved artifact after its compiled
how can i find out the reason why?
eugene yokota
@eed3si9n
Jul 18 05:40
@ShanonJackson maybe 2.1.0 doesn't exist for the Scala version you're using?
Mario Pastorelli
@melrief
Jul 18 10:00
hi here
is there a way to make a certain build.sbt depends on a package so that I can use that package to generate source code with sourceGenerators in Test += Def.task { my.org.my.app.main(Array("arg1", ..., "argn")) }?
Dale Wijnand
@dwijnand
Jul 18 10:13
Kind of, but it has to compile with Scala 2.10.
(unless you want to go down the classloader hacks route..)
OlegYch
@OlegYch
Jul 18 10:24
or fork
Mario Pastorelli
@melrief
Jul 18 10:35
it's a java thing
Justin Kaeser
@jastice
Jul 18 10:36
IntelliJ Scala Plugin Nightly now supports sbt 1.0.0-RC2
Dale Wijnand
@dwijnand
Jul 18 10:40
Sweet, thanks.
@melrief is the "package" you want to depend on local code or a jar?
Mario Pastorelli
@melrief
Jul 18 10:45
it's a jar on artifactory
Dale Wijnand
@dwijnand
Jul 18 10:46
ok, so you just need to declare it as a build dependency (as opposed to a project dependency).
Add libraryDependencies += ... in project/plugins.sbt
Mario Pastorelli
@melrief
Jul 18 10:47
I see, thanks!
Dale Wijnand
@dwijnand
Jul 18 10:48
no worries
Mario Pastorelli
@melrief
Jul 18 11:27
I probably did something wrong but I can't see the package that I've added in build.sbt. Do I need to do anything else except adding the library dependency?
Dale Wijnand
@dwijnand
Jul 18 12:03
Nope
What do you get?
NouraMoubarak
@NouraMoubarak
Jul 18 12:48
Hi, please I need a help. In my project I don't have a file named build.sbt!! I have build.scala. please I need to know what is the difference between them? and should I create it manually ?
Dale Wijnand
@dwijnand
Jul 18 12:51
Hi @NouraMoubarak. build.scala in the project/ directory was how builds used to be configured. Now it's by-and-large no longer required, so you should consider migrating.
Mario Pastorelli
@melrief
Jul 18 12:53

@dwijnand maybe it's because I have a multiproject setup? I put the dependency in <root>/project/codegen.sbt:

libraryDependencies ++= Seq(
  "my.org" % "foobar" % "1.2.3"
)

and then in one of the projects I added

sourceGenerators in Test += Def.task {
  val dir = (sourceManaged in Compile).value
  my.org.foobar.Main.main(Array(dir.toString))
  getGeneratedFiles()
}.taskValue

but when I compile I get object foobar is not a member of package my.org

Dale Wijnand
@dwijnand
Jul 18 12:54
yeah, that's correct
hmm
NouraMoubarak
@NouraMoubarak
Jul 18 12:55
@dwijnand thanks for your answer, but I don't have build.sbt! should I create it? and where?
Dale Wijnand
@dwijnand
Jul 18 12:55
If you want to migrate, yes create it - at the root of the repo.
@melrief is this a closed source build?
NouraMoubarak
@NouraMoubarak
Jul 18 12:56
image.png
I have this error, build.sbt can help to resolve it?
Dale Wijnand
@dwijnand
Jul 18 12:57
No
NouraMoubarak
@NouraMoubarak
Jul 18 12:57
do you have any idea of how to solve it?
Dale Wijnand
@dwijnand
Jul 18 12:57
not without understand the project better
What is start?
Is it the old Play script?
NouraMoubarak
@NouraMoubarak
Jul 18 12:58
it is a command that we use after play
to start the project
but I have also this error when I compile
Alessandro Vermeulen
@spockz
Jul 18 14:34
Is there a way to denote that task X in project b depends on the publish task in project a?
*subproject?
Dale Wijnand
@dwijnand
Jul 18 14:35
X in b := (X in b).dependsOn(publish in a).value
Alessandro Vermeulen
@spockz
Jul 18 14:58
@dwijnand if I add that to the settings of b I get the error that I need to give a type for b. I know why, but is it what you meant to do?
I get a stackoverflow error now
Dale Wijnand
@dwijnand
Jul 18 15:00
drop the in b if you're adding it to the settings of b
Alessandro Vermeulen
@spockz
Jul 18 15:01
Both?
Dale Wijnand
@dwijnand
Jul 18 15:01
yeah
Olli Helenius
@liff
Jul 18 15:02
hmm, on 1.0.0-RC2 streams.value.log.ansiCodesSupported is false
also there's an extra newline between all SBT log lines
Alessandro Vermeulen
@spockz
Jul 18 15:04
@dwijnand that does the trick thanks! :)
Dale Wijnand
@dwijnand
Jul 18 15:04
no worries
Alessandro Vermeulen
@spockz
Jul 18 15:04
@dwijnand is there a way I can say that before anything in b is done, a.publish has to be dne?
Dale Wijnand
@dwijnand
Jul 18 15:05
@liff that second one is known
@liff could you open an issue with a reproduction of the impact, for the first one, please?
i'll do that
Dale Wijnand
@dwijnand
Jul 18 15:06
@spockz no, it's task by task
/cc @Duhemm Do you have cycles to look at the ansi colour regression?
Alessandro Vermeulen
@spockz
Jul 18 15:08
@dwijnand will it do publish-m2 only once if I say ;b/foo;b/bar and I put the dependency of publish on both?
Martin Duhem
@Duhemm
Jul 18 15:08
@dwijnand I'll look into it tomorrow.
Dale Wijnand
@dwijnand
Jul 18 15:08
thanks
@spockz no, those are distinct invocations so it'll publish on both
Alessandro Vermeulen
@spockz
Jul 18 15:24
@dwijnand what can I do to prevent that?
Dale Wijnand
@dwijnand
Jul 18 15:26
let's peel back some layers, what are you trying to achieve/solve?
Martin Duhem
@Duhemm
Jul 18 15:38
@liff if you're interested in fixing the bug you reported, I think that ManagedLogger should override def ansiCodesSupported (simply return ConsoleAppender.formatEnabledInEnv). You'll find these classes in the sbt/util repo.
Olli Helenius
@liff
Jul 18 15:42
i'll see what happens
Olli Helenius
@liff
Jul 18 15:52
yeah that certainly does the trick
Martin Duhem
@Duhemm
Jul 18 15:55
Good news! Would you mind opening a PR?
Alessandro Vermeulen
@spockz
Jul 18 16:18
@dwijnand we have a project with sub modules. This project is a library and also intended to be used by mvn project. We generate a parent Pom for this. In order to test our library we have a Pom project and we delegate the building of it to mvn. But I want to set the parent Pom version only once and I also only want to publish our parent Pom once
Olli Helenius
@liff
Jul 18 16:56
@Duhemm will do
Nicolas Rinaudo
@nrinaudo
Jul 18 20:20
is there an equivalent to ThisBuild, but to set something in all configurations rather than in all projects?
the use case is as follows: I'm trying to override the scalastyle task to run some code beforehand (copy the default style sheet if not found)
Dale Wijnand
@dwijnand
Jul 18 21:27
ThisBuild is a variant of Global, which also exists for the configuration scope.
ThisBuild doesn't mean "in all projects" it means "in no project in particular".
Justin Kaeser
@jastice
Jul 18 21:28
yay @dwijnand for fixing sbt-bintray
Dale Wijnand
@dwijnand
Jul 18 21:29
:tophat:
The problem is that for configurations that doesn't work out normally, and, no, there's no such thing as "in all configurations", but there is a feature request for it IIRC.
eugene yokota
@eed3si9n
Jul 18 21:29
:tophat: < SLASH
:smoking:
:guitar:
OlegYch
@OlegYch
Jul 18 21:32
:)
Shanon Jackson
@ShanonJackson
Jul 18 21:40
@eed3si9n sorry mised your response, what version would you recommend?
starting to get pretty desperate.
eugene yokota
@eed3si9n
Jul 18 21:41
the latest stable version of Scala is 2.12.2
and the latest stable version of Slick is 3.2.0
Mario Pastorelli
@melrief
Jul 18 21:42

hey people, is it possible to generate java files and include them in the compilation with sbt? I have a part of the build defined as

sourceGenerators in Test += Def.task {
  // generate java files in src_managed dir
  // java files generated
}

but the files are ignored

Shanon Jackson
@ShanonJackson
Jul 18 21:43
Oh it definitely wont be that sorry, i'll link the error i'm getting
eugene yokota
@eed3si9n
Jul 18 21:43
@ShanonJackson if for whatever reason you want to use older Slick, you'd need to use the Scala version that was used at the time
Shanon Jackson
@ShanonJackson
Jul 18 21:43
""Cannot load Driver[Driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] cannot be instantiated.]" Updated Code:"
updated code i'm trying now is...
slick.default="models.*"
slick.default.driver = "com.typesafe.slick.driver.ms.SQLServerDriver"
db.default {
  slickdriver = "com.typesafe.slick.driver.ms.SQLServerDriver"
  driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  url = "jdbc:sqlserver://SKYNET\\DEV:40000"
  username = "XX"
  password = "XXXXXXXX!"
}
in my application.conf
and build.sbt remains the same
slick-extensions 2.1.0
slick 2.1.0
literally been stuck on this problem for about 8 hours now
eugene yokota
@eed3si9n
Jul 18 21:45
@ShanonJackson again, what version of Scala are you using?
Mario Pastorelli
@melrief
Jul 18 21:45
never mind, found the issue
Nicolas Rinaudo
@nrinaudo
Jul 18 21:45
Wasn't there some mess about slick dropping support for some drivers? I remember reading something about that
@melrief was it to do with the java subdir or was I entirely off?
Shanon Jackson
@ShanonJackson
Jul 18 21:46
i'm using 2.11.7 but i just put it up to 2.11.11 to test it out
2.11.7, 2.11.11 both dont work same error.
Cannot load Driver[Driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] cannot be instantiated.]
i manually install the com.microsoft.sqlserver.jdbc.sqlserverdriver without SBT and my IDE does pick it up
Nicolas Rinaudo
@nrinaudo
Jul 18 21:47
That looks like a typical error where you forgot to depend on the sql server deiver
Shanon Jackson
@ShanonJackson
Jul 18 21:48
Scala/SBT/Java newbie. don't know how to fix
Nicolas Rinaudo
@nrinaudo
Jul 18 21:48
So it's not on your runtime classpath
Shanon Jackson
@ShanonJackson
Jul 18 21:48
?
i just put the .jar in intellij -> project structure -> libraries -> Add -> file path of jar
then went into one of the .scala files and typed import com.micro... and it picked up it was there
Nicolas Rinaudo
@nrinaudo
Jul 18 21:49
Right. So you fixed intellij. But you need to put the jar in sbt's unmanged dependencies
Shanon Jackson
@ShanonJackson
Jul 18 21:49
how do i do that
eugene yokota
@eed3si9n
Jul 18 21:50
make a directory named lib and put it in there
Shanon Jackson
@ShanonJackson
Jul 18 21:50
not in Exteneral libraries?
eugene yokota
@eed3si9n
Jul 18 21:50
or declare the driver as libraryDependencies
this is where IDEs and sbt kind of overlap in its roles
Nicolas Rinaudo
@nrinaudo
Jul 18 21:51
I'm not sure the ms driver is available on any public repo
Shanon Jackson
@ShanonJackson
Jul 18 21:51
image.png
Shanon Jackson
@ShanonJackson
Jul 18 21:51
its in external libraries atm
Nicolas Rinaudo
@nrinaudo
Jul 18 21:51
So I'm wrong :)
Shanon Jackson
@ShanonJackson
Jul 18 21:52
sorry that screenshot doesn't show it but it is in there
eugene yokota
@eed3si9n
Jul 18 21:52
sbt essentialy is a text-based IDE
so whatever you did for IntelliJ, you'd have to do it for sbt too
Shanon Jackson
@ShanonJackson
Jul 18 21:53
ok how do i add it to sbt
Nicolas Rinaudo
@nrinaudo
Jul 18 21:53
If you go on the link that eugene linked, you'll even find the actual line you need to add to build.sbt
eugene yokota
@eed3si9n
Jul 18 21:53
in this case, you have to make a directory named lib and put all your jars
Shanon Jackson
@ShanonJackson
Jul 18 21:53
whats the process i follow
eugene yokota
@eed3si9n
Jul 18 21:53
hopefully that'll get you to the state where you can run your code
Shanon Jackson
@ShanonJackson
Jul 18 21:54
information overload, so the link takes me to the download jars page
and it only has a maven download option
so iv'e downloaded the jar
eugene yokota
@eed3si9n
Jul 18 21:54
  1. try putting currently external JAR files into lib/
  2. next, libraryDependencies += "com.microsoft.sqlserver" % "mssql-jdbc" % "6.2.1.jre8"
if you're using sbt, you never have to download jars manually
Shanon Jackson
@ShanonJackson
Jul 18 21:55
trying 2 first sbt is loading
eugene yokota
@eed3si9n
Jul 18 21:56
gluck
Shanon Jackson
@ShanonJackson
Jul 18 21:57
worked.
literally love you fam thanks so much
eugene yokota
@eed3si9n
Jul 18 21:57
awesome