SBT how to publish artifact generated by run command

I am trying to compile and run scala code that generates a file in SBT (in this case its swagger file).

The following sbt is executed. The bank is built and executed, and the swagger.zip file that executes is created in the target directory. However, I cannot get the zip file to be published in my artificial repo, as my standard jar files did.

Any idea on what I am missing?



    publishArtifact in (Compile, packageBin) := false 
    publishArtifact in run := true

    val myZipTask = taskKey[File]("swagger-zip")

    myZipTask := {
      file("swagger.zip")
    }

    addArtifact(Artifact("swagger", "zip", "zip"), myZipTask )


+4
source share
1 answer

run , , . , , run "publishArtifact in run := true", ; Tasks. , .

addArtifact (. )

, Task addArtifact, ..

val myZipTask = taskKey[File]("return the swagger-zip file")
val runZipCodeTask = taskKey[Unit]("run the swagger-zip code")

// See http://www.scala-sbt.org/0.13.2/docs/faq.html, "How can I create a custom run task, in addition to run?"
// and https://stackoverflow.com/questions/23409993/defining-sbt-task-that-invokes-method-from-project-code
fullRunTask(runZipCodeTask, Compile, "ZipGeneratorMainClass")

myZipTask := {
  runZipCodeTask.value
  file("target/swagger/swagger.zip")
}

addArtifact(Artifact("swagger", "zip", "zip"), myZipTask)

"sbt publish"

. https://gist.github.com/RichardBradley/5384a5e0da2427df237f42fe512b30b8 .

- ,

. fooobar.com/questions/310923/...

-2

Source: https://habr.com/ru/post/1673936/


All Articles