This repository has been archived by the owner on Sep 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
build.sbt
136 lines (130 loc) · 4.2 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
name := "org.scala-refactoring.library"
version := "0.14.0-SNAPSHOT"
scalaVersion := "2.12.3"
moduleName := name.value
organization := "org.scala-refactoring"
crossScalaVersions := Seq("2.10.6", "2.11.8", scalaVersion.value)
crossVersion := CrossVersion.full
fork := true
parallelExecution in Test := false
autoAPIMappings := true
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"com.novocode" % "junit-interface" % "0.10" % "test"
)
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
)
case _ => Nil
})
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq(
"-deprecation:false",
"-encoding", "UTF-8",
"-feature",
"-language:_",
"-unchecked",
"-Xlint",
"-Xfuture",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-unused-import",
"-Ywarn-unused"
)
case Some((2, 12)) => Seq(
"-deprecation:false",
"-encoding", "UTF-8",
"-feature",
"-language:_",
"-unchecked",
"-Xlint",
"-Xfuture",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-unused-import",
"-Ywarn-unused:-patvars,-params,-implicits,_"
)
case _ => Seq()
})
Seq(Compile, Test).flatMap { config =>
inConfig(config) {
unmanagedSourceDirectories += {
val dir = scalaSource.value
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
file(s"${dir.getPath}-$major.$minor")
}
}
}
publishMavenStyle := true
useGpg := true
publishTo := {
val nexus = "https://oss.sonatype.org"
if (isSnapshot.value)
Some("snapshots" at s"$nexus/content/repositories/snapshots")
else
Some("releases" at s"$nexus/service/local/staging/deploy/maven2")
}
publishArtifact in Test := false
pomExtra := (
<url>http://scala-refactoring.org</url>
<licenses>
<license>
<name>Scala License</name>
<url>http://www.scala-lang.org/node/146</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/scala-ide/scala-refactoring.git</connection>
<developerConnection>scm:git:[email protected]:scala-ide/scala-refactoring.git</developerConnection>
<tag>master</tag>
<url>https://github.com/scala-ide/scala-refactoring</url>
</scm>
<developers>
<developer>
<id>misto</id>
<name>Mirko Stocker</name>
<email>[email protected]</email>
</developer>
</developers>)
credentials ++= {
val config = Path.userHome / ".m2" / "credentials"
if (config.exists) Seq(Credentials(config))
else {
for {
username <- sys.env.get("SONATYPE_USERNAME")
password <- sys.env.get("SONATYPE_PASSWORD")
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)
}.toSeq
}
// sbt doesn't automatically load the content of the MANIFST.MF file, therefore
// we have to do it here by ourselves. Furthermore, the version format in the
// MANIFEST.MF is `version.qualifier`, which means that we have to replace
// `version` by the actual version and `qualifier` with a unique identifier
// otherwise OSGi can't find out which nightly build is newest and therefore
// not all caches are updated with the correct version of a nightly.
packageOptions in Compile in packageBin += {
val m = Using.fileInputStream(new java.io.File("MANIFEST.MF.prototype")) { in =>
val manifest = new java.util.jar.Manifest(in)
val attr = manifest.getMainAttributes
val key = "Bundle-Version"
val versionSuffix = scalaBinaryVersion.value.replace('.', '_')
// get the version but get rid of "-SNAPSHOT" suffix if it exists
val v = {
val v = version.value
val i = v.lastIndexOf('-')
if (i > 0)
v.substring(0, i)
else
v
}
val date = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(new java.util.Date)
val sha = "git rev-parse --short HEAD".!!.trim
attr.putValue(key, attr.getValue(key).replace("version.qualifier", s"$v.$versionSuffix-$date-$sha"))
manifest
}
Package.JarManifest(m)
}