Skip to content

Commit e8fb6ea

Browse files
authored
Readd the deprecated ivy string interpolator and some fixes (#5351)
The interpolated `ivy"g:a:v"` string is heavily used outside of Mill buildscripts, e.g. in various repository managers and search result pages. The popular Mvnrepository Search recently added support for Mill. https://mvnrepository.com/artifact/com.lihaoyi/mill-dist/1.0.0-RC2 ![grafik](https://github.com/user-attachments/assets/374e2924-02f9-4199-a262-66e5dae3c7a2) Unfortunately, those pages often use the now removed `ivy` interpolator. To improved the user experience, this PR re-adds the `ivy` interpolator, such that copy and pasting dependencies from such portals just works. Users should instantly see the deprecation warning and learn, that they should use `mvn` instead. But at least, the build succeeds, whereas in the current state, it would fail. Pull request: #5351
1 parent e5fd573 commit e8fb6ea

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

libs/kotlinlib/src/mill/kotlinlib/package.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package mill
22

33
package object kotlinlib {
4-
implicit class DepSyntax(ctx: StringContext) {
5-
def mvn(args: Any*): Dep = Dep.parse {
6-
(
7-
ctx.parts.take(args.length).zip(args).flatMap { case (p, a) => Seq(p, a) } ++
8-
ctx.parts.drop(args.length)
9-
).mkString
10-
}
4+
implicit class DepSyntax(ctx: StringContext) extends AnyVal {
5+
def mvn(args: Any*): Dep = mill.scalalib.DepSyntax(ctx).mvn(args*)
6+
7+
@deprecated("Use `mvn` string interpolator instead.", "Mill 0.12.11")
8+
def ivy(args: Any*): Dep = mill.scalalib.DepSyntax(ctx).mvn(args*)
119
}
1210

1311
type Dep = mill.scalalib.Dep

libs/scalalib/src/mill/javalib/package.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package mill
22

33
package object javalib extends mill.scalalib.JsonFormatters {
4-
implicit class DepSyntax(ctx: StringContext) {
5-
def mvn(args: Any*): Dep = Dep.parse {
6-
(
7-
ctx.parts.take(args.length).zip(args).flatMap { case (p, a) => Seq(p, a) } ++
8-
ctx.parts.drop(args.length)
9-
).mkString
10-
}
4+
implicit class DepSyntax(ctx: StringContext) extends AnyVal {
5+
def mvn(args: Any*): Dep = mill.scalalib.DepSyntax(ctx).mvn(args*)
6+
7+
@deprecated("Use `mvn` string interpolator instead.", "Mill 0.12.11")
8+
def ivy(args: Any*): Dep = mill.scalalib.DepSyntax(ctx).mvn(args*)
119
}
1210

1311
val Assembly = mill.scalalib.Assembly

libs/scalalib/src/mill/scalalib/Dep.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ case class Dep(dep: coursier.Dependency, cross: CrossVersion, force: Boolean) {
1111
require(
1212
!dep.module.name.value.contains("/") &&
1313
!dep.module.organization.value.contains("/") &&
14-
!dep.version.contains("/"),
14+
!dep.versionConstraint.asString.contains("/"),
1515
"Dependency coordinates must not contain `/`s"
1616
)
1717

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
package mill
22

33
package object scalalib extends mill.scalalib.JsonFormatters {
4-
implicit class DepSyntax(ctx: StringContext) {
4+
5+
implicit class DepSyntax(ctx: StringContext) extends AnyVal {
56
def mvn(args: Any*): Dep = Dep.parse {
67
(
78
ctx.parts.take(args.length).zip(args).flatMap { case (p, a) => Seq(p, a) } ++
89
ctx.parts.drop(args.length)
910
).mkString
1011
}
12+
13+
@deprecated("Use `mvn` string interpolator instead.", "Mill 0.12.11")
14+
def ivy(args: Any*): Dep = mvn(args*)
1115
}
1216

1317
val CrossVersion = mill.define.CrossVersion
1418
type CrossVersion = mill.define.CrossVersion
19+
1520
}

0 commit comments

Comments
 (0)