您所需要的只是定义一个属性文件sbt.boot.properties
,它允许您:
C:\HOMEWARE\apps\sbt-0.74\sbt.boot.properties
[斯卡拉]
版本:2.7.7
# 分类器:来源、javadoc
[应用程序]
组织:org.scala-tools.sbt
名称:sbt
版本:读取(sbt.version)
类:sbt.xMain
组件:xsbti
跨版本:真
分类器:来源、javadoc
[存储库]
当地的
my-nexus:http://my.nexus/nexus/content/repositories/scala-tools/,[组织]/[模块]/[修订]/[类型]s/[工件](-[分类器])。 [分机]
本地行家
# sbt-db: http://databinder.net/repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
# Maven 中心
# scala-tools-releases
# scala-tools-snapshots
[开机]
目录:项目/启动
属性:项目/build.properties
prompt-create: 项目不存在,新建项目?
提示填充:真
快速选项:真
[日志]
级别:调试
[应用程序属性]
project.name: quick=set(test), new=prompt(Name)[p], fill=prompt(Name)
project.organization: new=prompt(Organization)[org.vonc]
project.version: quick=set(1.0), new=prompt(Version)[1.0], fill=prompt(Version)[1.0]
build.scala.versions: quick=set(2.8.0.RC2), new=prompt(Scala 版本)[2.8.0.RC2], fill=prompt(Scala 版本)[2.8.0.RC2]
sbt.version: quick=set(0.7.4), new=prompt(sbt version)[0.7.4], fill=prompt(sbt version)[0.7.4]
project.scratch:快速=设置(真)
项目初始化:快速=设置(真),新=设置(真)
[常春藤]
缓存目录:C:\HOMEWARE\projects\.ivy2\cache
注意:此sbt.boot.properties
文件的灵感来自:
我评论了任何外部Maven 存储库定义,并添加了对我自己的 Nexus Maven 存储库的引用。
启动器可以按优先级递增顺序以下列方式之一进行配置:
- 替换.
/sbt/sbt.boot.properties
_jar
- 将一个名为的配置文件
sbt.boot.properties
放在类路径上。将其放在不带/sbt
前缀的类路径根目录中。
- 在命令行上指定备用配置的位置。这可以通过以下方式完成:
- 将位置指定为系统属性
sbt.boot.properties
- 或作为启动器的第一个参数,前缀为“
@
”。
系统属性的优先级较低。
相对路径的分辨率为:
- 第一次尝试针对当前工作目录,
- 然后针对用户的主目录,
- 然后针对包含启动器 jar 的目录。
如果这些尝试均未成功,则会生成错误。
定义一个 sbt.bat 包装器(为了确保指定您的 sbt.boot.properties
),例如:
C:\HOMEWARE>more C:\HOMEWARE\bin\sbt.BAT
@echo off
set t=%~dp0
set adp0=%t:C:\="%"
set SBT_DIR=%adp0%..\apps\sbt-0.74
dir C:\%SBT_DIR%\sbt-launch-0.7.4.jar
# if needed, add your proxy settings
set PROXY_OPTIONS=-Dhttp.proxyHost=my.proxy -Dhttp.proxyPort=80xx -Dhttp.proxyUser=auser -Dhttp.proxyPassword=yyyy
set JAVA_OPTIONS=-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -cp C:\HOMEWARE\apps\sbt-0.74\sbt-launch-0.7.4
set SBT_BOOT_PROPERTIES=-Dsbt.boot.properties="sbt.boot.properties"
cmd /C C:\HOMEWARE\apps\jdk4eclipse\bin\java.exe %PROXY_OPTIONS% %JAVA_OPTIONS% %SBT_BOOT_PROPERTIES% -jar C:\HOMEWARE\apps\sbt-0.74\sbt-launch-0.7.4.jar %*
而且您的 sbt 将仅从以下位置下载工件:
刚刚在家里用我运行的旧 Nexus 开源 1.6、java 1.6、sbt07.4 进行了测试
C:\Prog\Java\jdk1.6.0_18\jre\bin\java -Xmx512M -Dsbt.boot.properties=sbt.boot.properties - jar "c:\Prog\Scala\sbt\sbt-launch-0.7.4.jar"
这给出了:
[success] Build completed successfully.
C:\Prog\Scala\tests\pp>sbt
Getting Scala 2.8.0 ...
downloading http://localhost:8081/nexus/content/repositories/scala/org/scala-lang/scala-compiler/2.8.0/scala-compiler-2.
8.0.jar ...
[SUCCESSFUL ] org.scala-lang#scala-compiler;2.8.0!scala-compiler.jar (311ms)
downloading http://localhost:8081/nexus/content/repositories/scala/org/scala-lang/scala-library/2.8.0/scala-library-2.8.
0.jar ...
[SUCCESSFUL ] org.scala-lang#scala-library;2.8.0!scala-library.jar (185ms)
:: retrieving :: org.scala-tools.sbt#boot-scala
confs: [default]
2 artifacts copied, 0 already retrieved (14484kB/167ms)
[info] Building project test 0.1 against Scala 2.8.0
[info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
如果我在 sbt.boot.properties 文件中尝试一个有趣的值:
C:\Prog\Scala\tests\pp>sbt
Getting Scala 2.9.7 ...
:: problems summary ::
:::: WARNINGS
module not found: org.scala-lang#scala-compiler;2.9.7
==== nexus: tried
http://localhost:8081/nexus/content/repositories/scala/org/scala-lang/scala-compiler/2.9.7/scala-compiler-2.9.7.pom
-- artifact org.scala-lang#scala-compiler;2.9.7!scala-compiler.jar:
http://localhost:8081/nexus/content/repositories/scala/org/scala-lang/scala-compiler/2.9.7/scala-compiler-2.9.7.jar
所以它确实将自己限制在我定义的两个仓库中:
[repositories]
nexus: http://localhost:8081/nexus/content/repositories/scala
nexus2: http://localhost:8081/nexus/content/repositories/scala, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
(我评论了其他所有内容:local
, maven-local
, ...)
如果我评论所有存储库并为 scala 版本添加一个有趣的值(2.7.9)sbt.boot.properties
,我会得到(就像 OP 一样)
C:\Prog\Scala\tests\pp>sbt
Error during sbt execution: No repositories defined.
如果我放了 2.7.7 (同时仍然对所有repo 进行了评论),是的,它不会产生错误:
C:\Prog\Scala\tests\pp>sbt
[info] Building project test 0.1 against Scala 2.8.0
[info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
但这只是因为它在我之前的尝试中已经下载了 scala2.8.0。
如果我从我的project/boot
目录中删除该库,那么它将引发异常:
[info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
> C:\Prog\Scala\tests\pp>sbt
Error during sbt execution: No repositories defined.
at xsbt.boot.Pre$.error(Pre.scala:18)
at xsbt.boot.Update.addResolvers(Update.scala:197)
...
at xsbt.boot.Boot$.main(Boot.scala:15)
at xsbt.boot.Boot.main(Boot.scala)
Error loading project: Error during sbt execution: No repositories defined.