summaryrefslogtreecommitdiff
path: root/contrib/playlib/src/mill/playlib/RouterModule.scala
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/playlib/src/mill/playlib/RouterModule.scala')
-rw-r--r--contrib/playlib/src/mill/playlib/RouterModule.scala40
1 files changed, 18 insertions, 22 deletions
diff --git a/contrib/playlib/src/mill/playlib/RouterModule.scala b/contrib/playlib/src/mill/playlib/RouterModule.scala
index ea2593aa..c02bd7e1 100644
--- a/contrib/playlib/src/mill/playlib/RouterModule.scala
+++ b/contrib/playlib/src/mill/playlib/RouterModule.scala
@@ -1,22 +1,16 @@
package mill
package playlib
-import coursier.{Cache, MavenRepository}
-import mill.api.Loose
+import coursier.MavenRepository
+import mill.eval.PathRef
import mill.playlib.api.RouteCompilerType
import mill.scalalib.Lib.resolveDependencies
import mill.scalalib._
import mill.scalalib.api._
-trait RouterModule extends mill.Module with ScalaModule {
+trait RouterModule extends ScalaModule with Version {
- def playVersion: T[String]
-
- override def generatedSources = T {
- super.generatedSources() ++ Seq(compileRouter().classes)
- }
-
- def routes = T.sources { millSourcePath / 'routes }
+ def routes: T[Seq[PathRef]] = T.sources { millSourcePath / 'routes }
private def routeFiles = T {
val paths = routes().flatMap(file => os.walk(file.path))
@@ -52,10 +46,10 @@ trait RouterModule extends mill.Module with ScalaModule {
*/
def generatorType: RouteCompilerType = RouteCompilerType.InjectedGenerator
- def routerClasspath: T[Loose.Agg[PathRef]] = T {
+ def routerClasspath: T[Agg[PathRef]] = T {
resolveDependencies(
Seq(
- Cache.ivy2Local,
+ coursier.LocalRepositories.ivy2Local,
MavenRepository("https://repo1.maven.org/maven2")
),
Lib.depToDependency(_, scalaVersion()),
@@ -65,7 +59,7 @@ trait RouterModule extends mill.Module with ScalaModule {
)
}
- final def compileRouter: T[CompilationResult] = T {
+ final def compileRouter: T[CompilationResult] = T.persistent {
T.ctx().log.debug(s"compiling play routes with ${playVersion()} worker")
RouteCompilerWorkerModule.routeCompilerWorker().compile(
toolsClasspath().map(_.path),
@@ -78,21 +72,15 @@ trait RouterModule extends mill.Module with ScalaModule {
T.ctx().dest)
}
- private def playMinorVersion: T[String] = T {
- playVersion().split("\\.").take(2).mkString("", ".", ".0")
- }
-
private def playRouteCompilerWorkerClasspath = T {
- val workerKey = "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_" + playMinorVersion().replace(".",
- "_")
- T.ctx.log.debug(s"classpath worker key: $workerKey")
+ val workerKey = "MILL_CONTRIB_PLAYLIB_ROUTECOMPILER_WORKER_" + playMinorVersion().replace(".", "_")
//While the following seems to work (tests pass), I am not completely
//confident that the strings I used for artifact and resolveFilter are
//actually correct
mill.modules.Util.millProjectModule(
workerKey,
- s"mill-contrib-playlib-worker-${playVersion()}",
+ s"mill-contrib-playlib-worker-${playMinorVersion()}",
repositories,
resolveFilter = _.toString.contains("mill-contrib-playlib-worker")
)
@@ -101,4 +89,12 @@ trait RouterModule extends mill.Module with ScalaModule {
private def toolsClasspath = T {
playRouteCompilerWorkerClasspath() ++ routerClasspath()
}
-} \ No newline at end of file
+
+ def routerClasses = T{
+ Seq(compileRouter().classes)
+ }
+
+ override def generatedSources = T {
+ super.generatedSources() ++ routerClasses()
+ }
+}