Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type mismatch in Task Graph examples #501

Open
kelemensanyi opened this issue Sep 28, 2017 · 3 comments
Open

Type mismatch in Task Graph examples #501

kelemensanyi opened this issue Sep 28, 2017 · 3 comments

Comments

@kelemensanyi
Copy link

The Task Graph page http://www.scala-sbt.org/1.x/docs/Task-Graph.html contains three examples containing the expression ur.allConfigurations.take(3) which all seem broken:

$ cat build.sbt 
scalacOptions := {
  val ur = update.value  // update task happens-before scalacOptions
  val x = clean.value    // clean task happens-before scalacOptions
  // ---- scalacOptions begins here ----
  ur.allConfigurations.take(3)
}

$ sbt 
[info] Updated file /home/kelemen/temp/sbt-started/project/build.properties: set sbt.version to 1.0.2
[info] Loading project definition from /home/kelemen/temp/sbt-started/project
[info] Updating {file:/home/kelemen/temp/sbt-started/project/}sbt-started-build...
[info] Done updating.
/home/kelemen/temp/sbt-started/build.sbt:5: error: type mismatch;
 found   : scala.collection.immutable.Vector[sbt.librarymanagement.ConfigRef]
 required: Seq[String]
  ur.allConfigurations.take(3)
                           ^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 
@dwijnand
Copy link
Member

Thanks @kelemensanyi.

@julian-20
Copy link

julian-20 commented Dec 2, 2017

Hey there, I am new into sbt and I was also reading through the tutorial and hit the problem.
I managed to edit the line to make it work, and it seems like that its working how its intented to work.
I changed
ur.allConfigurations.take(3)
to
ur.allConfigurations.take(3).foldLeft[Seq[String]](Nil)((a, b)=>{(b.name::Nil)++:a})
and its running without errors.

When I type
show scalacOptions
I am getting this result, which seems legit

sbt:Hello> show scalacOptions
[info] 123
[info] 456
[info] * test
[info] * runtime
[info] * compile
[success] Total time: 0 s, completed 02.12.2017, 23:59:43

I would like to have confirmation uppon that, because I can't really myself, as I am new into sbt.

EDIT:
Ofcourse you would want to use foldRight not foldLeft like i did, to get the items in the correct order
ur.allConfigurations.take(3).foldRight[Seq[String]](Nil)((a, b)=>{(a.name::Nil)++:b})
like this

sbt:Hello> show scalacOptions
[info] 123
[info] 456
[info] * compile
[info] * runtime
[info] * test

@Irrizzit
Copy link

Irrizzit commented Feb 25, 2018

ur.allConfigurations.map(_.toString) should be good enough :)

scalacOptions := {
  println("->>>>>>>>>>>>>>>>>>>>")
  var ur =  update.value
  clean.value
  println("-<<<<<<<<<<<<<<<<<<<<")
  ur.allConfigurations.map(_.toString)
},

gives then:

[IJ]sbt:work> show scalacOptions
[info] Updating ...
[info] Done updating.
->>>>>>>>>>>>>>>>>>>>
-<<<<<<<<<<<<<<<<<<<<
[info] * compile
[info] * runtime
[info] * test
[info] * provided
[info] * optional
[info] * compile-internal
[info] * runtime-internal
[info] * test-internal
[info] * plugin
[info] * pom
[info] * scala-tool
[success] Total time: 1 s, completed Feb 25, 2018 10:42:55 PM
[IJ]sbt:work>

mattkirwan added a commit to mattkirwan/sbt.github.com that referenced this issue Mar 30, 2018
Updated scalacOptions examples to output correct Seq[String]'s - raised here: sbt/website#501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants