sbt / sbt/website

Task graph / .. task that depends on other settings - broken example

Open
#500 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Scala
Stars
73
Forks
351
Avg merge
5h 21m
Merged PRs (30d)
9

Description

In the Getting Started Guide this example is not working as described with sbt 1.0.2:
http://www.scala-sbt.org/1.x/docs/Task-Graph.html#Defining+a+task+that+depends+on+other+settings

$ cat build.sbt 
lazy val root = (project in file("."))
  .settings(
    name := "Hello",
    organization := "com.example",
    scalaVersion := "2.12.3",
    version := "0.1.0-SNAPSHOT",
    scalacOptions := List("-encoding", "utf8", "-Xfatal-warnings", "-deprecation", "-unchecked"),
    scalacOptions := {
      val old = scalacOptions.value
      scalaBinaryVersion.value match {
        case "2.12" => old
        case _      => old filterNot (Set("-Xfatal-warnings", "-deprecation").apply)
      }
    }
  )

$ sbt about
[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.
[info] Loading settings from build.sbt ...
[info] Set current project to Hello (in build file:/home/kelemen/temp/sbt-started/)
[info] This is sbt 1.0.2
[info] The current project is {file:/home/kelemen/temp/sbt-started/}root 0.1.0-SNAPSHOT
[info] The current project is built against Scala 2.12.3
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.3

$ sbt
[info] Loading project definition from /home/kelemen/temp/sbt-started/project
[info] Loading settings from build.sbt ...
[info] Set current project to Hello (in build file:/home/kelemen/temp/sbt-started/)
[info] sbt server started at 127.0.0.1:5797
sbt:Hello> show scalacOptions
[info] * -encoding
[info] * utf8
[info] * -Xfatal-warnings
[info] * -deprecation
[info] * -unchecked
[success] Total time: 0 s, completed Sep 28, 2017 5:53:13 PM
sbt:Hello> ++2.11.8
[info] Setting Scala version to 2.11.8 on 0 projects.
[info] Excluded 1 projects, run ++ 2.11.8 -v for more details.
[info] Reapplying settings...
[info] Set current project to Hello (in build file:/home/kelemen/temp/sbt-started/)
sbt:Hello> show scalacOptions
[info] * -encoding
[info] * utf8
[info] * -Xfatal-warnings
[info] * -deprecation
[info] * -unchecked
[success] Total time: 0 s, completed Sep 28, 2017 5:53:30 PM

The problem is with the second execution of show scalacOptions, because according to the example it should only display -encoding, utf8, -unchecked and NOT -Xfatal-warnings and -deprecation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Getting Started Guide's Task Graph section, especially the example in build.sbt, and reproduce it with sbt 1.0.2 using show scalacOptions and ++2.11.8. Done means the documented example and its expected scalacOptions output agree, with the guide updated if needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.