Defining Artifacts

By default, the published artifact is a war for DefaultWebProject and a jar for DefaultProject. You can declare other types of artifacts to publish by defining Artifact instances in your project definition. Multiple artifacts are allowed.

The basic constructions look like:

  val art  = Artifact("name", "type", "extension")
  val art2 = Artifact("name", "classifier")
  val art3 = Artifact("name", url: URL)
  val art4 = Artifact("name", Map("extra1" -> "value1", "extra2" -> "value2"))

For example:

  val myZip = Artifact("myproject", "zip", "zip")
  val myImg = Artifact("myproject", "image", "jpg")
  val for15 = Artifact("myproject", "jdk15")

See the Ivy documentation for more details on artifacts. See the Artifact API documentation for combining the parameters above and specifying configurations and extra attributes.


These declarations are collected and are made available under the artifacts method of your project definition. You could alternatively define your artifacts directly by overriding artifacts:

 override def artifacts =
   Artifact("myproject", "zip", "zip") ::
   Artifact("myproject", "jdk15") ::

To specify artifacts directly in addition to reflective definitions as above, add the artifacts to super.artifacts:

 override def artifacts =
   super.artifacts ++ Seq( Artifact("myproject", "zip", "zip") )

The artifacts method is then used to attach the artifacts to the project ID:

  def projectID =
    ModuleID(organization, moduleID, version.toString) artifacts(artifacts : _*)

Another alternative is to directly override projectID to specify your artifacts.


A common need is to publish source and doc artifacts. The declarations would look like:

  // make the jar names have the expected format
  override def packageDocsJar = defaultJarPath("-javadoc.jar")
  override def packageSrcJar= defaultJarPath("-sources.jar")

  // define the artifacts
  val sourceArtifact = Artifact.sources(artifactID)
  val docsArtifact = Artifact.javadoc(artifactID)

See Publishing for the full details on publishing sources and docs.

Using Dependencies with Artifacts

To specify the artifacts to use from a dependency that has custom or multiple artifacts, use the artifacts method on your dependencies. For example:

  val dep = "org" % "name" % "rev" artifacts(Artifact("name", "type", "ext"))

The from and classifer methods (described on the Basics page) are actually convenience methods that translate to artifacts:

  def from(url: String) = artifacts( Artifact(name, new URL(url)) )
  def classifier(c: String) = artifacts( Artifact(name, c) )

That is, the following two dependency declarations are equivalent:

 val testng = "org.testng" % "testng" % "5.7" classifier "jdk15"
 val testng = "org.testng" % "testng" % "5.7" artifacts( Artifact("testng", "jdk15") )