1 import ammonite.ops._ |
1 import ammonite.ops._ |
2 import mill._ |
2 import mill._ |
|
3 import mill.api.Loose |
3 import mill.define.{Input, Sources, Target} |
4 import mill.define.{Input, Sources, Target} |
4 import mill.scalajslib._ |
5 import mill.scalajslib._ |
5 import mill.scalalib._ |
6 import mill.scalalib._ |
6 import mill.scalalib.publish._ |
7 import mill.scalalib.publish._ |
7 import mill.util.Loose |
8 |
8 |
9 val appVersion = "20.12-SNAPSHOT" |
9 val appVersion = "19.03" |
10 |
10 |
11 val scalaJsVer = "0.6.33" |
11 val scalaJsVer = "0.6.25" |
12 val scalaVer = "2.12.12" |
12 val scalaVer = "2.12.7" |
13 val akkaVer = "2.6.10" |
13 val akkaVer = "2.4.20" |
14 val akkaHttp = "10.2.1" |
14 |
15 |
15 trait Common extends ScalaModule with PublishModule { |
16 trait Common extends ScalaModule with PublishModule { |
16 val scalaVersion = scalaVer |
17 val scalaVersion = scalaVer |
17 |
18 |
18 def publishVersion: Target[String] = appVersion |
19 def publishVersion: Target[String] = appVersion |
19 |
20 |
20 def pomSettings = PomSettings( |
21 def pomSettings = PomSettings( |
21 description = "Content management system for SQWL", |
22 description = "Content management system for SQWL", |
22 organization = "net.tz", |
23 organization = "cz.functionals", |
23 url = "http://kvalitapracovnihozivota.vubp.cz", |
24 url = "http://kvalitapracovnihozivota.vubp.cz", |
24 licenses = Seq(License.`Apache-2.0`), |
25 licenses = Seq(License.`Apache-2.0`), |
25 versionControl = VersionControl(developerConnection = Some( |
26 versionControl = VersionControl(developerConnection = Some( |
26 "ssh://hg@bitbucket.org/tzeman/sqwl-cms")), |
27 "ssh://tzeman@hg.functionals.cz/repos/public/sqwl-cms")), |
27 developers = Seq( |
28 developers = Seq( |
28 Developer("tzeman", "Tomas Zeman", "") |
29 Developer("tzeman", "Tomas Zeman", "") |
29 ) |
30 ) |
30 ) |
31 ) |
31 |
32 |
32 override def artifactName = T{ |
33 override def artifactName: Target[String] = T{ |
33 super.artifactName.map(_.flatMap(c => |
34 super.artifactName().flatMap(c => |
34 if (c.isUpper) Seq('-', c.toLower) else Seq(c) )) |
35 if (c.isUpper) Seq('-', c.toLower) else Seq(c)).mkString |
35 } |
36 } |
36 |
37 |
37 override def scalacOptions = T{Seq( |
38 override def scalacOptions = T{Seq( |
38 "-deprecation", // Emit warning and location for usages of deprecated APIs. |
39 "-deprecation", // Emit warning and location for usages of deprecated APIs. |
39 "-encoding", "utf-8", // Specify character encoding used by source files. |
40 "-encoding", "utf-8", // Specify character encoding used by source files. |
44 "-language:reflectiveCalls", |
45 "-language:reflectiveCalls", |
45 "-language:postfixOps", |
46 "-language:postfixOps", |
46 "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
47 "-unchecked", // Enable additional warnings where generated code depends on assumptions. |
47 "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
48 "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. |
48 "-Xfuture", // Turn on future language features. |
49 "-Xfuture", // Turn on future language features. |
49 "-target:jvm-1.8", |
50 "-target:jvm-1.8" |
50 )} |
51 )} |
51 |
52 |
52 def hgId: Input[String] = T.input { |
53 def hgId: Input[String] = T.input { |
53 os.proc("hg", "id", "-i").call().out.string.trim |
54 os.proc("hg", "id", "-i").call().out.trim |
54 } |
55 } |
55 |
56 |
56 def hgNum: Input[String] = T.input { |
57 def hgNum: Input[String] = T.input { |
57 os.proc("hg", "id", "-n").call().out.string.trim |
58 os.proc("hg", "id", "-n").call().out.trim |
58 } |
59 } |
59 |
60 |
60 def hgTag: Input[Option[String]] = T.input { |
61 def hgTag: Input[Option[String]] = T.input { |
61 os.proc("hg", "id", "-t").call().out.string.trim.split(' ').headOption |
62 os.proc("hg", "id", "-t").call().out.trim.split(' ').headOption |
62 } |
63 } |
63 |
64 |
64 } |
65 } |
65 |
66 |
66 trait Versions { |
67 trait Versions { |
71 } |
72 } |
72 |
73 |
73 object base extends Common with Versions { |
74 object base extends Common with Versions { |
74 override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] = |
75 override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] = |
75 super.scalacPluginIvyDeps() ++ Agg( |
76 super.scalacPluginIvyDeps() ++ Agg( |
76 ivy"org.scalamacros:::paradise:2.1.0" |
77 ivy"org.scalamacros:::paradise:2.1.1" |
77 ) |
78 ) |
78 |
79 |
79 override def ivyDeps = Agg( |
80 override def ivyDeps = Agg( |
80 ivy"com.wacai::config-annotation:0.3.6", |
81 ivy"com.wacai::config-annotation:0.3.6", |
81 ivy"de.heikoseeberger::akka-http-json4s:1.22.0", |
82 ivy"com.typesafe.akka::akka-http:$akkaHttp", |
82 ivy"com.typesafe.akka::akka-slf4j:$akkaVer", |
83 ivy"com.typesafe.akka::akka-slf4j:$akkaVer", |
|
84 ivy"com.typesafe.akka::akka-stream:$akkaVer", |
83 ivy"org.json4s::json4s-native:3.6.2", |
85 ivy"org.json4s::json4s-native:3.6.2", |
84 ivy"ch.qos.logback:logback-classic:1.2.3", |
86 ivy"ch.qos.logback:logback-classic:1.2.3", |
85 ivy"com.lihaoyi::scalatags:0.6.7", |
87 ivy"com.lihaoyi::scalatags:0.6.7", |
86 ivy"org.webjars:bootstrap:$bootstrap", |
88 ivy"org.webjars:bootstrap:$bootstrap", |
87 ivy"org.webjars:font-awesome:$fontAwesome", |
89 ivy"org.webjars:font-awesome:$fontAwesome", |
120 def contentSources: Sources |
122 def contentSources: Sources |
121 |
123 |
122 override def generatedSources: Target[Seq[PathRef]] = T{ |
124 override def generatedSources: Target[Seq[PathRef]] = T{ |
123 val dir = T.ctx().dest |
125 val dir = T.ctx().dest |
124 val src = contentSources() map(_.path) |
126 val src = contentSources() map(_.path) |
125 val ids = src flatMap(ls! _ filter(_.name endsWith ".scalatex") map { p => |
127 val ids = src flatMap(ls! _ filter(_.ext endsWith "scalatex") map { p => |
126 val id = p.name replaceAllLiterally (".scalatex", "") |
128 val id = p.last replaceAllLiterally (".scalatex", "") |
127 val aid = s"article-$id" |
129 val aid = s"article-$id" |
128 write(dir / s"$id.scala", |
130 write(dir / s"$id.scala", |
129 s""" |
131 s""" |
130 | package sqwl.cms |
132 | package sqwl.cms |
131 | import scalatags.Text.all._ |
133 | import scalatags.Text.all._ |
194 object production extends Content { |
196 object production extends Content { |
195 def contentSources: Sources = |
197 def contentSources: Sources = |
196 T.sources{ millSourcePath / up / 'production / 'content } |
198 T.sources{ millSourcePath / up / 'production / 'content } |
197 |
199 |
198 def hgProdId: Input[String] = T.input { |
200 def hgProdId: Input[String] = T.input { |
199 os.proc("hg", "id", "-i", "--cwd", "production").call().out.string.trim |
201 os.proc("hg", "id", "-i", "--cwd", "production").call().out.trim |
200 } |
202 } |
201 |
203 |
202 override def assemblyName: Target[String] = T{ |
204 override def assemblyName: Target[String] = T{ |
203 s"${super.assemblyName()}-${hgProdId()}" |
205 s"${super.assemblyName()}-${hgProdId()}" |
204 } |
206 } |