Comments (6)
It seems we did not set
scalacOptions
forX
.
sbt's default compile
task is implemented by JvmPlugin, and unfortunately I think it needs to inject scalacOptions at the subproject level for various reasons, for example
sbt/main/src/main/scala/sbt/Defaults.scala
Lines 982 to 988 in 586e0a7
Test / scalacOptions
as the first one, and we also seeZero / Test / scalacOptions
. Aren't they are the same scope?
I think the first one means ProjectRef(uri("file:/Users/liufengyun/Documents/sbt-bug/"), "X") / Test / scalacOptions
, but we omit the subproject part when we display it.
from sbt.
Hi @liufengyun!
Your example is probably hitting Rule 1 - https://www.scala-sbt.org/1.x/docs/Scope-Delegation.html#Rule+1%3A+Scope+axis+precedence
Rule 1: Scope axes have the following precedence: the subproject axis, the configuration axis, and then the task axis.
Anything on subproject Zero
would be ignored for scalacOptions
because there's an existing value in the subproject X
. I plan to change the semantic of the bare settings in sbt 2.x to address this issue - dbaa34b
from sbt.
Thank you for the quick response @eed3si9n .
there's an existing value in the subproject X
Could you elaborate more about it? It seems we did not set scalacOptions
for X
. In particular, I would expect scalacOptions
and foo
to behave the same.
When I inspect the delegates precedence, it lists Test / scalacOptions
as the first one, and we also see Zero / Test / scalacOptions
. Aren't they are the same scope?
sbt:X> inspect X / Test / scalacOptions
[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info] Options for the Scala compiler.
[info] Provided by:
[info] ProjectRef(uri("file:/Users/liufengyun/Documents/sbt-bug/"), "X") / Test / scalacOptions
[info] Defined at:
[info] (sbt.Defaults.configTasks) Defaults.scala:975
[info] (sbt.Defaults.configTasks) Defaults.scala:982
[info] (sbt.Classpaths.compilerPluginConfig) Defaults.scala:4205
[info] (sbt.plugins.SemanticdbPlugin.configurationSettings) SemanticdbPlugin.scala:72
[info] (sbt.plugins.SemanticdbPlugin.configurationSettings) SemanticdbPlugin.scala:80
[info] Dependencies:
[info] Test / settingsData
[info] Test / semanticdbEnabled
[info] Test / configuration
[info] Test / autoCompilerPlugins
[info] Test / scalacOptions / streams
[info] Test / fileConverter
[info] Test / buildDependencies
[info] Test / exportPipelining
[info] Test / scalaVersion
[info] Test / thisProjectRef
[info] Test / earlyOutput
[info] Test / sbtPlugin
[info] Test / update
[info] Test / semanticdbOptions
[info] Reverse dependencies:
[info] Test / bspBuildTargetScalacOptionsItem
[info] printTask
[info] Delegates:
[info] Test / scalacOptions
[info] Runtime / scalacOptions
[info] Compile / scalacOptions
[info] scalacOptions
[info] ThisBuild / Test / scalacOptions
[info] ThisBuild / Runtime / scalacOptions
[info] ThisBuild / Compile / scalacOptions
[info] ThisBuild / scalacOptions
[info] Zero / Test / scalacOptions
[info] Zero / Runtime / scalacOptions
[info] Zero / Compile / scalacOptions
[info] Global / scalacOptions
[info] Related:
[info] Zero / Test / scalacOptions
[info] Test / doc / scalacOptions
[info] Compile / scalacOptions
[info] Global / scalacOptions
[info] Compile / doc / scalacOptions
from sbt.
Thank you for the explanation @eed3si9n !
Now I see the resolution rules are observed. For end users, the rules are seemingly violated due to the implicit injections.
It would be nice to have an injection mechanism that can avoid such surprises. It will be more natural to users if the injection only intercepts and transforms the resolution result in a reasonable way --- such that the resolution rules would "seem" to be effective in spite of the injection.
I see it's a complicated design problem, it's already beyond the reach of most build tools.
from sbt.
Yea with dbaa34b (https://eed3si9n.com/simplifying-sbt-with-common-settings/),
scalacOptions := scalacOptions.value.filter(_ != "-Ysafe-init-global")
would be injected into all subprojects in sbt 2.x.
from sbt.
That sounds like a very good design --- it solves both simple and complex problems with low cognitive load. Yet it's still easy to explain to experts simply by saying they are "automatic subproject-level settings".
One minor detail: I guess users can still specify the axis of the common settings, right? That would make advanced use cases possible.
from sbt.
Related Issues (20)
- Please update the documentation HOT 1
- Sbt server displays weird characters around dates on Windows HOT 6
- java exception during first attempt to do REPL completion by TAB in sbt console on Scala 3.4.1 HOT 5
- Error message in log when compiling: BufferStrategyPaintManager$ HOT 5
- Sbt build times substantially slower on Windows vs Ubuntu. HOT 1
- `sbt.PluginData#dependencyClasspath` contains multiple `scala-library/compiler/reflect/xml` jars HOT 6
- How to report slowness issues from built-in resolver repo.typesafe.com (scala.jfrog.io)? HOT 16
- NPE when compiling HOT 1
- Fail to boot with match error with `scala-tools-releases` in `repositories` HOT 3
- Project not found when running with ++scalaVersion HOT 1
- Unable to run tests with javaOptions HOT 2
- Scala program does not receive EOF when using `sbt run`
- SBT console "swallow" keypresses on JDK 22 and Windows 10
- sbt doesn't seem to follow 307 redirects HOT 1
- sbt whatDependsOn does not work anymore HOT 2
- set window title to organization + artifactId + sbt command HOT 1
- Incorrect spacing in build.properties causes sbt bash script to incorrectly choose to use native client
- files that depend on a dynamic class (say C) are not recompiled when C's private fields become public HOT 3
- Not able to start more than one service at a time using different ports. error is SBT server is already booting.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbt.