-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
87 lines (71 loc) · 2.5 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
organization := "com.github.kmizu"
name := "pegex"
def Scala211 = "2.11.12"
def Scala212 = "2.12.8"
def Scala213 = "2.13.0"
scalaVersion := Scala213
crossScalaVersions := Seq(Scala211, Scala212, Scala213)
publishMavenStyle := true
val scaladocBranch = settingKey[String]("branch name for scaladoc -doc-source-url")
scaladocBranch := "master"
scalacOptions in (Compile, doc) ++= { Seq(
"-sourcepath", baseDirectory.value.getAbsolutePath,
"-doc-source-url", s"https://github.com/kmizu/pegex/tree/${scaladocBranch.value}€{FILE_PATH}.scala"
)}
testOptions in Test += Tests.Argument("-u", "target/scalatest-reports")
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-language:implicitConversions")
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
"junit" % "junit" % "4.13" % "test",
"org.scalatest" %% "scalatest" % "3.1.0" % "test"
)
fork in Test := true
initialCommands in console += {
Iterator().map("import "+).mkString("\n")
}
pomExtra := (
<url>https://github.com/kmizu/pegex</url>
<licenses>
<license>
<name>The MIT License</name>
<url>http://www.opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:kmizu/pegex.git</url>
<connection>scm:git:git@github.com:kmizu/pegex.git</connection>
</scm>
<developers>
<developer>
<id>kmizu</id>
<name>Kota Mizushima</name>
<url>https://github.com/kmizu</url>
</developer>
</developers>
)
publishTo := {
val v = version.value
val nexus = "https://oss.sonatype.org/"
if (v.endsWith("-SNAPSHOT"))
Some("snapshots" at nexus+"content/repositories/snapshots")
else
Some("releases" at nexus+"service/local/staging/deploy/maven2")
}
credentials ++= {
val sonatype = ("Sonatype Nexus Repository Manager", "oss.sonatype.org")
def loadMavenCredentials(file: java.io.File) : Seq[Credentials] = {
xml.XML.loadFile(file) \ "servers" \ "server" map (s => {
val host = (s \ "id").text
val realm = if (host == sonatype._2) sonatype._1 else "Unknown"
Credentials(realm, host, (s \ "username").text, (s \ "password").text)
})
}
val ivyCredentials = Path.userHome / ".ivy2" / ".credentials"
val mavenCredentials = Path.userHome / ".m2" / "settings.xml"
(ivyCredentials.asFile, mavenCredentials.asFile) match {
case (ivy, _) if ivy.canRead => Credentials(ivy) :: Nil
case (_, mvn) if mvn.canRead => loadMavenCredentials(mvn)
case _ => Nil
}
}