我有一個scala項目,我用sbt
構建。我想用sftp
將項目發佈到遠程服務器。我不想輸入每個publish
我的用戶名和密碼,所以我決定使用位於~/.ivy2/.credentials
的文件.credentials
。問題是.credentials
文件被忽略,因爲在每個publish
操作中,我需要給我的用戶名和密碼。sbt使用憑證發佈到遠程服務器
build.sbt
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
〜/ .ivy2/.credentials
realm=Maven Repository
host=example.com
user=user
password=foobar
我需要做什麼才能解決這個問題做什麼呢?
我沒有看到keyFile或證書的使用位置,但[documentation](http://www.scala-sbt.org/0.12 .1/docs/Detailed-Topics/Resolvers.html)以這種方式指定'resolvers + = Resolver.ssh(「my-ssh-repo」,「example.org」)作爲(「user」,「password」)。我相信這同樣適用於sftp –
您的解決方案可以工作,但我不想將密碼放入'build.sbt'中。另外,這個證書將被幾個scala項目使用。這就是爲什麼我想要存儲到如下所述的文件中:http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Publishing.html。然後,正確地添加我的示例中的憑據。 – alifirat