@@ -46,13 +46,24 @@ default is `src/scalafix/scala`.
46
46
+ └── ...
47
47
```
48
48
49
- ``` diff
50
- // build.sbt
51
- + libraryDependencies +=
52
- + "ch.epfl.scala" %%
53
- + "scalafix-core" %
54
- + _root_.scalafix.sbt.BuildInfo.scalafixVersion %
55
- + ScalafixConfig
49
+ ``` scala
50
+ // build.sbt
51
+ import _root_ .scalafix .sbt .{BuildInfo => ScalafixBuildInfo }
52
+
53
+ libraryDependencies +=
54
+ (" ch.epfl.scala" %% " scalafix-core" % ScalafixBuildInfo .scalafixVersion)
55
+ .cross(CrossVersion .for3Use2_13) % ScalafixConfig
56
+
57
+ // Since sbt 1.10.x (https://github.com/sbt/sbt/pull/7480), scala3-library is
58
+ // not automatically added to non-standard configurations, but is needed by the
59
+ // Scala 3 compiler, so it must be added explicitly if no dependency brings it
60
+ // implicitly, which is the case here because the only dependency is for3Use2_13
61
+ libraryDependencies ++= {
62
+ if (scalaBinaryVersion.value == " 3" )
63
+ Seq (" org.scala-lang" %% " scala3-library" % scalaVersion.value % ScalafixConfig )
64
+ else
65
+ Nil
66
+ }
56
67
```
57
68
58
69
``` bash
@@ -102,16 +113,26 @@ promoting them to the [build-level](#as-a-separate-sub-project).
102
113
└── ...
103
114
```
104
115
105
- ``` diff
106
- // build.sbt
107
- lazy val service1 = project
108
- + .settings(
109
- + libraryDependencies +=
110
- + "ch.epfl.scala" %%
111
- + "scalafix-core" %
112
- + _root_.scalafix.sbt.BuildInfo.scalafixVersion %
113
- + ScalafixConfig
114
- + )
116
+ ``` scala
117
+ // build.sbt
118
+ import _root_ .scalafix .sbt .{BuildInfo => ScalafixBuildInfo }
119
+
120
+ lazy val service1 = project
121
+ .settings(
122
+ libraryDependencies +=
123
+ (" ch.epfl.scala" %% " scalafix-core" % ScalafixBuildInfo .scalafixVersion)
124
+ .cross(CrossVersion .for3Use2_13) % ScalafixConfig ,
125
+ // Since sbt 1.10.x (https://github.com/sbt/sbt/pull/7480), scala3-library is
126
+ // not automatically added to non-standard configurations, but is needed by the
127
+ // Scala 3 compiler, so it must be added explicitly if no dependency brings it
128
+ // implicitly, which is the case here because the only dependency is for3Use2_13
129
+ libraryDependencies ++= {
130
+ if (scalaBinaryVersion.value == " 3" )
131
+ Seq (" org.scala-lang" %% " scala3-library" % scalaVersion.value % ScalafixConfig )
132
+ else
133
+ Nil
134
+ }
135
+ )
115
136
```
116
137
117
138
``` bash
@@ -158,37 +179,44 @@ semantic rules.
158
179
└── ...
159
180
```
160
181
161
- ``` diff
162
- // build.sbt
163
- lazy val service1 = project // sub-project where rule(s) will be used
164
- + .dependsOn(`scalafix-rules` % ScalafixConfig)
165
- + lazy val `scalafix-input` = (project in file("scalafix/input"))
166
- + .disablePlugins(ScalafixPlugin)
167
- + lazy val `scalafix-output` = (project in file("scalafix/output"))
168
- + .disablePlugins(ScalafixPlugin)
169
- + lazy val `scalafix-rules` = (project in file("scalafix/rules"))
170
- + .disablePlugins(ScalafixPlugin)
171
- + .settings(
172
- + libraryDependencies +=
173
- + "ch.epfl.scala" %%
174
- + "scalafix-core" %
175
- + _root_.scalafix.sbt.BuildInfo.scalafixVersion
176
- + )
177
- + lazy val `scalafix-tests` = (project in file("scalafix/tests"))
178
- + .settings(
179
- + scalafixTestkitOutputSourceDirectories :=
180
- + (`scalafix-output` / Compile / sourceDirectories).value,
181
- + scalafixTestkitInputSourceDirectories :=
182
- + (`scalafix-input` / Compile / sourceDirectories).value,
183
- + scalafixTestkitInputClasspath :=
184
- + (`scalafix-input` / Compile / fullClasspath).value,
185
- + scalafixTestkitInputScalacOptions :=
186
- + (`scalafix-input` / Compile / scalacOptions).value,
187
- + scalafixTestkitInputScalaVersion :=
188
- + (`scalafix-input` / Compile / scalaVersion).value
189
- + )
190
- + .dependsOn(`scalafix-input`, `scalafix-rules`)
191
- + .enablePlugins(ScalafixTestkitPlugin)
182
+ ``` scala
183
+ // build.sbt
184
+ import _root_ .scalafix .sbt .{BuildInfo => ScalafixBuildInfo }
185
+
186
+ lazy val service1 = project // sub-project where rule(s) will be used
187
+ .dependsOn(`scalafix-rules` % ScalafixConfig )
188
+
189
+ lazy val `scalafix-rules` = (project in file(" scalafix/rules" ))
190
+ .disablePlugins(ScalafixPlugin )
191
+ .settings(
192
+ libraryDependencies +=
193
+ (" ch.epfl.scala" %% " scalafix-core" % ScalafixBuildInfo .scalafixVersion)
194
+ .cross(CrossVersion .for3Use2_13)
195
+ )
196
+
197
+ // Projects below are optional, demonstrating usage of the testkit for unit tests
198
+
199
+ lazy val `scalafix-input` = (project in file(" scalafix/input" ))
200
+ .disablePlugins(ScalafixPlugin )
201
+
202
+ lazy val `scalafix-output` = (project in file(" scalafix/output" ))
203
+ .disablePlugins(ScalafixPlugin )
204
+
205
+ lazy val `scalafix-tests` = (project in file(" scalafix/tests" ))
206
+ .settings(
207
+ scalafixTestkitOutputSourceDirectories :=
208
+ (`scalafix-output` / Compile / sourceDirectories).value,
209
+ scalafixTestkitInputSourceDirectories :=
210
+ (`scalafix-input` / Compile / sourceDirectories).value,
211
+ scalafixTestkitInputClasspath :=
212
+ (`scalafix-input` / Compile / fullClasspath).value,
213
+ scalafixTestkitInputScalacOptions :=
214
+ (`scalafix-input` / Compile / scalacOptions).value,
215
+ scalafixTestkitInputScalaVersion :=
216
+ (`scalafix-input` / Compile / scalaVersion).value
217
+ )
218
+ .dependsOn(`scalafix-input`, `scalafix-rules`)
219
+ .enablePlugins(ScalafixTestkitPlugin )
192
220
```
193
221
194
222
``` bash
0 commit comments