11import sbt .Keys ._
22import sbt ._
33import complete .DefaultParsers ._
4- import java .io .{ File , RandomAccessFile }
4+ import java .io .File
55import java .nio .channels .FileLock
6- import java .nio .file .{ Files , FileSystemException }
6+ import java .nio .file ._
77import java .util .Calendar
88
99import scala .reflect .io .Path
@@ -12,14 +12,14 @@ import xerial.sbt.Pack._
1212
1313import sbt .Package .ManifestAttributes
1414
15- import com .typesafe .sbteclipse .plugin .EclipsePlugin ._
16-
1715import dotty .tools .sbtplugin .DottyPlugin .autoImport ._
1816import dotty .tools .sbtplugin .DottyIDEPlugin .{ prepareCommand , runProcess }
1917import dotty .tools .sbtplugin .DottyIDEPlugin .autoImport ._
2018import org .scalajs .sbtplugin .ScalaJSPlugin
2119import org .scalajs .sbtplugin .ScalaJSPlugin .autoImport ._
2220
21+ import com .typesafe .sbt .pgp .PgpKeys
22+
2323import pl .project13 .scala .sbt .JmhPlugin
2424import JmhPlugin .JmhKeys .Jmh
2525
@@ -96,27 +96,14 @@ object Build {
9696
9797 lazy val bootstrapFromPublishedJars = settingKey[Boolean ](" If true, bootstrap dotty from published non-bootstrapped dotty" )
9898
99- // Used in build.sbt
100- lazy val thisBuildSettings = Def .settings(
101- // Change this to true if you want to bootstrap using a published non-bootstrapped compiler
102- bootstrapFromPublishedJars := false ,
103-
104- // Override `runCode` from sbt-dotty to use the language-server and
105- // vscode extension from the source repository of dotty instead of a
106- // published version.
107- runCode := (run in `dotty-language-server`).toTask(" " ).value
108- )
109-
11099 // Only available in vscode-dotty
111100 lazy val unpublish = taskKey[Unit ](" Unpublish a package" )
112101
113-
114-
115- lazy val commonSettings = publishSettings ++ Seq (
102+ // Settings shared by the build (scoped in ThisBuild). Used in build.sbt
103+ lazy val thisBuildSettings = Def .settings(
116104 organization := dottyOrganization,
117105 organizationName := " LAMP/EPFL" ,
118106 organizationHomepage := Some (url(" http://lamp.epfl.ch" )),
119- homepage := Some (url(dottyGithubUrl)),
120107
121108 scalacOptions ++= Seq (
122109 " -feature" ,
@@ -129,6 +116,63 @@ object Build {
129116
130117 javacOptions ++= Seq (" -Xlint:unchecked" , " -Xlint:deprecation" ),
131118
119+ // Change this to true if you want to bootstrap using a published non-bootstrapped compiler
120+ bootstrapFromPublishedJars := false ,
121+
122+ // Override `runCode` from sbt-dotty to use the language-server and
123+ // vscode extension from the source repository of dotty instead of a
124+ // published version.
125+ runCode := (run in `dotty-language-server`).toTask(" " ).value
126+ )
127+
128+ // Settings shared globally (scoped in Global). Used in build.sbt
129+ lazy val globalSettings = Def .settings(
130+ // Change this to true if you want to bootstrap using a published non-bootstrapped compiler
131+ bootstrapFromPublishedJars := false ,
132+
133+ // Override `runCode` from sbt-dotty to use the language-server and
134+ // vscode extension from the source repository of dotty instead of a
135+ // published version.
136+ runCode := (run in `dotty-language-server`).toTask(" " ).value,
137+
138+ onLoad := (onLoad in Global ).value andThen { state =>
139+ def exists (submodule : String ) = {
140+ val path = Paths .get(submodule)
141+ Files .exists(path) && {
142+ val fileStream = Files .list(path)
143+ val nonEmpty = fileStream.iterator().hasNext()
144+ fileStream.close()
145+ nonEmpty
146+ }
147+ }
148+
149+ // Make sure all submodules are properly cloned
150+ val submodules = List (" scala-backend" , " scala2-library" , " collection-strawman" )
151+ if (! submodules.forall(exists)) {
152+ sLog.value.log(Level .Error ,
153+ s """ Missing some of the submodules
154+ |You can initialize the modules with:
155+ | > git submodule update --init
156+ """ .stripMargin)
157+ }
158+
159+ // Copy default configuration from .vscode-template/ unless configuration files already exist in .vscode/
160+ sbt.IO .copyDirectory(new File (" .vscode-template/" ), new File (" .vscode/" ), overwrite = false )
161+
162+ state
163+ },
164+
165+ // Credentials to release to Sonatype
166+ credentials ++= (
167+ for {
168+ username <- sys.env.get(" SONATYPE_USER" )
169+ password <- sys.env.get(" SONATYPE_PW" )
170+ } yield Credentials (" Sonatype Nexus Repository Manager" , " oss.sonatype.org" , username, password)
171+ ).toList,
172+ PgpKeys .pgpPassphrase := sys.env.get(" PGP_PW" ).map(_.toCharArray())
173+ )
174+
175+ lazy val commonSettings = publishSettings ++ Seq (
132176 scalaSource in Compile := baseDirectory.value / " src" ,
133177 scalaSource in Test := baseDirectory.value / " test" ,
134178 javaSource in Compile := baseDirectory.value / " src" ,
@@ -154,7 +198,6 @@ object Build {
154198
155199 // Settings used when compiling dotty with a non-bootstrapped dotty
156200 lazy val commonBootstrappedSettings = commonSettings ++ Seq (
157- EclipseKeys .skipProject := true ,
158201 version := dottyVersion,
159202 scalaVersion := dottyNonBootstrappedVersion,
160203
@@ -288,8 +331,6 @@ object Build {
288331 crossPaths := false ,
289332 // Do not depend on the Scala library
290333 autoScalaLibrary := false ,
291- // Let the sbt eclipse plugin know that this is a Java-only project
292- EclipseKeys .projectFlavor := EclipseProjectFlavor .Java ,
293334 // Remove javac invalid options in Compile doc
294335 javacOptions in (Compile , doc) --= Seq (" -Xlint:unchecked" , " -Xlint:deprecation" )
295336 )
@@ -465,10 +506,6 @@ object Build {
465506 Seq (file)
466507 }.taskValue,
467508
468- // include sources in eclipse (downloads source code for all dependencies)
469- // http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728
470- com.typesafe.sbteclipse.plugin.EclipsePlugin .EclipseKeys .withSource := true ,
471-
472509 // get libraries onboard
473510 libraryDependencies ++= Seq (" com.typesafe.sbt" % " sbt-interface" % sbtVersion.value,
474511 (" org.scala-lang.modules" %% " scala-xml" % " 1.0.6" ).withDottyCompat(),
@@ -880,8 +917,6 @@ object Build {
880917 lazy val `vscode-dotty` = project.in(file(" vscode-dotty" )).
881918 settings(commonSettings).
882919 settings(
883- EclipseKeys .skipProject := true ,
884-
885920 version := " 0.1.2" , // Keep in sync with package.json
886921
887922 autoScalaLibrary := false ,
@@ -1097,22 +1132,6 @@ object Build {
10971132 ))
10981133 }
10991134
1100- lazy val dottyProjectFolderChecks = onLoad in Global := (onLoad in Global ).value andThen { state =>
1101- val submodules = List (new File (" scala-backend" ), new File (" scala2-library" ), new File (" collection-strawman" ))
1102- if (! submodules.forall(f => f.exists && f.listFiles().nonEmpty)) {
1103- sLog.value.log(Level .Error ,
1104- s """ Missing some of the submodules
1105- |You can initialize the modules with:
1106- | > git submodule update --init
1107- """ .stripMargin)
1108- }
1109-
1110- // Copy default configuration from .vscode-template/ unless configuration files already exist in .vscode/
1111- sbt.IO .copyDirectory(new File (" .vscode-template/" ), new File (" .vscode/" ), overwrite = false )
1112-
1113- state
1114- }
1115-
11161135 lazy val commonDistSettings = packSettings ++ Seq (
11171136 packMain := Map (),
11181137 publishArtifact := false ,
@@ -1134,9 +1153,6 @@ object Build {
11341153 dependsOn(dottyCompiler).
11351154 dependsOn(dottyLibrary).
11361155 nonBootstrappedSettings(
1137- triggeredMessage in ThisBuild := Watched .clearWhenTriggered,
1138- dottyProjectFolderChecks,
1139-
11401156 addCommandAlias(" run" , " dotty-compiler/run" ) ++
11411157 addCommandAlias(" legacyTests" , " dotty-compiler/testOnly dotc.tests" )
11421158 )
0 commit comments