0

If you want to load module sources and/or javadocs you write following sbt:

lazy val joda_timeV = "1.2.3" 
lazy val scalatagsV = "1.2.3" 
lazy val upickleV = "1.2.4" 
lazy val autowireV = "1.2.5" 
lazy val scalarxV = "1.2.6" 


libraryDependencies ++= Seq( 
  "joda-time" % "joda-time" % joda_timeV withJavadoc(), 
  "com.lihaoyi" %%% "scalatags" % scalatagsV withSources() withJavadoc(),   
  "com.lihaoyi" %% "upickle" % upickleV withSources() withJavadoc(),
  "com.lihaoyi" %%% "autowire" % autowireV withJavadoc(),
  "com.lihaoyi" %%% "scalarx" % scalarxV  withSources(),
  "org.scalatestplus.play" %% "scalatestplus-play" % scalatestplus_playV % "test" withSources() withJavadoc() 
),

In mill you say

override def ivyDeps = Agg(
    ivy"joda-time:joda-time:${joda_timeV}", 
    ivy"com.lihaoyi:::scalatags:${scalatagsV}", 
    ivy"com.lihaoyi::upickle:${upickleV}",
    ivy"com.lihaoyi:::autowire:${autowireV}",
    ivy"com.lihaoyi:::scalarx:${scalarxV}"
)

but how can you add withJavadoc() or withSources() or withSources() withJavadoc() in to mill build.sc? There is function .withConfiguration(String) but no scaladoc how to use it.

Is it possible to define that a module is available only in test (like org.scalatestplus.play in the previous code) or should I create separate ivyDeps for testing module?

user4955663
  • 1,039
  • 2
  • 13
  • 21
  • Or is it so that ivy"..." always tries to load sources + javadoc? Ammonite import $ivy seems to do that. In Ammonite user can see what is downloaded. In mill you see only that some artifacts where downloaded but don't see what were they. – user4955663 Sep 14 '21 at 23:47
  • What should mill do with these extra artifacts? You probably want to use these in your IDE, in which case mill provides direct IDEA support (and already fetches the sources for you) and can also act as BSP server (directly or with Bloop plugin) and also handles sources I think. – Tobias Roeser Sep 15 '21 at 07:47
  • Yes I need sources and javadocs for IDE (Idea). You said "mill provides direct IDEA support (and already fetches the sources for you)". So it seems that this is automatically taken care in mill. Sounds good! – user4955663 Sep 15 '21 at 15:21

1 Answers1

0

Regarding your first question, I assume, your are interested in good IDE support, e.g. completion and jump-to the sources of your dependencies.

Mill already supports IDE integration. It comes with a project generator for IntelliJ IDEA (mill mill.scalalib.GenIdea/idea), which automatically downloads the sources for you. Alternatively, you can use the new BSP Support (Build Server Protocol) which should in combination with the Metals Language Server (https://scalameta.org/metals/) provide a nice editing experience in various IDEs and Editors. Unfortunately, at the time of this writing, Mills built-in BSP server isn't as robust as its IDEA generator, but there is even another alternative, the Bloop contrib module. All these methods should provide decent code navigation through dependencies and completion.

And to your second question:

Is it possible to define that a module is available only in test (like org.scalatestplus.play in the previous code) or should I create separate ivyDeps for testing module?

Test dependencies are declared it the test modules (which are technically regular modules too).

// build.sc
// ...

object yourplaymodule extends PlayModule {
  override def ivyDeps = Agg(
    ivy"joda-time:joda-time:${joda_timeV}", 
    ivy"com.lihaoyi:::scalatags:${scalatagsV}", 
    ivy"com.lihaoyi::upickle:${upickleV}",
    ivy"com.lihaoyi:::autowire:${autowireV}",
    ivy"com.lihaoyi:::scalarx:${scalarxV}"
  )
  // ...
  object test extends PlayTests {
    override def ivyDeps = Agg(
      ivy"org.scalatestplus.play::scalatestplus-play:${scalatestplus_playV}"
    )
  }
}

Edit 2021-09-16: Added the answer to the first question.

Tobias Roeser
  • 431
  • 2
  • 8
  • It seems to be possible to also define "test jars". According to mill docs "Configuring Mill/Compilation & Execution Flags" section: To select the test-jars from a dependency use the following syntax: ivy"org.apache.spark::spark-sql:2.4.0;classifier=tests This "classifier=tests" is then probably needed in the test module def ivyDeps? – user4955663 Oct 07 '21 at 20:19