Search code examples
scalaplayframework-2.0sbt-native-packager

Adding artifact to play project using SBT - Native Packager Plugin


I'm trying to add artifact to my play project, I've looked in couple of forums and looks like this is the proper way to do it:

lazy val playProject = play.Project(myProjectName, myProjectVersion, path = file("."))
.settings(addArtifact(Artifact (myProjectName, "dist", "zip"), dist).settings: _*)

but then I'm getting compilation error: "...project/Build.scala:26: not found: value dist"

where I need to define it? what am I missing here?

additional info: my "playProject" is a module inside scala project that contain some other scala modules.


Solution

  • It is difficult to be sure with such a limited extract of your build definition, but my guess would be you are in a scala build file and didn't import the dist key in scope.

    Try adding the following import to your build file

    import com.typesafe.sbt.packager.universal.UniversalKeys.dist 
    

    addArtifact has the following signature :

    def addArtifact(a : sbt.Artifact, taskDef : sbt.TaskKey[java.io.File])
    

    UniversalKeys.dist is defined as follows:

    val dist = TaskKey[File]("dist", "Creates the distribution packages.")
    

    So the types are correct at least :)