You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>See also <ahref="./migrating-from-sbt-1.x.html">Migrating from sbt 1.x</a>.</p>
194
194
<ul>
195
195
<li>sbt 2.x uses Scala 3.x for build definitions and plugins (Both sbt 1.x and 2.x are capable of building Scala 2.x and 3.x) by <ahref="https://github.com/eed3si9n">@eed3si9n</a>, <ahref="https://github.com/adpi2">@adpi2</a>, and others.</li>
196
-
<li>Bare settings are added to all subprojects, as opposed to just the root subproject, and thus replacing the role that <code>ThisBuild</code> has played. by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/6746">#6746</a></li>
196
+
<li>Bare settings are added to all subprojects, as opposed to just the root subproject, and thus replacing the role that <code>ThisBuild</code> has played.</li>
197
197
<li><code>test</code> task is changed to be incremental test that can cache test results. Use <code>testFull</code> for full test by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7686">#7686</a></li>
198
198
<li>sbt 2.x plugins are published with <code>_sbt2_3</code> suffix by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7671">#7671</a></li>
199
199
<li>sbt 2.x adds <code>platform</code> setting so <code>ModuleID</code>'s <code>%%</code> operator can cross build on JVM as well as JS and Native, as opposed to <code>%%%</code> operator that was created in a plugin to workaround this issue, by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/6746">#6746</a></li>
<li>Project matrix, which was available via plugin in sbt 1.x, is in-sourced.</li>
209
-
<li>Local/remote hybrid cache system. sbt 2.x implements cached task, which can automatically cache the task results to local disk and Bazel-compatible remote cache. by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7464">#7464</a> / <ahref="https://github.com/sbt/sbt/pull/7525">#7525</a></li>
209
+
<li>sbt 2.x extends the unified slash syntax to support query of subprojects. Details below.</li>
<p>In sbt 2.x, the bare settings in <code>build.sbt</code> are interpreted to be common settings, and are injected to all subprojects. This means we can now set <code>scalaVersion</code> without using <code>ThisBuild</code> scoping:</p>
<p>This also fixes the so-called dynamic dispatch problem:</p>
217
+
<pre><codeclass="language-scala">lazy val hi = taskKey[String]("")
218
+
hi := name.value + "!"
219
+
</code></pre>
220
+
<p>In sbt 1.x <code>hi</code> task will capture the name of the root project, but in sbt 2.x it will return the <code>name</code> of each subproject with <code>!</code>:</p>
<p>The above runs all subprojects whose <code>scalaBinaryVersion</code> is <code>3</code>. Contributed by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7699">#7699</a></p>
<p>sbt 2.x implements cached task, which can automatically cache the task results to local disk and Bazel-compatible remote cache.</p>
243
+
<pre><codeclass="language-scala">lazy val task1 = taskKey[String]("doc for task1")
244
+
245
+
task1 := (Def.cachedTask {
246
+
name.value + version.value + "!"
247
+
}).value
248
+
</code></pre>
249
+
<p>This tracks the inputs into the <code>task1</code> and creates a machine-wide disk cache, which can also be configured to also use a remote cache. Since it's common for sbt tasks to also produce files on the side, we also provide a mechanism to cache file contents:</p>
250
+
<pre><codeclass="language-scala">lazy val task1 = taskKey[String]("doc for task1")
251
+
252
+
task1 := (Def.cachedTask {
253
+
val converter = fileConverter.value
254
+
....
255
+
val output = converter.toVirtualFile(somefile)
256
+
Def.declareOutput(output)
257
+
name.value + version.value + "!"
258
+
}).value
259
+
</code></pre>
260
+
<p>Contributed by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7464">#7464</a> / <ahref="https://github.com/sbt/sbt/pull/7525">#7525</a></p>
211
261
<h2id="previously-on-sbt"><aclass="header" href="#previously-on-sbt">Previously on sbt</a></h2>
<p>See also <ahref="changes/./migrating-from-sbt-1.x.html">Migrating from sbt 1.x</a>.</p>
1369
1369
<ul>
1370
1370
<li>sbt 2.x uses Scala 3.x for build definitions and plugins (Both sbt 1.x and 2.x are capable of building Scala 2.x and 3.x) by <ahref="https://github.com/eed3si9n">@eed3si9n</a>, <ahref="https://github.com/adpi2">@adpi2</a>, and others.</li>
1371
-
<li>Bare settings are added to all subprojects, as opposed to just the root subproject, and thus replacing the role that <code>ThisBuild</code> has played. by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/6746">#6746</a></li>
1371
+
<li>Bare settings are added to all subprojects, as opposed to just the root subproject, and thus replacing the role that <code>ThisBuild</code> has played.</li>
1372
1372
<li><code>test</code> task is changed to be incremental test that can cache test results. Use <code>testFull</code> for full test by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7686">#7686</a></li>
1373
1373
<li>sbt 2.x plugins are published with <code>_sbt2_3</code> suffix by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7671">#7671</a></li>
1374
1374
<li>sbt 2.x adds <code>platform</code> setting so <code>ModuleID</code>'s <code>%%</code> operator can cross build on JVM as well as JS and Native, as opposed to <code>%%%</code> operator that was created in a plugin to workaround this issue, by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/6746">#6746</a></li>
<li>Project matrix, which was available via plugin in sbt 1.x, is in-sourced.</li>
1384
-
<li>Local/remote hybrid cache system. sbt 2.x implements cached task, which can automatically cache the task results to local disk and Bazel-compatible remote cache. by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7464">#7464</a> / <ahref="https://github.com/sbt/sbt/pull/7525">#7525</a></li>
1384
+
<li>sbt 2.x extends the unified slash syntax to support query of subprojects. Details below.</li>
<p>In sbt 2.x, the bare settings in <code>build.sbt</code> are interpreted to be common settings, and are injected to all subprojects. This means we can now set <code>scalaVersion</code> without using <code>ThisBuild</code> scoping:</p>
<p>This also fixes the so-called dynamic dispatch problem:</p>
1392
+
<pre><codeclass="language-scala">lazy val hi = taskKey[String]("")
1393
+
hi := name.value + "!"
1394
+
</code></pre>
1395
+
<p>In sbt 1.x <code>hi</code> task will capture the name of the root project, but in sbt 2.x it will return the <code>name</code> of each subproject with <code>!</code>:</p>
<p>The above runs all subprojects whose <code>scalaBinaryVersion</code> is <code>3</code>. Contributed by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7699">#7699</a></p>
<p>sbt 2.x implements cached task, which can automatically cache the task results to local disk and Bazel-compatible remote cache.</p>
1418
+
<pre><codeclass="language-scala">lazy val task1 = taskKey[String]("doc for task1")
1419
+
1420
+
task1 := (Def.cachedTask {
1421
+
name.value + version.value + "!"
1422
+
}).value
1423
+
</code></pre>
1424
+
<p>This tracks the inputs into the <code>task1</code> and creates a machine-wide disk cache, which can also be configured to also use a remote cache. Since it's common for sbt tasks to also produce files on the side, we also provide a mechanism to cache file contents:</p>
1425
+
<pre><codeclass="language-scala">lazy val task1 = taskKey[String]("doc for task1")
1426
+
1427
+
task1 := (Def.cachedTask {
1428
+
val converter = fileConverter.value
1429
+
....
1430
+
val output = converter.toVirtualFile(somefile)
1431
+
Def.declareOutput(output)
1432
+
name.value + version.value + "!"
1433
+
}).value
1434
+
</code></pre>
1435
+
<p>Contributed by <ahref="https://github.com/eed3si9n">@eed3si9n</a> in <ahref="https://github.com/sbt/sbt/pull/7464">#7464</a> / <ahref="https://github.com/sbt/sbt/pull/7525">#7525</a></p>
1386
1436
<h2id="previously-on-sbt"><aclass="header" href="#previously-on-sbt">Previously on sbt</a></h2>
0 commit comments