Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 96 lines (84 sloc) 4.183 kb
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
import sbt._
import sbt.Keys._
import com.github.retronym.SbtOneJar
import com.typesafe.sbteclipse.core.EclipsePlugin.EclipseKeys._
import com.typesafe.sbteclipse.core.EclipsePlugin._
import com.typesafe.sbtscalariform.ScalariformPlugin
import com.typesafe.sbtscalariform.ScalariformPlugin.ScalariformKeys
import scalariform.formatter.preferences._

object ScalariformBuild extends Build {

  lazy val commonSettings = Defaults.defaultSettings ++ ScalariformPlugin.defaultScalariformSettings ++ Seq(
    organization := "org.scalariform",
    version := "0.1.3-SNAPSHOT",
    scalaVersion := "2.9.2",
    crossScalaVersions := Seq("2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "2.9.2"),
    exportJars := true, // Needed for cli oneJar
    retrieveManaged := true,
    scalacOptions += "-deprecation",
    EclipseKeys.withSource := true,
    EclipseKeys.eclipseOutput := Some("bin"))

  lazy val subprojectSettings = commonSettings ++ Seq(
    ScalariformKeys.preferences <<= baseDirectory.apply(getScalariformPreferences))

  def getScalariformPreferences(dir: File) =
    PreferencesImporterExporter.loadPreferences((dir / ".." / "formatterPreferences.properties").getPath)

  lazy val root: Project = Project("root", file("."), settings = commonSettings ++ Seq(
    publish := (),
    publishLocal := ())) aggregate (scalariform, cli, misc)

  def getScalaTestDependency(scalaVersion: String) = scalaVersion match {
    case "2.8.0" "org.scalatest" %% "scalatest" % "1.3.1.RC2" % "test"
    case "2.10.0-M3" "org.scalatest" % "scalatest_2.10.0-M3" % "1.8-SNAPSHOT" % "test"
    case _ "org.scalatest" %% "scalatest" % "1.7.2" % "test"
  }

  lazy val scalariform: Project = Project("scalariform", file("scalariform"), settings =
    subprojectSettings ++ sbtbuildinfo.Plugin.buildInfoSettings ++ eclipseSettings ++
      Seq(
        libraryDependencies <<= (scalaVersion, libraryDependencies) { (sv, deps) deps :+ getScalaTestDependency(sv) },
        pomExtra := pomExtraXml,
        publishMavenStyle := true,
        publishArtifact in Test := false,
        pomIncludeRepository := { _ false },
        sbtbuildinfo.Plugin.buildInfoKeys := Seq[Scoped](version),
        sbtbuildinfo.Plugin.buildInfoPackage := "scalariform",
        sourceGenerators in Compile <+= sbtbuildinfo.Plugin.buildInfo,
        EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Managed,
        publishTo <<= isSnapshot(getPublishToRepo)))

  def getPublishToRepo(isSnapshot: Boolean) =
    if (isSnapshot) Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
    else Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")

  lazy val cli = Project("cli", file("cli"), settings = subprojectSettings ++ SbtOneJar.oneJarSettings ++
    Seq(
      libraryDependencies += "commons-io" % "commons-io" % "1.4",
      mainClass in (Compile, packageBin) := Some("scalariform.commandline.Main"),
      artifactName in SbtOneJar.oneJar := { (config: String, module: ModuleID, artifact: Artifact) "scalariform.jar" },
      publish := (),
      publishLocal := ())) dependsOn (scalariform)

  lazy val misc: Project = Project("misc", file("misc"), settings = subprojectSettings ++
    Seq(
      libraryDependencies ++= Seq(
        "commons-io" % "commons-io" % "1.4",
        "com.miglayout" % "miglayout" % "3.7.4"),
      publish := (),
      publishLocal := (),
      mainClass in (Compile, run) := Some("scalariform.gui.Main"))) dependsOn (scalariform, cli)

  def pomExtraXml =
    <inceptionYear>2010</inceptionYear>
    <url>http://github.com/mdr/scalariform</url>
    <licenses>
      <license>
        <name>MIT License</name>
        <url>http://www.opensource.org/licenses/mit-license.php</url>
        <distribution>repo</distribution>
      </license>
    </licenses>
    <scm>
      <url>git@github.com:mdr/scalariform.git</url>
      <connection>scm:git:git@github.com:mdr/scalariform</connection>
    </scm>
    <developers>
      <developer>
        <id>mdr</id>
        <name>Matt Russell</name>
        <url>https://github.com/mdr/</url>
      </developer>
    </developers>

}
Something went wrong with that request. Please try again.