Skip to content

Commit 95c5a7a

Browse files
committed
First cut at abstracting the builds for scala-modules.
Don't repeat yourself = good, right? So, here we just list the common settings for all scala modules, along with some convenient hooks for our automated builds.
0 parents  commit 95c5a7a

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

build.sbt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name := "scala-module-plugin"
2+
3+
organization := "org.scala-lang.modules"
4+
5+
sbtPlugin := true
6+
7+
version := "ZOMG"

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.0
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import sbt._
2+
import Keys._
3+
4+
object ScalaModulePlugin extends Plugin {
5+
6+
val includeTestDependencies = settingKey[Boolean]("Include testing dependencies when building. Used to break cycles when doing full builds.")
7+
val partestVersion = settingKey[String]("the partest version we want to use.")
8+
9+
def scalaModuleSettings: Seq[Setting[_]] =
10+
Seq(
11+
partestVersion := "1.0-RC5",
12+
organization := "org.scala-lang.modules",
13+
// don't use for doc scope, scaladoc warnings are not to be reckoned with
14+
scalacOptions in compile ++= Seq("-optimize", "-Xfatal-warnings", "-feature", "-deprecation", "-unchecked", "-Xlint"),
15+
// Generate $name.properties to store our version as well as the scala version used to build
16+
resourceGenerators in Compile <+= Def.task {
17+
val props = new java.util.Properties
18+
props.put("version.number", version.value)
19+
props.put("scala.version.number", scalaVersion.value)
20+
props.put("scala.binary.version.number", scalaBinaryVersion.value)
21+
val file = (resourceManaged in Compile).value / s"${name.value}.properties"
22+
IO.write(props, null, file)
23+
Seq(file)
24+
},
25+
mappings in (Compile, packageBin) += {
26+
(baseDirectory.value / s"${name.value}.properties") -> s"${name.value}.properties"
27+
},
28+
// maven publishing
29+
publishTo := {
30+
val nexus = "https://oss.sonatype.org/"
31+
if (version.value.trim.endsWith("SNAPSHOT"))
32+
Some("snapshots" at nexus + "content/repositories/snapshots")
33+
else
34+
Some("releases" at nexus + "service/local/staging/deploy/maven2")
35+
},
36+
publishMavenStyle := true,
37+
publishArtifact in Test := false,
38+
pomIncludeRepository := { _ => false },
39+
pomExtra := (
40+
<url>http://www.scala-lang.org/</url>
41+
<inceptionYear>2002</inceptionYear>
42+
<licenses>
43+
<license>
44+
<distribution>repo</distribution>
45+
<name>BSD 3-Clause</name>
46+
<url>https://github.com/scala/{name.value}/blob/master/LICENSE.md</url>
47+
</license>
48+
</licenses>
49+
<scm>
50+
<connection>scm:git:git://github.com/scala/{name.value}.git</connection>
51+
<url>https://github.com/scala/{name.value}</url>
52+
</scm>
53+
<issueManagement>
54+
<system>JIRA</system>
55+
<url>https://issues.scala-lang.org/</url>
56+
</issueManagement>
57+
<developers>
58+
<developer>
59+
<id>epfl</id>
60+
<name>EPFL</name>
61+
</developer>
62+
<developer>
63+
<id>Typesafe</id>
64+
<name>Typesafe, Inc.</name>
65+
</developer>
66+
</developers>
67+
),
68+
// default value must be set here
69+
includeTestDependencies := true,
70+
// the actual partest the interface calls into -- must be binary version close enough to ours
71+
// so that it can link to the compiler/lib we're using (testing)
72+
libraryDependencies ++= (
73+
if (includeTestDependencies.value)
74+
Seq("org.scala-lang.modules" %% "scala-partest" % partestVersion.value % "test",
75+
"org.scala-lang.modules" %% "scala-partest-interface" % "0.2" % "test")
76+
else Seq.empty
77+
),
78+
// necessary for partest -- see comments in its build.sbt
79+
conflictWarning ~= { _.copy(failOnConflict = false) },
80+
fork in Test := true,
81+
javaOptions in Test += "-Xmx1G",
82+
testFrameworks += new TestFramework("scala.tools.partest.Framework"),
83+
definedTests in Test += (
84+
new sbt.TestDefinition(
85+
"partest",
86+
// marker fingerprint since there are no test classes
87+
// to be discovered by sbt:
88+
new sbt.testing.AnnotatedFingerprint {
89+
def isModule = true
90+
def annotationName = "partest"
91+
}, true, Array())
92+
)
93+
94+
// TODO: mima
95+
// import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
96+
// import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact
97+
// previousArtifact := Some(organization.value %% name.value % binaryReferenceVersion.value)
98+
)
99+
100+
}

0 commit comments

Comments
 (0)