1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package mill.scalalib
import ammonite.ops._
import mill._
import mill.define.Discover
import mill.util.{TestEvaluator, TestUtil}
import utest._
object GenIdeaTests extends TestSuite {
val millSourcePath = pwd / 'target / 'workspace / "gen-idea"
trait HelloWorldModule extends scalalib.ScalaModule {
def scalaVersion = "2.12.4"
def millSourcePath = GenIdeaTests.millSourcePath
}
object HelloWorld extends TestUtil.BaseModule with HelloWorldModule
val helloWorldEvaluator = TestEvaluator.static(HelloWorld)
def tests: Tests = Tests {
'genIdeaTests - {
val pp = new scala.xml.PrettyPrinter(999, 4)
val layout = GenIdea.xmlFileLayout(helloWorldEvaluator.evaluator, HelloWorld, fetchMillModules = false)
for((relPath, xml) <- layout){
write.over(millSourcePath/ "generated"/ relPath, pp.format(xml))
}
Seq(
"gen-idea/idea_modules/iml" ->
millSourcePath / "generated" / ".idea_modules" /".iml",
"gen-idea/idea_modules/root.iml" ->
millSourcePath / "generated" / ".idea_modules" /"root.iml",
"gen-idea/idea/libraries/scala-library-2.12.4.jar.xml" ->
millSourcePath / "generated" / ".idea" / "libraries" / "scala-library-2.12.4.jar.xml",
"gen-idea/idea/libraries/scala-library-2.12.4-sources.jar.xml" ->
millSourcePath / "generated" / ".idea" / "libraries" / "scala-library-2.12.4-sources.jar.xml",
"gen-idea/idea/modules.xml" ->
millSourcePath / "generated" / ".idea" / "modules.xml",
"gen-idea/idea/misc.xml" ->
millSourcePath / "generated" / ".idea" / "misc.xml"
).foreach { case (resource, generated) =>
val resourceString = scala.io.Source.fromResource(resource).getLines().mkString("\n")
val generatedString = normaliseLibraryPaths(read! generated)
assert(resourceString == generatedString)
}
}
}
private val libPathRegex = """([\w/]+)/.coursier""".r
private def normaliseLibraryPaths(in: String): String = {
libPathRegex.replaceAllIn(in, "COURSIER_HOME")
}
}
|