Skip to content

Commit 60c38ed

Browse files
committed
Merge pull request scala#2 from adriaanm/master
Consolidate actual Scala module builds.
2 parents 8bde32f + d176066 commit 60c38ed

File tree

4 files changed

+123
-99
lines changed

4 files changed

+123
-99
lines changed

build.sbt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
git.baseVersion := "1.0"
1+
import bintray.Keys._
2+
3+
git.baseVersion := "1.0.0"
24

35
versionWithGit
46

5-
name := "scala-module-plugin"
7+
name := "scala-module-plugin"
8+
9+
organization := "org.scala-lang.modules"
10+
11+
sbtPlugin := true
612

7-
organization := "org.scala-lang.modules"
13+
// sbtVersion in Global := "0.13.1"
814

9-
sbtPlugin := true
15+
// scalaVersion in Global := "2.10.3"
1016

11-
publishTo := Some(Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns))
17+
// publishTo := Some(if (version.value.trim.endsWith("SNAPSHOT")) Classpaths.sbtPluginSnapshots else Classpaths.sbtPluginReleases)
1218

1319
publishMavenStyle := false
20+
21+
bintrayPublishSettings
22+
23+
resolvers += Classpaths.sbtPluginReleases
24+
25+
licenses := Seq("BSD" -> url("http://opensource.org/licenses/BSD"))
26+
27+
repository in bintray := "sbt-plugins"
28+
29+
bintrayOrganization in bintray := None
30+
31+
// this plugin depends on the sbt-osgi plugin -- 2-for-1!
32+
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.0
1+
sbt.version=0.13.1

project/plugins.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
2+
3+
// incompatible with sbt-gpg (https://github.com/softprops/bintray-sbt/pull/10)
4+
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1.1")
Lines changed: 95 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
11
import sbt._
22
import Keys._
3+
import com.typesafe.sbt.osgi.{OsgiKeys, SbtOsgi}
34

45
object ScalaModulePlugin extends Plugin {
6+
val snapshotScalaBinaryVersion = settingKey[String]("The Scala binary version to use when building against Scala SNAPSHOT.")
7+
val repoName = settingKey[String]("The name of the repository under github.com/scala/.")
58

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, 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-interface" % "0.2" % "test",
75-
"org.scala-lang.modules" %% "scala-partest" % partestVersion.value % "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-
)
9+
def deriveBinaryVersion(sv: String, snapshotScalaBinaryVersion: String) = sv match {
10+
case snap_211 if snap_211.startsWith("2.11") &&
11+
snap_211.contains("-SNAPSHOT") => snapshotScalaBinaryVersion
12+
case sv => sbt.CrossVersion.binaryScalaVersion(sv)
13+
}
9914

15+
// a setting-transform to turn the regular version into something osgi can deal with
16+
val osgiVersion = version(_.replace('-', '.'))
17+
18+
lazy val scalaModuleSettings = Seq(
19+
repoName := name.value,
20+
21+
organization := "org.scala-lang.modules",
22+
23+
scalaBinaryVersion := deriveBinaryVersion(scalaVersion.value, snapshotScalaBinaryVersion.value),
24+
25+
// so we don't have to wait for sonatype to synch to maven central when deploying a new module
26+
resolvers += Resolver.sonatypeRepo("releases"),
27+
28+
// to allow compiling against snapshot versions of Scala
29+
resolvers += Resolver.sonatypeRepo("snapshots"),
30+
31+
// don't use for doc scope, scaladoc warnings are not to be reckoned with
32+
// TODO: turn on for nightlies, but don't enable for PR validation... "-Xfatal-warnings"
33+
scalacOptions in compile ++= Seq("-optimize", "-feature", "-deprecation", "-unchecked", "-Xlint"),
34+
35+
// Generate $name.properties to store our version as well as the scala version used to build
36+
resourceGenerators in Compile <+= Def.task {
37+
val props = new java.util.Properties
38+
props.put("version.number", version.value)
39+
props.put("scala.version.number", scalaVersion.value)
40+
props.put("scala.binary.version.number", scalaBinaryVersion.value)
41+
val file = (resourceManaged in Compile).value / s"${name.value}.properties"
42+
IO.write(props, null, file)
43+
Seq(file)
44+
},
45+
46+
mappings in (Compile, packageBin) += {
47+
(baseDirectory.value / s"${name.value}.properties") -> s"${name.value}.properties"
48+
},
49+
50+
publishArtifact in Test := false,
51+
52+
// maven publishing
53+
publishTo := Some(
54+
if (version.value.trim.endsWith("SNAPSHOT")) Resolver.sonatypeRepo("snapshots")
55+
else Opts.resolver.sonatypeStaging
56+
),
57+
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
58+
59+
publishMavenStyle := true,
60+
scmInfo := Some(ScmInfo(url(s"https://github.com/scala/${repoName.value}"),s"scm:git:git://github.com/scala/${repoName.value}.git")),
61+
homepage := Some(url("http://www.scala-lang.org/")),
62+
organizationHomepage := Some(url("http://www.scala-lang.org/")),
63+
licenses := Seq("BSD 3-clause" -> url("http://opensource.org/licenses/BSD-3-Clause")),
64+
startYear := Some(2002),
65+
pomIncludeRepository := { _ => false },
66+
pomExtra := (
67+
<issueManagement>
68+
<system>JIRA</system>
69+
<url>https://issues.scala-lang.org/</url>
70+
</issueManagement>
71+
<developers>
72+
<developer>
73+
<id>epfl</id>
74+
<name>EPFL</name>
75+
</developer>
76+
<developer>
77+
<id>Typesafe</id>
78+
<name>Typesafe, Inc.</name>
79+
</developer>
80+
</developers>
81+
),
82+
83+
OsgiKeys.bundleSymbolicName := s"${organization.value}.${name.value}",
84+
OsgiKeys.bundleVersion := osgiVersion.value,
85+
86+
// Sources should also have a nice MANIFEST file
87+
packageOptions in packageSrc := Seq(Package.ManifestAttributes(
88+
("Bundle-SymbolicName", s"${organization.value}.${name.value}.source"),
89+
("Bundle-Name", s"${name.value} sources"),
90+
("Bundle-Version", osgiVersion.value),
91+
("Eclipse-SourceBundle", s"""${organization.value}.${name.value};version="${osgiVersion.value}";roots:="."""")
92+
))
93+
94+
95+
// TODO: mima
96+
// resolvers += Classpaths.typesafeResolver
97+
// addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.5")
98+
// import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
99+
// import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact
100+
// previousArtifact := Some(organization.value %% name.value % binaryReferenceVersion.value)
101+
)
100102
}

0 commit comments

Comments
 (0)