如何在sonatype nexus存储库上发布sbt .zip文件?

时间:2015-08-21 07:34:59

标签: playframework sbt

我在sbt project的目标>通用文件夹中有zip文件,要在nexus存储库上发布此zip,我已在下面添加了代码

import com.typesafe.config._
import play.Project._
import play.PlayJava

//这里我有外部的sbt属性。

val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()

name := conf.getString("name_prop")

version := conf.getString("version_prop")

scalaVersion := conf.getString("scala_version")

val nexusProperty = conf.getString("nexus_prop")

val snapRelNo = conf.getString("Snapshot_Release_NO")

lazy val root = (project in file(".")).enablePlugins(PlayScala);

libraryDependencies ++= Seq(jdbc, anorm, cache, ws)

resolvers ++= Seq(
"Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
"snapshots" at "http://localhost:8081/nexus/content/repositories/snapshots/"
)

libraryDependencies ++= Seq(

//这里指定了依赖项     )     releaseSettings

credentials += Credentials(file(".") / "project" / ".credentials")

lazy val dist = com.typesafe.sbt.SbtNativePackager.NativePackagerKeys.dist

  val publishDist = TaskKey[sbt.File]("publish-dist", "publish the dist artifact")

  lazy val publishSettings = sbtrelease.ReleasePlugin.releaseSettings ++ Seq(
    publishArtifact in (Compile, packageDoc) := false,
    publishArtifact in (Compile, packageSrc) := false,
    publishArtifact in (Compile, packageBin) := false,
    publish <<= (publish) dependsOn dist,
    publishLocal <<= (publishLocal) dependsOn dist,
    artifact in publishDist ~= {
      (art: Artifact) => art.copy(`type` = "zip", extension = "zip")
    },
    // disable using the Scala version in output paths and artifacts
    crossPaths := false,
    // publish to Artefactory
    organization := nexusProperty,
    publishMavenStyle := true,
    pomIncludeRepository := {
      x => false
    },
    publishDist <<= (target in Universal, normalizedName, version) map { (targetDir, id, version) =>
      val packageName = "%s-%s" format(id, version)
      targetDir / (packageName + ".zip")
    },
    publishTo <<= version {
      (v: String) =>
        val repo = nexusProperty;// FILL IN HERE
        if (v.trim.endsWith("SNAPSHOT"))
         Some("snapshots" at repo + "libs-snapshot-local")
        else
         Some("releases" at repo + "libs-release-local")
    }
  ) ++ addArtifact(artifact in publishDist, publishDist)

  val main = play.Project(appName,
    dependencies = appDependencies,
    settings = playScalaSettings ++ publishSettings
  ).settings(
    version <<= version in ThisBuild 
  )


Its giving me error for play object as "error: object Project is not a member of package play import play.Project._" and if I remove this then error for this appears "val main = play.Project(appName,"

Please let us know the solution for this.
Thanks in advance.                 ^

0 个答案:

没有答案