Skip to content

Commit

Permalink
Fixes com-lihaoyi#336: pass scalac options to ScalaDoc during docJar …
Browse files Browse the repository at this point in the history
…stage
  • Loading branch information
Anton Sviridov committed May 18, 2018
1 parent 7b61fc9 commit e52b58a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
4 changes: 1 addition & 3 deletions scalalib/src/mill/scalalib/ScalaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ trait ScalaModule extends JavaModule { outer =>
} yield p.toNIO.toString

val pluginOptions = scalacPluginClasspath().map(pluginPathRef => s"-Xplugin:${pluginPathRef.path}")
val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp") ++ pluginOptions
val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp") ++ pluginOptions ++ scalacOptions()

if (files.nonEmpty) subprocess(
"scala.tools.nsc.ScalaDoc",
Expand Down Expand Up @@ -193,5 +193,3 @@ trait ScalaModule extends JavaModule { outer =>
override def artifactId: T[String] = artifactName() + artifactSuffix()

}


6 changes: 6 additions & 0 deletions scalalib/test/resources/hello-world-flags/core/src/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.collection.immutable.SortedMap

object Main extends App {
def foo[F[_], A](fa: F[A]): String = fa.toString
foo { x: Int => x * 2 }
}
29 changes: 29 additions & 0 deletions scalalib/test/src/mill/scalalib/HelloWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ object HelloWorldTests extends TestSuite {
}
}

object HelloWorldFlags extends HelloBase{
object core extends ScalaModule {
def scalaVersion = "2.12.4"

def scalacOptions = super.scalacOptions() ++ Seq(
"-Ypartial-unification"
)
}
}

object HelloScalacheck extends HelloBase{
object foo extends ScalaModule {
def scalaVersion = "2.12.4"
Expand Down Expand Up @@ -523,6 +533,25 @@ object HelloWorldTests extends TestSuite {
}
}

'flags - {
// make sure flags are passed when compiling/running
'runMain - workspaceTest(
HelloWorldFlags,
resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldFlags.core.runMain("Main"))
assert(evalCount > 0)
}
// make sure flags are passed during ScalaDoc generation
'docJar - workspaceTest(
HelloWorldFlags,
resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-flags"
){ eval =>
val Right((_, evalCount)) = eval.apply(HelloWorldFlags.core.docJar)
assert(evalCount > 0)
}
}

'scalacheck - workspaceTest(
HelloScalacheck,
resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-scalacheck"
Expand Down

0 comments on commit e52b58a

Please sign in to comment.