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
@@ -20,6 +20,8 @@ import dotty.tools.sbtplugin.DottyIDEPlugin.autoImport._
2020import org .scalajs .sbtplugin .ScalaJSPlugin
2121import org .scalajs .sbtplugin .ScalaJSPlugin .autoImport ._
2222
23+ import com .typesafe .sbt .pgp .PgpKeys
24+
2325import pl .project13 .scala .sbt .JmhPlugin
2426import JmhPlugin .JmhKeys .Jmh
2527
@@ -96,27 +98,14 @@ object Build {
9698
9799 lazy val bootstrapFromPublishedJars = settingKey[Boolean ](" If true, bootstrap dotty from published non-bootstrapped dotty" )
98100
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-
110101 // Only available in vscode-dotty
111102 lazy val unpublish = taskKey[Unit ](" Unpublish a package" )
112103
113-
114-
115- lazy val commonSettings = publishSettings ++ Seq (
104+ // Settings shared by the build (scoped in ThisBuild). Used in build.sbt
105+ lazy val thisBuildSettings = Def .settings(
116106 organization := dottyOrganization,
117107 organizationName := " LAMP/EPFL" ,
118108 organizationHomepage := Some (url(" http://lamp.epfl.ch" )),
119- homepage := Some (url(dottyGithubUrl)),
120109
121110 scalacOptions ++= Seq (
122111 " -feature" ,
@@ -129,6 +118,60 @@ object Build {
129118
130119 javacOptions ++= Seq (" -Xlint:unchecked" , " -Xlint:deprecation" ),
131120
121+ // Change this to true if you want to bootstrap using a published non-bootstrapped compiler
122+ bootstrapFromPublishedJars := false ,
123+
124+ // Override `runCode` from sbt-dotty to use the language-server and
125+ // vscode extension from the source repository of dotty instead of a
126+ // published version.
127+ runCode := (run in `dotty-language-server`).toTask(" " ).value
128+ )
129+
130+ // Settings shared globally (scoped in Global). Used in build.sbt
131+ lazy val globalSettings = Def .settings(
132+ // Override `runCode` from sbt-dotty to use the language-server and
133+ // vscode extension from the source repository of dotty instead of a
134+ // published version.
135+ runCode := (run in `dotty-language-server`).toTask(" " ).value,
136+
137+ onLoad := (onLoad in Global ).value andThen { state =>
138+ def exists (submodule : String ) = {
139+ val path = Paths .get(submodule)
140+ Files .exists(path) && {
141+ val fileStream = Files .list(path)
142+ val nonEmpty = fileStream.iterator().hasNext()
143+ fileStream.close()
144+ nonEmpty
145+ }
146+ }
147+
148+ // Make sure all submodules are properly cloned
149+ val submodules = List (" scala-backend" , " scala2-library" , " collection-strawman" )
150+ if (! submodules.forall(exists)) {
151+ sLog.value.log(Level .Error ,
152+ s """ Missing some of the submodules
153+ |You can initialize the modules with:
154+ | > git submodule update --init
155+ """ .stripMargin)
156+ }
157+
158+ // Copy default configuration from .vscode-template/ unless configuration files already exist in .vscode/
159+ sbt.IO .copyDirectory(new File (" .vscode-template/" ), new File (" .vscode/" ), overwrite = false )
160+
161+ state
162+ },
163+
164+ // Credentials to release to Sonatype
165+ credentials ++= (
166+ for {
167+ username <- sys.env.get(" SONATYPE_USER" )
168+ password <- sys.env.get(" SONATYPE_PW" )
169+ } yield Credentials (" Sonatype Nexus Repository Manager" , " oss.sonatype.org" , username, password)
170+ ).toList,
171+ PgpKeys .pgpPassphrase := sys.env.get(" PGP_PW" ).map(_.toCharArray())
172+ )
173+
174+ lazy val commonSettings = publishSettings ++ Seq (
132175 scalaSource in Compile := baseDirectory.value / " src" ,
133176 scalaSource in Test := baseDirectory.value / " test" ,
134177 javaSource in Compile := baseDirectory.value / " src" ,
@@ -881,7 +924,6 @@ object Build {
881924 settings(commonSettings).
882925 settings(
883926 EclipseKeys .skipProject := true ,
884-
885927 version := " 0.1.2" , // Keep in sync with package.json
886928
887929 autoScalaLibrary := false ,
@@ -1097,22 +1139,6 @@ object Build {
10971139 ))
10981140 }
10991141
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-
11161142 lazy val commonDistSettings = packSettings ++ Seq (
11171143 packMain := Map (),
11181144 publishArtifact := false ,
@@ -1134,9 +1160,6 @@ object Build {
11341160 dependsOn(dottyCompiler).
11351161 dependsOn(dottyLibrary).
11361162 nonBootstrappedSettings(
1137- triggeredMessage in ThisBuild := Watched .clearWhenTriggered,
1138- dottyProjectFolderChecks,
1139-
11401163 addCommandAlias(" run" , " dotty-compiler/run" ) ++
11411164 addCommandAlias(" legacyTests" , " dotty-compiler/testOnly dotc.tests" )
11421165 )
0 commit comments