This repository has been archived by the owner on Apr 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ProjectPlugin.scala
103 lines (96 loc) · 3.48 KB
/
ProjectPlugin.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import de.heikoseeberger.sbtheader.{FileType, HeaderPlugin}
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import net.cakesolutions._
import sbt._
import sbt.Keys._
import sbtbuildinfo.BuildInfoPlugin.autoImport._
/**
* Common project settings.
*/
object ProjectPlugin extends AutoPlugin {
/** @see [[sbt.AutoPlugin]] */
override def requires: Plugins =
CakeBuildInfoPlugin &&
CakePlatformPlugin &&
CakeStandardsPlugin &&
CakePublishMavenPlugin &&
ReleaseNotesPlugin &&
HeaderPlugin
/** @see [[sbt.AutoPlugin]] */
override val buildSettings = Seq(
name := "$name;format="norm,word"$",
organization := "$organisation_domain$.$organisation$",
buildInfoPackage := "$organisation_domain$.$organisation$.$name;format="norm,word"$.build",
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion
)
)
/** @see [[sbt.AutoPlugin]] */
override val projectSettings = Seq(
// This avoids using resources to create a POM file. We don't need it.
publishArtifact in makePom := false,
autoAPIMappings in Global := true,
// scalastyle:off magic.number
// FIXME: The following should be tailored to match project requirements
startYear := Some(2017),
// scalastyle:on magic.number
// FIXME: The following should be tailored to match project requirements
licenses :=
Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
// FIXME: The following should be tailored to match project requirements
headerLicense := Some(
HeaderLicense.Custom(
"""|Copyright: 2017 https://github.com/cakesolutions/play-scala-template.g8/graphs
|License: http://www.apache.org/licenses/LICENSE-2.0
|""".stripMargin
)
),
headerMappings :=
headerMappings.value ++
Map(
FileType("sbt") -> HeaderCommentStyle.CppStyleLineComment,
HeaderFileType.java -> HeaderCommentStyle.CppStyleLineComment,
HeaderFileType.scala -> HeaderCommentStyle.CppStyleLineComment
)
) ++ headerSettings(IntegrationTest) ++ addCommandAlias(
"validate",
";reload plugins; sbt:scalafmt::test; scalafmt::test; reload return; " +
"sbt:scalafmt::test; scalafmt::test; test:scalafmt::test; " +
"it:scalafmt::test; " +
"scalastyle; test:scalastyle; it:scalastyle; " +
"headerCheck; test:headerCheck; it:headerCheck"
)
}
object ProjectPluginKeys {
// NOTE: anything in here is automatically visible in build.sbt
/**
* Implicitly add extra methods to in scope Projects
*
* @param p project that Play application setting should be applied to
*/
implicit final class PlayOps(val p: Project) extends AnyVal {
import play.sbt._
import PlayImport.PlayKeys
import play.twirl.sbt.Import.TwirlKeys
/**
* Enable Play Scala plugin, SBT style layout and a default set of
* settings.
*
* @return project with Play settings and configuration applied
*/
def enablePlay: Project =
p.enablePlugins(PlayScala)
// For consistency we prefer default SBT style layout
// https://www.playframework.com/documentation/2.5.x/Anatomy
.disablePlugins(PlayLayoutPlugin)
.settings(
// false positives in generated code
scalacOptions -= "-Ywarn-unused-import",
PlayKeys.playMonitoredFiles ++=
(sourceDirectories in (Compile, TwirlKeys.compileTemplates)).value
)
}
}