Library dependencies

The @@dependency block is used to show example code for how to configure a dependency on a library in a build tool, such as sbt.

@@dependency[sbt,Maven,Gradle] {
  group="com.typesafe.akka"
  artifact="akka-http_2.12"
  version="10.0.10"
}

Which will render as:

sbt
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.0.10"
Maven
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-http_2.12</artifactId>
  <version>10.0.10</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.typesafe.akka', name: 'akka-http_2.12', version: '10.0.10'
}

The build tools for which to show a configuration snippet can be configured in the directive content. Recognized build tools are: sbt, Maven and Gradle. Each build tool snippet will be shown in a separate tab.

The library coordinates are defined via the group, artifact and version attributes. Optionally, scope and classifier attributes can also be defined if needed. Variables may be used inside attributes, for example $project.version$.

@@dependency[sbt,Maven,Gradle] {
  group="com.example"
  artifact="domain"
  version="0.1.0"
  scope="runtime"
  classifier="assets"
}

Which will render as:

sbt
libraryDependencies += "com.example" % "domain" % "0.1.0" % Runtime classifier "assets"
Maven
<dependency>
  <groupId>com.example</groupId>
  <artifactId>domain</artifactId>
  <version>0.1.0</version>
  <classifier>assets</classifier>
  <scope>runtime</scope>
</dependency>
Gradle
dependencies {
  runtime group: 'com.example', name: 'domain', version: '0.1.0', classifier: 'assets'
}

It is also possible to render more than one dependency in a list. In that case library coordinates need to be appended with the same suffix. For example

@@dependency[sbt,Maven,Gradle] {
  group="com.example" artifact="domain" version="0.1.0"
  group2="com.example" artifact2="another-domain" version2="0.2.1"
}

will be rendered as:

sbt
libraryDependencies ++= Seq(
  "com.example" % "domain" % "0.1.0",
  "com.example" % "another-domain" % "0.2.1"
)
Maven
<dependency>
  <groupId>com.example</groupId>
  <artifactId>domain</artifactId>
  <version>0.1.0</version>
</dependency>
<dependency>
  <groupId>com.example</groupId>
  <artifactId>another-domain</artifactId>
  <version>0.2.1</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.example', name: 'domain', version: '0.1.0',
  compile group: 'com.example', name: 'another-domain', version: '0.2.1'
}
The source code for this page can be found here.