Skip to content

Commit e0898ae

Browse files
authored
Misc cleanups (#6107)
- Use `enableBsp = false` to skip useless IntelliJ modules for `example.{local,packaged,native}.{daemon,nodaemon}` modules, speeds up intellij import from 10+min to 2+min - Flesh out `ScriptHeaderChanges` integration tests to cover more cases - Remove `@compileTimeOnly` from `ModuleCtx.dummyInfo` and `Task` macro, using runtime exceptions instead to avoid spurious intellij error highlighting - Bump Mill version - Add retries around `mill.server.Server.tryLockBlock` to make it robust in case of collisions with the client polling the lock, which should fix #5895. Remove older incorrect fixes
1 parent fad2352 commit e0898ae

File tree

18 files changed

+122
-118
lines changed

18 files changed

+122
-118
lines changed

build.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//| mill-version: 1.0.6-95-b08901
1+
//| mill-version: 1.0.6-114-ed0e74
22
//| mill-jvm-opts: ["-XX:NonProfiledCodeHeapSize=250m", "-XX:ReservedCodeCacheSize=500m"]
33
//| mill-opts: ["--jobs=0.5C"]
44

core/api/src/mill/api/ModuleCtx.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package mill.api
22

33
import mill.api.internal.OverrideMapping
44

5-
import scala.annotation.{compileTimeOnly, implicitNotFound}
5+
import scala.annotation.implicitNotFound
66

77
/**
88
* The contextual information provided to a [[mill.api.Module]] or [[mill.api.Task]]
@@ -163,11 +163,10 @@ object ModuleCtx extends LowPriCtx {
163163
}
164164

165165
trait LowPriCtx {
166-
// Dummy `Ctx` available in implicit scope but never actually used.
166+
// Dummy `Ctx` available in implicit scope but must not be actually used.
167167
// as it is provided by the codegen. Defined for IDEs to think that one is available
168168
// and not show errors in build.mill/package.mill even though they can't see the codegen
169-
@compileTimeOnly(
169+
implicit def dummyInfo: ModuleCtx = sys.error(
170170
"Modules and Tasks can only be defined within a mill Module (in `build.mill` or `package.mill` files)"
171171
)
172-
implicit def dummyInfo: ModuleCtx = sys.error("implicit Ctx must be provided")
173172
}

core/api/src/mill/api/internal/Cacher.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ private[mill] object Cacher {
7272

7373
val thisSel = This(owner.owner).asExprOf[Cacher]
7474
'{ $thisSel.cachedTask[T](${ t })(using $enclosingCtx) }
75-
} else report.errorAndAbort(
76-
"Task{} members must be defs defined in a Module class/trait/object body",
77-
Position.ofMacroExpansion
78-
)
75+
} else '{
76+
// Use a runtime exception to prevent false error highlighting in IntelliJ
77+
throw new Exception("Task{} members must be defs defined in a Module class/trait/object body")
78+
}
7979
}
8080
}

core/api/test/src/mill/api/MacroErrorTests.scala

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ import scala.annotation.unused
88
object MacroErrorTests extends TestSuite {
99

1010
val tests = Tests {
11-
12-
test("errors") {
13-
val expectedMsg =
14-
"Task{} members must be defs defined in a Module class/trait/object body"
15-
16-
val err = assertCompileError("object Foo extends TestRootModule{ val x = Task {1} }")
17-
assert(err.msg == expectedMsg)
18-
}
19-
2011
test("badParameterSets") {
2112
test("command") {
2213
val e = assertCompileError("""
@@ -119,19 +110,7 @@ object MacroErrorTests extends TestSuite {
119110
lazy val millDiscover = Discover[this.type]
120111
}
121112
}
122-
test("neg1") {
123-
val e = assertCompileError("""def a = Task { 1 }""")
124-
assert(e.msg.contains(
125-
"Task{} members must be defs defined in a Module class/trait/object body"
126-
))
127-
}
128113

129-
test("neg2") {
130-
val e = assertCompileError("object foo extends TestRootModule{ val a = Task { 1 } }")
131-
assert(e.msg.contains(
132-
"Task{} members must be defs defined in a Module class/trait/object body"
133-
))
134-
}
135114
test("neg3") {
136115

137116
val expectedMsg =

integration/failure/build-yaml-errors/resources/build.mill.yaml

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extends: [mill.javalib.JavaModule]
2+
mvnDepsTypo: []
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: [mill.javalib.JavaModuleTypod]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package mill.integration
2+
3+
import mill.testkit.UtestIntegrationTestSuite
4+
5+
import utest._
6+
7+
// Basic tests for errors in build.mill.yaml an package.mill.yaml files. The errors don't
8+
// look great, but for now just assert on them and make sure they don't regress
9+
object BuildYamlErrorsTests extends UtestIntegrationTestSuite {
10+
val tests: Tests = Tests {
11+
integrationTest { tester =>
12+
val res = tester.eval("version")
13+
assert(res.err.replace('\\', '/').contains("mispelledextends/package.mill.yaml"))
14+
assert(res.err.contains("trait package_ extends mill.javalib.JavaModuleTypod"))
15+
assert(res.err.contains("type JavaModuleTypod is not a member of mill.javalib"))
16+
17+
os.remove.all(tester.workspacePath / "mispelledextends")
18+
19+
val res2 = tester.eval("version")
20+
assert(res2.err.replace('\\', '/').contains("invalidtaskname/package.mill.yaml"))
21+
assert(res2.err.contains("override def mvnDepsTypo = Task.Literal(\"\"\"[]\"\"\")"))
22+
assert(res2.err.contains("method mvnDepsTypo overrides nothin"))
23+
}
24+
}
25+
}

integration/failure/module-outside-top-level-module/resources/build.mill

Lines changed: 0 additions & 6 deletions
This file was deleted.

integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)