This repository has been archived by the owner on Jul 7, 2019. It is now read-only.
forked from softprops/pj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
140 lines (130 loc) · 3.98 KB
/
build.sbt
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import sbtrelease.ReleaseStateTransformations._
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)
val Scala212 = "2.12.8"
val updateLaunchconfig = TaskKey[File]("updateLaunchconfig")
val tagName = Def.setting{
s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}"
}
val tagOrHash = Def.setting{
if(isSnapshot.value) gitHash() else tagName.value
}
def gitHash(): String =
sys.process.Process("git rev-parse HEAD").lineStream_!.head
val unusedWarnings = (
"-Ywarn-unused" ::
"-Ywarn-unused-import" ::
Nil
)
val commonSettings = Seq(
scalaVersion := Scala212,
scalacOptions ++= (
"-deprecation" ::
"-unchecked" ::
"-Xlint" ::
"-Xfuture" ::
"-language:existentials" ::
"-language:higherKinds" ::
"-language:implicitConversions" ::
"-Yno-adapted-args" ::
Nil
),
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)){
case Some((2, v)) if v >= 11 => unusedWarnings
}.toList.flatten,
scalacOptions in (Compile, doc) ++= {
val tag = tagOrHash.value
Seq(
"-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url", s"https://github.com/xuwei-k/pj/tree/${tag}€{FILE_PATH}.scala"
)
},
publishMavenStyle := true,
publishArtifact in Test := false,
organization := "com.github.xuwei-k",
licenses := Seq("MIT" -> url(s"https://github.com/xuwei-k/pj/blob/${tagOrHash.value}/LICENSE")),
homepage := some(url("https://github.com/xuwei-k/pj/#readme")),
crossScalaVersions := Seq("2.10.7", "2.11.12", Scala212),
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
releaseStepTask(updateLaunchconfig),
commitReleaseVersion,
tagRelease,
releaseStepCommand("publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
pomExtra := (
<scm>
<url>[email protected]:xuwei-k/pj.git</url>
<connection>scm:git:[email protected]:xuwei-k/pj.git</connection>
</scm>
<developers>
<developer>
<id>xuwei-k</id>
<name>Kenji Yoshida</name>
<url>https://github.com/xuwei-k</url>
</developer>
<developer>
<id>softprops</id>
<name>Doug Tangren</name>
<url>https://github.com/softprops</url>
</developer>
</developers>)
) ++ Seq(Compile, Test).flatMap(c =>
scalacOptions in (c, console) --= unusedWarnings
)
lazy val root = Project(
"root", file(".")
).settings(
commonSettings,
updateLaunchconfig := {
val mainClassName = (discoveredMainClasses in Compile in app).value match {
case Seq(m) => m
case zeroOrMulti => sys.error(s"could not found main class. $zeroOrMulti")
}
val launchconfig = s"""[app]
version: ${(version in app).value}
org: ${(organization in app).value}
name: ${(normalizedName in app).value}
class: ${mainClassName}
[scala]
version: ${Scala212}
[repositories]
local
maven-central
"""
val f = (baseDirectory in ThisBuild).value / "src/main/conscript/pj/launchconfig"
IO.write(f, launchconfig)
f
},
publishArtifact := false,
publish := { },
publishLocal := { },
PgpKeys.publishSigned := { },
PgpKeys.publishLocalSigned := { }
).aggregate(pj, app)
lazy val pj = Project("pj", file("pj")).settings(
commonSettings,
name := "pj",
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-core" % "2.8.9",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoObject := "PjBuildInfo",
buildInfoPackage := "pj",
description := "A pretty printer for json"
).enablePlugins(BuildInfoPlugin)
lazy val app = Project("app", file("app")).settings(
commonSettings,
name := "pj-app",
description := "A conscript interface for prettifying json strings and streams"
).dependsOn(pj).enablePlugins(ConscriptPlugin)