0
点赞
收藏
分享

微信扫一扫

Win10 下 Idea 使用 SBT 方式编译 Scala 源码

WikongGuan 2022-12-03 阅读 65


sbtconfig.txt

Set the java args to high

-Xmx512M

-XX:MaxPermSize=256m

-XX:ReservedCodeCacheSize=128m

# Set the extra SBT options

-Dsbt.log.format=true

-Dsbt.ivy.home=C:\soft\sbt\.ivy2
-Dsbt.global.base=C:\soft\sbt\.sbt
-Dsbt.boot.directory=C:\Users\answer\.sbt\boot
-Dsbt.repository.config=C:\Users\answer\.sbt\repo.properties
-Dsbt.repository.secure=false

路径: %SBT_HOME%\conf\sbtconfig.txt
 

repo.properties

[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots

路径: sbtconfig.txt -> Dsbt.repository.config 属性设置的值
 

Idea 配置

  1. Settings -> Build, Execution, Deployment -> Build Tools -> SBT
  • JVM Options -> VM parameters -> -Xmx512M -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m
  • Launcher -> C:\soft\sbt\bin\sbt-launch.jar
  1. Ctrl + Shift + Alt + s(Project Structure) -> Modules

SBT 下载的缓存 jar 包路径: C:\Users\answer.ivy2\cache
 

SBT 命令

# 查看版本号
sbt sbtVersion
# 清理环境
sbt clean
# 编译
sbt compile
# 打包
sbt package
# 打包
sbt assembly

# 先执行 sbt 进行 sbt 命令行, 在执行对应的命令 sbtVersion | clean | compile | package | assembly

 

SBT编译 java 报错:编码GBK的不可映射字符

javacOptions ++= Seq("-encoding", "UTF-8")
// javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-encoding", "UTF-8")

 

% 和 %% 区别

libraryDependencies += "junit" % "junit" % "4.12"
junit.junit;4.12
libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.3.0"
org.scalaj#scalaj-http_${scalaVersion};2.3.0

# 打包时此 jar 包不需要打进 jar 包中, 加 provided
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.4.3" % "provided",

  • %%​:自动给库包的报名结尾加上Scala的版本号
  • %​: 只用于分割 groupId 与 artifactId

 

Reference

  • ​​win10下idea使用sbt方式编译scala源码​​


举报

相关推荐

0 条评论