diff --git a/.appveyor.yml b/.appveyor.yml index 680470c9d..f0c903f69 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -22,7 +22,7 @@ install: - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 test_script: - - sbt "-Dsbt.build.version=1.2.8" universal:packageBin + - sbt "-Dsbt.build.version=1.3.0-M4" universal:packageBin - cd citest - test.bat - test1.bat diff --git a/.travis.yml b/.travis.yml index 213d7d1ce..7f51ec42d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: scala env: global: - - SBT_VER=1.2.8 + - SBT_VER=1.3.0-M4 matrix: include: diff --git a/bin/coursier b/bin/coursier new file mode 100755 index 000000000..e808b0db0 Binary files /dev/null and b/bin/coursier differ diff --git a/bin/coursier.bat b/bin/coursier.bat new file mode 100644 index 000000000..87ca34b5b --- /dev/null +++ b/bin/coursier.bat @@ -0,0 +1,95 @@ +@echo off + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%) + +set ERROR_CODE=0 + +@REM set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" @setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +for /f %%j in ("java.exe") do ( + set JAVA_EXE="%%~$PATH:j" + goto init +) + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" ( + SET JAVA_EXE="%JAVA_HOME%\bin\java.exe" + goto init +) + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory. +echo JAVA_HOME = %JAVA_HOME% +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation +echo. +goto error + +:init +@REM Decide how to startup depending on the version of windows + +@REM -- Win98ME +if NOT "%OS%"=="Windows_NT" goto Win9xArg + +@REM -- 4NT shell +if "%@eval[2+2]" == "4" goto 4NTArgs + +@REM -- Regular WinNT shell +set CMD_LINE_ARGS=%* +goto endInit + +@REM The 4NT Shell from jp software +:4NTArgs +set CMD_LINE_ARGS=%$ +goto endInit + +:Win9xArg +@REM Slurp the command line arguments. This loop allows for an unlimited number +@REM of agruments (up to the command line limit, anyway). +set CMD_LINE_ARGS= +:Win9xApp +if %1a==a goto endInit +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto Win9xApp + +@REM Reaching here means variables are defined and arguments have been captured +:endInit + +set JAR_PATH=%~dp0\%~n0 +SET PROG_DIR=%~dp0 +SET PSEP=; + +@REM Start Java program +:runm2 +SET CMDLINE=%JAVA_EXE% -noverify %JAVA_OPTS% -Dprog.dir="%PROG_DIR:\=\\%" -jar "%JAR_PATH%" %CMD_LINE_ARGS% +%CMDLINE% +if ERRORLEVEL 1 goto error +goto end + +:error +if "%OS%"=="Windows_NT" @endlocal +set ERROR_CODE=1 + +:end +@REM set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" goto endNT + +@REM For old DOS remove the set variables from ENV - we assume they were not set +@REM before we started - at least we don't leave any baggage around +set JAVA_EXE= +set CMD_LINE_ARGS= +set CMDLINE= +set PSEP= +goto postExec + +:endNT +@endlocal + +:postExec +exit /B %ERROR_CODE% diff --git a/build.sbt b/build.sbt index 84ef58036..267ebf00a 100644 --- a/build.sbt +++ b/build.sbt @@ -32,6 +32,7 @@ lazy val sbt013ExtraDeps = { else Seq() } +lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows") lazy val isExperimental = (sbtVersionToRelease contains "RC") || (sbtVersionToRelease contains "M") val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") @@ -51,6 +52,9 @@ val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Relea val windowsBuildId = settingKey[Int]("build id for Windows installer") val debianBuildId = settingKey[Int]("build id for Debian") +val exportRepoUsingCoursier = taskKey[File]("export Maven style repository") +val exportRepoCsrDirectory = settingKey[File]("") + // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin, @@ -186,7 +190,12 @@ val root = (project in file(".")). Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") }, mappings in Universal ++= (Def.taskDyn { - if (sbtOfflineInstall) + if (sbtOfflineInstall && sbtVersionToRelease.startsWith("1.")) + Def.task { + val _ = (exportRepoUsingCoursier in dist).value + directory((target in dist).value / "lib") + } + else if (sbtOfflineInstall) Def.task { val _ = (exportRepo in dist).value directory((target in dist).value / "lib") @@ -330,15 +339,7 @@ lazy val dist = (project in file("dist")) val old = exportRepo.value sbtVersionToRelease match { case v if v.startsWith("1.") => - val zincBase = exportRepoDirectory.value / "org.scala-sbt" / "zinc_2.12" - val zincVersion = (zincBase * DirectoryFilter).get.head.getName - val utilBase = exportRepoDirectory.value / "org.scala-sbt" / "util-logging_2.12" - val utilVersion = (utilBase * DirectoryFilter).get.head.getName - val outbase = exportRepoDirectory.value / "org" / "scala-sbt" / "compiler-interface" / zincVersion - val uribase = s"https://oss.sonatype.org/content/repositories/public/org/scala-sbt/compiler-interface/$zincVersion/" - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.jar"), outbase / s"compiler-interface-${zincVersion}.jar") - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}-sources.jar"), outbase / s"compiler-interface-${zincVersion}-sources.jar") - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.pom"), outbase / s"compiler-interface-${zincVersion}.pom") + sys.error("sbt 1.x should use coursier") case v if v.startsWith("0.13.") => val outbase = exportRepoDirectory.value / "org.scala-sbt" / "compiler-interface" / v val uribase = s"https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/$v/" @@ -350,6 +351,31 @@ lazy val dist = (project in file("dist")) old }, exportRepoDirectory := target.value / "lib" / "local-preloaded", + exportRepoCsrDirectory := exportRepoDirectory.value, + exportRepoUsingCoursier := { + val outDirectory = exportRepoCsrDirectory.value + val csr = + if (isWindows) (baseDirectory in LocalRootProject).value / "bin" / "coursier.bat" + else (baseDirectory in LocalRootProject).value / "bin" / "coursier" + val cache = target.value / "coursier" + IO.delete(cache) + val v = sbtVersionToRelease + s"$csr fetch --cache $cache org.scala-sbt:sbt:$v".! + val mavenCache = cache / "https" / "repo1.maven.org" / "maven2" + val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption + compilerBridgeVer match { + case Some(bridgeDir) => + val bridgeVer = bridgeDir.getName + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.10:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.11:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.12:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.13:$bridgeVer".! + case _ => + sys.error("bridge not found") + } + IO.copyDirectory(mavenCache, outDirectory, true, true) + outDirectory + }, conflictWarning := ConflictWarning.disable, publish := (), publishLocal := (), diff --git a/citest/build.sbt b/citest/build.sbt index 3ff4eae20..77123e433 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -10,11 +10,10 @@ lazy val root = (project in file(".")) println(xs) assert(xs(0) startsWith "[info] Loading project definition") - assert(xs(1) startsWith "[info] Loading settings from build.sbt") + assert(xs(1) startsWith "[info] Loading settings") assert(xs(2) startsWith "[info] Set current project to Hello") assert(xs(3) startsWith "[info] This is sbt") assert(xs(4) startsWith "[info] The current project") - assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4") val ys = IO.readLines(file("err.txt")).toVector.distinct diff --git a/citest/project/build.properties b/citest/project/build.properties index 31334bbd3..c491602bb 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.1 +sbt.version=1.3.0-M4 diff --git a/citest/test.bat b/citest/test.bat index 9234e6201..6dc88bae4 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -13,6 +13,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" about +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about ENDLOCAL diff --git a/citest/test.sh b/citest/test.sh index 53c9c6db6..c25555881 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -23,14 +23,14 @@ fail() { } env HOME=./target/home1 ./freshly-baked/sbt/bin/sbt about -test -d ./target/home1/.sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home1/.sbt" +test -d ./target/home1/.sbt/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home1/.sbt" env HOME=./target/home2 ./freshly-baked/sbt/bin/sbt -sbt-dir ./target/home2/alternate-sbt about -test -d ./target/home2/alternate-sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home2/alternate-sbt" +test -d ./target/home2/alternate-sbt/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home2/alternate-sbt" env HOME=./target/home3 ./freshly-baked/sbt/bin/sbt -J-Dsbt.preloaded=./target/home3/alternate-preloaded about -test -d ./target/home3/alternate-preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home3/alternate-preloaded" +test -d ./target/home3/alternate-preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home3/alternate-preloaded" env HOME=./target/home4 ./freshly-baked/sbt/bin/sbt -J-Dsbt.global.base=./target/home4/global-base about -test -d ./target/home4/global-base/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" +test -d ./target/home4/global-base/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" diff --git a/citest/test1.bat b/citest/test1.bat index 4036c2593..9ac5f2b1c 100644 --- a/citest/test1.bat +++ b/citest/test1.bat @@ -6,6 +6,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt ENDLOCAL diff --git a/citest/test2.bat b/citest/test2.bat index 2c42c7288..ebd74afe8 100644 --- a/citest/test2.bat +++ b/citest/test2.bat @@ -6,6 +6,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" check +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check ENDLOCAL diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 7447bb89b..1a4e02524 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -264,7 +264,7 @@ syncPreloaded() { local target_preloaded="$(getPreloaded)" if [[ "$init_sbt_version" == "" ]]; then # FIXME: better $init_sbt_version detection - init_sbt_version="$(ls -1 "$source_preloaded/org.scala-sbt/sbt/")" + init_sbt_version="$(ls -1 "$source_preloaded/org/scala-sbt/sbt/")" fi [[ -f "$target_preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index f909ec0fb..b67083271 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -190,11 +190,11 @@ exit /B 0 :sync_preloaded if "%INIT_SBT_VERSION%"=="" ( rem FIXME: better %INIT_SBT_VERSION% detection - FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org.scala-sbt\sbt" /B`) DO ( + FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( SET INIT_SBT_VERSION=%%F ) ) -set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" +set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\%INIT_SBT_VERSION%\" if /I %JAVA_VERSION% GEQ 8 ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 (