summaryrefslogtreecommitdiff
path: root/scalalib
diff options
context:
space:
mode:
authorAndres Pipicello <andres.pipicello@olx.com>2019-06-18 15:25:16 -0300
committerTobias Roeser <le.petit.fou@web.de>2019-06-28 08:37:39 +0200
commit1ae2061ca5ba6eecf18d4b17203717526d1b3d39 (patch)
tree9a232fd347701548ba44b84029f5b30f113225a0 /scalalib
parentc2c64bbbc4034fdfbd9bc4da56f25fef3cd68f63 (diff)
downloadmill-1ae2061ca5ba6eecf18d4b17203717526d1b3d39.tar.gz
mill-1ae2061ca5ba6eecf18d4b17203717526d1b3d39.tar.bz2
mill-1ae2061ca5ba6eecf18d4b17203717526d1b3d39.zip
Using mill source path instead of pwd
Diffstat (limited to 'scalalib')
-rwxr-xr-xscalalib/src/GenIdeaImpl.scala28
-rw-r--r--scalalib/test/resources/gen-idea-hello-world/build.sc1
-rw-r--r--scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml12
-rw-r--r--scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml12
-rw-r--r--scalalib/test/src/GenIdeaTests.scala10
5 files changed, 32 insertions, 31 deletions
diff --git a/scalalib/src/GenIdeaImpl.scala b/scalalib/src/GenIdeaImpl.scala
index 97decd3f..f27fb1da 100755
--- a/scalalib/src/GenIdeaImpl.scala
+++ b/scalalib/src/GenIdeaImpl.scala
@@ -23,29 +23,31 @@ object GenIdea extends ExternalModule {
implicitly,
ev.rootModule,
ev.rootModule.millDiscover
- )
+ ).run()
}
implicit def millScoptEvaluatorReads[T] = new mill.main.EvaluatorScopt[T]()
lazy val millDiscover = Discover[this.type]
}
-object GenIdeaImpl {
+case class GenIdeaImpl(evaluator: Evaluator,
+ ctx: Log with Home,
+ rootModule: BaseModule,
+ discover: Discover[_]) {
+ val cwd: Path = rootModule.millSourcePath
- def apply(evaluator: Evaluator,
- ctx: Log with Home,
- rootModule: BaseModule,
- discover: Discover[_]): Unit = {
- val pp = new scala.xml.PrettyPrinter(999, 4)
+ def run(): Unit = {
- val jdkInfo = extractCurrentJdk(os.pwd / ".idea" / "misc.xml").getOrElse(("JDK_1_8", "1.8 (1)"))
- os.remove.all(os.pwd/".idea"/"libraries")
- os.remove.all(os.pwd/".idea"/"scala_compiler.xml")
- os.remove.all(os.pwd/".idea_modules")
+ val pp = new scala.xml.PrettyPrinter(999, 4)
+ val jdkInfo = extractCurrentJdk(cwd / ".idea" / "misc.xml").getOrElse(("JDK_1_8", "1.8 (1)"))
+
+ os.remove.all(cwd/".idea"/"libraries")
+ os.remove.all(cwd/".idea"/"scala_compiler.xml")
+ os.remove.all(cwd/".idea_modules")
for((relPath, xml) <- xmlFileLayout(evaluator, rootModule, jdkInfo, Some(ctx))){
- os.write.over(os.pwd/relPath, pp.format(xml), createFolders = true)
+ os.write.over(cwd/relPath, pp.format(xml), createFolders = true)
}
}
@@ -326,7 +328,7 @@ object GenIdeaImpl {
}
def relify(p: os.Path) = {
- val r = p.relativeTo(os.pwd/".idea_modules")
+ val r = p.relativeTo(cwd/".idea_modules")
(Seq.fill(r.ups)("..") ++ r.segments).mkString("/")
}
diff --git a/scalalib/test/resources/gen-idea-hello-world/build.sc b/scalalib/test/resources/gen-idea-hello-world/build.sc
index 53cd26a9..45ec2536 100644
--- a/scalalib/test/resources/gen-idea-hello-world/build.sc
+++ b/scalalib/test/resources/gen-idea-hello-world/build.sc
@@ -1,5 +1,4 @@
import mill.scalalib
-import $ivy.`com.lihaoyi::mill-contrib-buildinfo:0.4.0`
trait HelloWorldModule extends scalalib.ScalaModule {
def scalaVersion = "2.12.4"
diff --git a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml
index 38ea17be..6808e515 100644
--- a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml
+++ b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml
@@ -1,12 +1,12 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
- <output url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/out/HelloWorld/compile/dest/classes"/>
+ <output url="file://$MODULE_DIR$/../out/HelloWorld/compile/dest/classes"/>
<exclude-output/>
- <content url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/out/HelloWorld/generatedSources/dest"/>
- <content url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld">
- <sourceFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/src" isTestSource="false"/>
- <sourceFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/resources" type="java-resource"/>
- <excludeFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/target"/>
+ <content url="file://$MODULE_DIR$/../out/HelloWorld/generatedSources/dest"/>
+ <content url="file://$MODULE_DIR$/../HelloWorld">
+ <sourceFolder url="file://$MODULE_DIR$/../HelloWorld/src" isTestSource="false"/>
+ <sourceFolder url="file://$MODULE_DIR$/../HelloWorld/resources" type="java-resource"/>
+ <excludeFolder url="file://$MODULE_DIR$/../HelloWorld/target"/>
</content>
<orderEntry type="inheritedJdk"/>
<orderEntry type="sourceFolder" forTests="false"/>
diff --git a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml
index bfe0ff3c..26fac21d 100644
--- a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml
+++ b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml
@@ -1,12 +1,12 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
- <output-test url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/out/HelloWorld/test/compile/dest/classes"/>
+ <output-test url="file://$MODULE_DIR$/../out/HelloWorld/test/compile/dest/classes"/>
<exclude-output/>
- <content url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/out/HelloWorld/test/generatedSources/dest"/>
- <content url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/test">
- <sourceFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/test/src" isTestSource="true"/>
- <sourceFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/test/resources" type="java-test-resource"/>
- <excludeFolder url="file://$MODULE_DIR$/../target/workspace/gen-idea-hello-world/HelloWorld/test/target"/>
+ <content url="file://$MODULE_DIR$/../out/HelloWorld/test/generatedSources/dest"/>
+ <content url="file://$MODULE_DIR$/../HelloWorld/test">
+ <sourceFolder url="file://$MODULE_DIR$/../HelloWorld/test/src" isTestSource="true"/>
+ <sourceFolder url="file://$MODULE_DIR$/../HelloWorld/test/resources" type="java-test-resource"/>
+ <excludeFolder url="file://$MODULE_DIR$/../HelloWorld/test/target"/>
</content>
<orderEntry type="inheritedJdk"/>
<orderEntry type="sourceFolder" forTests="false"/>
diff --git a/scalalib/test/src/GenIdeaTests.scala b/scalalib/test/src/GenIdeaTests.scala
index efd6381c..b7d3a257 100644
--- a/scalalib/test/src/GenIdeaTests.scala
+++ b/scalalib/test/src/GenIdeaTests.scala
@@ -13,17 +13,17 @@ object GenIdeaTests extends ScriptTestSuite(false) {
Seq(
s"$workspaceSlug/idea_modules/helloworld.iml" ->
- os.pwd / ".idea_modules" /"helloworld.iml",
+ workspacePath / ".idea_modules" /"helloworld.iml",
s"$workspaceSlug/idea_modules/helloworld.test.iml" ->
- os.pwd / ".idea_modules" /"helloworld.test.iml",
+ workspacePath / ".idea_modules" /"helloworld.test.iml",
// s"$workspaceSlug/idea_modules/mill-build.iml" ->
// os.pwd / ".idea_modules" /"mill-build.iml",
s"$workspaceSlug/idea/libraries/scala-library-2.12.4.jar.xml" ->
- os.pwd / ".idea" / "libraries" / "scala-library-2.12.4.jar.xml",
+ workspacePath / ".idea" / "libraries" / "scala-library-2.12.4.jar.xml",
s"$workspaceSlug/idea/modules.xml" ->
- os.pwd / ".idea" / "modules.xml",
+ workspacePath / ".idea" / "modules.xml",
s"$workspaceSlug/idea/misc.xml" ->
- os.pwd / ".idea" / "misc.xml"
+ workspacePath / ".idea" / "misc.xml"
).foreach { case (resource, generated) =>
val resourceString = scala.io.Source.fromResource(resource).getLines().mkString("\n")
val generatedString = normaliseLibraryPaths(os.read(generated))