我有一个使用sbt
构建的scala项目。我想使用sftp
将项目发布到远程服务器。我不想输入每个publish
我的用户名和密码,所以我决定使用位于.credentials
的文件~/.ivy2/.credentials
。问题是.credentials
文件被忽略,因为在每次publish
操作时,我都需要提供用户名和密码。
name := "myproject"
version := "1.0"
scalaVersion := "2.11.7"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.10.12",
"com.typesafe.play" %% "play-json" % "2.3.4",
"org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23",
"com.typesafe" % "config" % "1.3.0",
"com.github.nscala-time" %% "nscala-time" % "2.6.0"
)
coverageEnabled := true
publishMavenStyle := true
val keyFile: File = new File(sys.env("HOME") + "/.ssh/id_rsa")
publishTo := Some(Resolver.sftp("Maven Repository","example.com","/data/www/example.com/html"))
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
isSnapshot := true
realm=Maven Repository
host=example.com
user=user
password=foobar
为了解决这个问题,我需要做些什么?
答案 0 :(得分:2)
常春藤凭据仅用于HTTP(s)解析器(请参阅常春藤文档:http://ant.apache.org/ivy/history/latest-milestone/settings/credentials.html)。
对于ssh / sftp,您可以使用ssh密钥,但不幸的是,如果您使用ssh-agent来保护您的私钥,sbt会询问您的密码。问题在Ivy 2.4中得到解决,但sbt仍然使用Ivy 2.3(https://github.com/sbt/sbt/issues/1920)