使用sbt-native-packager发布到bintray一个zip文件

时间:2014-05-18 05:48:34

标签: sbt sbt-native-packager bintray

我想使用sbt-native-launcher将一个zip文件发布到bintray。

我能够执行:

sbt publish

并发布主要工件(.jar,javadocs等)。

我也能执行:

sbt universal:packageBin

并生成.zip文件。

然而,当我执行:

sbt universal:publish

它出现以下错误:

[info] Wrote C:\src\ShExcala\target\scala-2.10\shexcala_2.10-0.0.1.pom
tar: Cannot execute remote shell: No such file or directory
tar: C\:\\Users\\Labra\\AppData\\Local\\Temp\\sbt_407249ba\\shexcala-0.0.1.tar: Cannot open: I/O error
tar: Error is not recoverable: exiting now
[trace] Stack trace suppressed: run last universal:packageZipTarball for the full output.
[error] (universal:packageZipTarball) Error tarballing
C:\src\ShExcala\target\universal\shexcala-0.0.1.tgz. Exit code: 2

似乎问题出在" universal:packageZipTarball"任务也给出了同样的错误。

我正在使用Windows,我检查过我有" tar"," xz"和" gzip"安装。

我不介意现在只发布.zip,所以也许另一种解决方法就是知道如何配置sbt-native-packager以避免packageZipTarball任务。

build.sbt定义是:

import sbt._
import sbt.Keys._
import AssemblyKeys._
import bintray.Plugin.bintraySettings
import bintray.Keys._
import scala.scalajs.sbtplugin.ScalaJSPlugin.ScalaJSKeys._

lazy val root = project.in(file("."))//.settings(crossScalaVersions := Seq("2.10.4", "2.11.0"))

Build.sharedSettings

version := Build.currentVersion

libraryDependencies ++= Seq(
    "org.specs2" %% "specs2" % "2.3.7" % "test" 
  , "org.scalatest" % "scalatest_2.10" % "2.0.1-SNAP" % "test"
  , "commons-configuration" % "commons-configuration" % "1.7"
  , "org.rogach" %% "scallop" % "0.9.5" 
  , "com.typesafe" % "config" % "1.0.1"
  , "org.scala-lang" % "scala-compiler" % "2.10.2" 
  , "com.assembla.scala-incubator" % "graph-core_2.10" % "1.6.2"
  , "org.apache.jena" % "jena-arq" % "2.10.1" 
  , "org.scalaz" % "scalaz-core_2.10" % "7.0.6" 
  , "es.weso" % "stateparser_2.10" % "0.0.1"
  , "es.weso" % "wesin_2.10" % "0.0.1" 
  )

autoCompilerPlugins := true

seq(bintraySettings:_*)

Build.publishSettings

deploymentSettings

publishMavenStyle := true

// publish <<= publish.dependsOn(publish in config("universal"))

packageArchetype.java_application

resourceGenerators in Test += Def.task {
  val location = url("https://github.com/shexSpec/test-suite/raw/gh-pages/tests.zip")
  IO.unzipURL(location, resourceManaged.value / "downloadedTests").toSeq
}.taskValue

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

project/build.scala是:

import sbt._
import sbt.Keys._
import bintray.Plugin.bintraySettings
import bintray.Keys._
import Def.ScopedKey
import scala.scalajs.sbtplugin.ScalaJSPlugin._

object Build extends sbt.Build {

  val isRelease = true 

  def repo = "weso-releases" 

  val shExcalaVersion = "0.0.1"

  publishMavenStyle := false

  val currentVersion = shExcalaVersion

  protected val bintrayPublishIvyStyle = settingKey[Boolean]("=== !publishMavenStyle")   

  lazy val publishSettings = Seq(
    repository in bintray := this.repo,
    bintrayOrganization in bintray := Some("weso"),
    licenses += ("MPL-2.0", url("http://opensource.org/licenses/MPL-2.0")),
    bintrayPublishIvyStyle := true
  )

 val sharedSettings = Seq(
    organization := "es.weso",
    name := "shExcala",
    scalaVersion := "2.10.4"
 )
} 

last universal:packageZipTarball的输出是:

> last universal:packageZipTarball
java.lang.RuntimeException: Error tarballing C:\src\ShExcala\target\universal\shexcala-0.0.1.tgz. Exit code: 2
        at scala.sys.package$.error(package.scala:27)
        at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:134)
        at  com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:118)
        at sbt.IO$.withTemporaryDirectory(IO.scala:285)
        at com.typesafe.sbt.packager.universal.Archives$.makeTarball(Archives.scala:118)
        at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:111)
        at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:111)
        at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
        at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
[error] (universal:packageZipTarball) Error tarballing     C:\src\ShExcala\target\universal\shexcala-0.0.1.tgz. Exit code: 2
>

1 个答案:

答案 0 :(得分:3)

我认为问题出在Windows的tar上,它不接受绝对路径。 sbt-native-packager 执行的是tar -pcvf <absolute-path> <input>

我不确定您是否可以轻松禁用universal:packageZipTarball任务。

我可以提出一个解决方法。安装bsdtar,似乎没有这个问题,仍然可以作为gnu tar调用。从链接下载文件,然后安装 gnutar ,安装后转到 C:\ Program Files \ GnuWin32 \ bin 并将bsdtar.exe复制到{{1} }。

确保tar.exe变量中包含tar命令。