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

[2.x] Document plugin cross building #1242

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/reference/changes/migrating-from-sbt-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,32 @@ In sbt 1.x bare settings were project settings that applied only to the root sub
```

```scala
name := "root"
name := "root" // every subprojects will be named root!
publish / skip := true
```

### Migrating ThisBuild

In sbt 2.x, bare settings settings should no longer be scoped to `ThisBuild`. One benefit of the new _common settings_ over `ThisBuild` is that it would act in a more predictable delegation. These settings are inserted between plugins settings and those defined in `settings(...)`, meaning they can be used to define settings like `Compile / scalacOptions`, which was not possible with `ThisBuild`.

Cross building sbt plugins
--------------------------

In sbt 2.x, if you cross build an sbt plugin with Scala 3.x and 2.12.x, it will automatically cross build against sbt 1.x and sbt 2.x:

```scala
// using sbt 2.x
lazy val plugin = (projectMatrix in file("plugin"))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-vimquit",
)
.jvmPlatform(scalaVersions = Seq("3.3.3", "2.12.20"))
```

If you use `projectMatrix`, make sure to move the plugin to a subdirectory like `plugin/`. Otherwise, the synthetic root project will also pick up the `src/`.
Use sbt 1.10.2 or later to cross build from sbt 1.x side.

Migrating to slash syntax
-------------------------

Expand Down
4 changes: 3 additions & 1 deletion src/reference/changes/sbt-2.0-change-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ See also [Migrating from sbt 1.x](./migrating-from-sbt-1.x.md).
- Bare settings are added to all subprojects, as opposed to just the root subproject, and thus replacing the role that `ThisBuild` has played. by [@eed3si9n][@eed3si9n] in [#6746][6746]
- `test` task is changed to be incremental test that can cache test results. Use `testFull` for full test by [@eed3si9n][@eed3si9n] in [#7686][7686]
- sbt 2.x plugins are published with `_sbt2_3` suffix by [@eed3si9n][@eed3si9n] in [#7671][7671]
- sbt 2.x adds `platform` setting so `ModuleID`'s `%%` operator can cross build on JVM as well as JS and Native, as opposed to `%%%` operator that was created in a plugin to workaround this issue. by [@eed3si9n][@eed3si9n] in [#6746][6746]
- sbt 2.x adds `platform` setting so `ModuleID`'s `%%` operator can cross build on JVM as well as JS and Native, as opposed to `%%%` operator that was created in a plugin to workaround this issue, by [@eed3si9n][@eed3si9n] in [#6746][6746]
- Dropped `useCoursier` setting so Coursier cannot be opted out, by [@eed3si9n][@eed3si9n] in [#7712][7712]

### Dropped dreprecations

Expand All @@ -41,5 +42,6 @@ See also:
[7671]: https://github.com/sbt/sbt/pull/7671
[7686]: https://github.com/sbt/sbt/pull/7686
[7700]: https://github.com/sbt/sbt/pull/7700
[7712]: https://github.com/sbt/sbt/pull/7712
[@eed3si9n]: https://github.com/eed3si9n
[@adpi2]: https://github.com/adpi2