Publish to bintray a zip file with sbt-native-packager

混江龙づ霸主 提交于 2019-12-11 12:37:47

问题


I want to publish a zip file to bintray using the sbt-native-launcher.

I am able to execute:

sbt publish

and it publishes the main artifacts (.jar, javadocs, and so on).

I am also able to execute:

sbt universal:packageBin

and it generates the .zip file.

However, when I execute:

sbt universal:publish

it gives the following error:

[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

It seems that the problem is with the "universal:packageZipTarball" task which also gives the same error.

I am using windows and I have checked that I have "tar", "xz" and "gzip" installed.

I would not mind to publish only the .zip by now, so maybe another workaround is just to know how can I configure sbt-native-packager to avoid the packageZipTarball task.

The build.sbt definition is:

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)

and the project/build.scala is:

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"
 )
} 

the output of last universal:packageZipTarball is:

> 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:


I think the problem is with the tar for windows, which does not accept absolute paths. What sbt-native-packager does is executing tar -pcvf <absolute-path> <input>.

I am not sure you can easily disable universal:packageZipTarball task.

I can propose a workaround though. Install bsdtar, which doesn't seem to have this issue, and still can be called as gnu tar. Download the file from the link, and install gnutar, after installation go to C:\Program Files\GnuWin32\bin and copy bsdtar.exe to tar.exe.

Make sure the tar command is in your PATH variable.



来源:https://stackoverflow.com/questions/23718949/publish-to-bintray-a-zip-file-with-sbt-native-packager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!