maven 与 sbt 配置对比
所属分类 maven
浏览量 762
maven pom.xml
sbt build.sbt
maven
com.dyyx
demo
1.0-SNAPSHOT
sbt
organization := "com.dyyx"
name := "demo"
version := "1.0-SNAPSHOT"
加入源
maven:
scala-tools.org
Scala-Tools Maven2 Repository
http://scala-tools.org/repo-releases
sbt:
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
resolvers += name at location
加入本地maven库
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
build source
maven:
src/main/scala
src/main/resource
src/main/conf
sbt:
scalaSource in Compile := baseDirectory.value / "src/main/scala"
scalaSource in Test := baseDirectory.value / "src/test"
unmanagedResourceDirectories in Compile += baseDirectory.value / "src/main/resources"
导入依赖包,并排除不须要的包
maven:
org.apache.spark
spark-core_2.10
${spark.version}
javax.servlet
*
sbt:
libraryDependencies ++= Seq(
"org.apache.spark" % "spark-core_2.11" % "1.5.0"
)
"log4j" % "log4j" % "1.2.15" excludeAll(
ExclusionRule(organization = "com.sun.jdmk"),
ExclusionRule(organization = "com.sun.jmx"),
ExclusionRule(organization = "javax.jms")
def exclude(org: String, name: String) = excludeAll(ExclusionRule(org, name))
发布
maven:
artifactory
xxxxxx
http://artifactory.xxxxxx.com/artifactory/xxxxxx/
artifactory
xxxxxx
http://artifactory.xxxxxxx.com/artifactory/xxxxxxx/
sbt:
publishTo := {
val nexus = "http://artifactory.xxxxxx.com/artifactory/"
if (isSnapshot.value)
Some("snapshots" at nexus + "snapshots")
else
Some("releases" at nexus + "releases")
}
//受权
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
其中受权文件为:
realm=Artifactory Realm
host=host
user=userName
password=passWord
测试
maven:
org.scalatest
scalatest_2.11
3.0.0-M16-SNAP3
test
sbt:
libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.0-M16-SNAP3" % "test"
上一篇
下一篇
使用maven构建scala项目
构建工具sbt 简介
maven 和 sbt 命令对比
获取当前shell脚本所在目录绝对路径
play框架简介
play REST hello 实例