diff --git a/.travis.yml b/.travis.yml index 9e3b8e81..5ae498ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: scala env: matrix: - - TRAVIS_JDK=adopt@1.8.0-222 + - TRAVIS_JDK=adopt@1.8-0 before_install: curl -Ls https://git.io/jabba | bash && . ~/.jabba/jabba.sh install: jabba install "$TRAVIS_JDK" && jabba use $_ && java -Xmx32m -version @@ -19,7 +19,7 @@ jobs: - script: sbt verify name: "Compile, test and build docs with JDK11" - env: TRAVIS_JDK=adopt@1.11.0-4 + env: TRAVIS_JDK=adopt@1.11-0 - stage: publish script: sbt ci-release @@ -48,7 +48,3 @@ cache: before_cache: - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete - find $HOME/.sbt -name "*.lock" -print -delete - -notifications: - email: - on_success: never diff --git a/README.markdown b/README.markdown index 15527d74..65bbf648 100644 --- a/README.markdown +++ b/README.markdown @@ -1,12 +1,10 @@ -Paradox [![scaladex-badge][]][scaladex] [![travis-badge][]][travis] [![gitter-badge][]][gitter] +Paradox [![scaladex-badge][]][scaladex] [![travis-badge][]][travis] ======= [scaladex]: https://index.scala-lang.org/lightbend/paradox [scaladex-badge]: https://index.scala-lang.org/lightbend/paradox/paradox/latest.svg -[travis]: https://travis-ci.org/lightbend/paradox -[travis-badge]: https://travis-ci.org/lightbend/paradox.svg?branch=master -[gitter]: https://gitter.im/lightbend/paradox -[gitter-badge]: https://badges.gitter.im/lightbend/paradox.svg +[travis]: https://travis-ci.com/lightbend/paradox +[travis-badge]: https://travis-ci.com/lightbend/paradox.svg?branch=master Paradox is a markdown documentation tool for software projects. See [Paradox docs](http://developer.lightbend.com/docs/paradox/latest/) for details. @@ -18,4 +16,4 @@ This software is licensed under the Apache 2 license. **Paradox is NOT supported under the Lightbend subscription.** -The project is maintained by the [Paradox Team](https://github.com/orgs/lightbend/teams/paradox) and all [the contributors](https://github.com/lightbend/paradox/graphs/contributors). Pull requests are very welcome–thanks in advance! +The project is community maintained by [the contributors](https://github.com/lightbend/paradox/graphs/contributors). Pull requests are very welcome–thanks in advance! diff --git a/core/src/main/scala/com/lightbend/paradox/markdown/Directive.scala b/core/src/main/scala/com/lightbend/paradox/markdown/Directive.scala index d65b9b22..71d5e3cb 100644 --- a/core/src/main/scala/com/lightbend/paradox/markdown/Directive.scala +++ b/core/src/main/scala/com/lightbend/paradox/markdown/Directive.scala @@ -696,6 +696,7 @@ case class InlineGroupDirective(groups: Seq[String]) extends InlineDirective(gro * Dependency directive. */ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective("dependency") { + val BomVersionSymbols = "bomVersionSymbols" val VersionSymbol = "symbol" val VersionValue = "value" val ScalaBinaryVersionVar = "scala.binary.version" @@ -714,6 +715,9 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective(" def renderDependency(tools: String, node: DirectiveNode, printer: Printer): Unit = { val classes = Seq("dependency", node.attributes.classesString).filter(_.nonEmpty) + val bomPostfixes = node.attributes.keys().asScala.toSeq + .filter(_.startsWith(BomVersionSymbols)).sorted.map(_.replace(BomVersionSymbols, "")) + val symbolPostfixes = node.attributes.keys().asScala.toSeq .filter(_.startsWith(VersionSymbol)).sorted.map(_.replace(VersionSymbol, "")) @@ -775,35 +779,61 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective(" } } - def gradle(group: String, artifact: String, rawArtifact: String, version: String, scope: Option[String], classifier: Option[String]): String = { - val artifactName = ScalaBinaryVersion match { + /** + * Replace Scala bin version in artifact postfix with the property. + */ + def artifactNameWithScalaBin(artifact: String, rawArtifact: String, property: String) = { + ScalaBinaryVersion match { case Some(v) if (rawArtifact.endsWith(scalaBinaryVersionVarUse)) => - "\"" + artifact.substring(0, artifact.length - v.length) + "${versions.ScalaBinary}\"" - case _ => s"'$artifact'" + artifact.substring(0, artifact.length - v.length) + property + case _ => artifact } - val conf = scope.getOrElse("compile") - val extra = classifier.map(c => s", classifier: '$c'").getOrElse("") - val v = if (symbols.contains(version)) s"versions.$version" else s"'$version'" - s"""$conf group: '$group', name: $artifactName, version: $v$extra""".stripMargin } - def mvn(group: String, artifact: String, rawArtifact: String, version: String, scope: Option[String], classifier: Option[String]): String = { - val artifactName = ScalaBinaryVersion match { - case Some(v) if rawArtifact.endsWith(scalaBinaryVersionVarUse) => - artifact.substring(0, artifact.length - v.length) + "${scala.binary.version}" - case _ => artifact + def gradle(group: String, artifact: String, rawArtifact: String, version: Option[String], scope: Option[String], classifier: Option[String]): String = { + val artifactName = artifactNameWithScalaBin(artifact, rawArtifact, "${versions.ScalaBinary}") + val conf = scope match { + case None => "implementation" + case Some("test") => "testImplementation" + case Some(other) => other } + val ver = version.map(v => if (symbols.contains(v)) s":$${versions.$v}" else s":$v").getOrElse("") + val extra = classifier.map(c => s":$c").getOrElse("") + s"""$conf "$group:$artifactName$ver$extra"""" + } + + def gradleBom(group: String, artifact: String, rawArtifact: String, version: String): String = { + val artifactName = artifactNameWithScalaBin(artifact, rawArtifact, "${versions.ScalaBinary}") + val ver = if (symbols.contains(version)) s"versions.$version" else version + s""" implementation platform("$group:$artifactName:$ver")""" + } + + def mvn(group: String, artifact: String, rawArtifact: String, version: Option[String], `type`: Option[String], scope: Option[String], classifier: Option[String], indent: String): String = { + val artifactName = artifactNameWithScalaBin(artifact, rawArtifact, "${scala.binary.version}") val elements = - Seq("groupId" -> group, "artifactId" -> artifactName, "version" -> { - if (symbols.contains(version)) s"$${${dotted(version)}}" else version - }) ++ - classifier.map("classifier" -> _) ++ scope.map("scope" -> _) + Seq("groupId" -> group, "artifactId" -> artifactName) ++ + version.map(v => "version" -> { + if (symbols.contains(v)) s"$${${dotted(v)}}" else v + }) ++ classifier.map("classifier" -> _) ++ `type`.map("type" -> _) ++ scope.map("scope" -> _) elements.map { - case (element, value) => s" <$element>$value" - }.mkString("\n", "\n", "\n").replace("<", "<").replace(">", ">") + case (element, value) => s"$indent <$element>$value</$element>" + }.mkString(s"$indent<dependency>\n", "\n", s"\n$indent</dependency>\n") } + val boms = bomPostfixes.map { p => + ( + requiredCoordinate(s"bomGroup$p"), + requiredCoordinate(s"bomArtifact$p"), + requiredCoordinateRaw(s"bomArtifact$p"), + requiredCoordinate(s"bomVersionSymbols$p").split(",").toSeq + ) + } + val bomSymbols = boms.flatMap(_._4.toSet).toSet + + val symbolVersions = symbolPostfixes + .map(sp => requiredCoordinate(VersionSymbol + sp) -> requiredCoordinate(VersionValue + sp)) + printer.print(s"""
""") tools.split("[,]").map(_.trim).filter(_.nonEmpty).foreach { tool => val (lang, code) = tool match { @@ -831,54 +861,91 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective(" case "gradle" | "Gradle" => val scalaBinaryVersionProperties = - if (showSymbolScalaBinary) ScalaBinaryVersion.flatMap { v => - Some(s""" ScalaBinary: "$v"""") - } + if (showSymbolScalaBinary) ScalaBinaryVersion.map(v => s""" ScalaBinary: "$v"""") else None val symbolProperties = if (scalaBinaryVersionProperties.isEmpty && symbols.isEmpty) "" else - (symbolPostfixes.map { sp => - s""" ${requiredCoordinate(VersionSymbol + sp)}: "${requiredCoordinate(VersionValue + sp)}"""" - } ++ scalaBinaryVersionProperties).mkString("versions += [\n", ",\n", "\n]\n") + (symbolVersions + .filter(sp => !bomSymbols.contains(sp._1)) + .map { + case (symbol, version) => s""" $symbol: "$version"""" + } ++ scalaBinaryVersionProperties).mkString("def versions = [\n", ",\n", "\n]\n") + val bomArtifacts = + if (boms.nonEmpty) { + boms.map { + case (group, artifact, artifactRaw, versionSymbol) => + gradleBom( + group, + artifact, + artifactRaw, + version = symbolVersions.find(_._1 == versionSymbol.head).map(_._2).getOrElse(sys.error(s"No version found for ${versionSymbol.head}")), + ) + }.mkString("", "\n", "\n\n") + } else "" val artifacts = dependencyPostfixes.map { dp => + val versionCoordinate = requiredCoordinate(s"version$dp") gradle( requiredCoordinate(s"group$dp"), requiredCoordinate(s"artifact$dp"), requiredCoordinateRaw(s"artifact$dp"), - requiredCoordinate(s"version$dp"), + if (bomSymbols.contains(versionCoordinate)) None else Some(versionCoordinate), coordinate(s"scope$dp"), coordinate(s"classifier$dp") ) } val libraryDependencies = - Seq("dependencies {", artifacts.map(a => s" $a").mkString(",\n"), "}").mkString("\n") + Seq("dependencies {", bomArtifacts ++ artifacts.map(a => s" $a").mkString("\n"), "}").mkString("\n") ("gradle", symbolProperties + libraryDependencies) case "maven" | "Maven" | "mvn" => val scalaBinaryVersionProperties = - if (showSymbolScalaBinary) ScalaBinaryVersion.flatMap { v => - Some(s""" <scala.binary.version>$v</scala.binary.version>""") + if (showSymbolScalaBinary) ScalaBinaryVersion.map { v => + s""" <scala.binary.version>$v</scala.binary.version>""" } else None val symbolProperties = if (scalaBinaryVersionProperties.isEmpty && symbols.isEmpty) "" else - (symbolPostfixes.map { sp => - val symb = s"""${dotted(requiredCoordinate(VersionSymbol + sp))}""" - s""" <$symb>${requiredCoordinate(VersionValue + sp)}</$symb>""" - } ++ scalaBinaryVersionProperties) + (symbolVersions + .filter(sp => !bomSymbols.contains(sp._1)) + .map { + case (symbol, version) => + val symb = dotted(symbol) + s""" <$symb>$version</$symb>""" + } ++ scalaBinaryVersionProperties) .mkString("<properties>\n", "\n", "\n</properties>\n") + val bomArtifacts = + if (boms.nonEmpty) { + boms.map { + case (group, artifact, artifactRaw, versionSymbol) => + val version = symbolVersions.find(_._1 == versionSymbol.head).map(_._2) + if (version.isEmpty) sys.error(s"No version found for ${versionSymbol.head}") + mvn( + group, + artifact, + artifactRaw, + version, + `type` = Some("pom"), + scope = Some("import"), + classifier = None, + indent = " " + ) + }.mkString("<dependencyManagement>\n <dependencies>\n", "", " </dependencies>\n</dependencyManagement>\n") + } else "" val artifacts = dependencyPostfixes.map { dp => + val versionCoordinate = requiredCoordinate(s"version$dp") mvn( requiredCoordinate(s"group$dp"), requiredCoordinate(s"artifact$dp"), requiredCoordinateRaw(s"artifact$dp"), - requiredCoordinate(s"version$dp"), + if (bomSymbols.contains(versionCoordinate)) None else Some(versionCoordinate), + `type` = None, coordinate(s"scope$dp"), - coordinate(s"classifier$dp") + coordinate(s"classifier$dp"), + indent = " " ) } - ("xml", symbolProperties + artifacts.mkString("\n")) + ("xml", symbolProperties + bomArtifacts ++ artifacts.mkString("<dependencies>\n", "", "</dependencies>")) } printer.print(s"""
$tool
""") diff --git a/docs/src/main/paradox/directives/dependencies.md b/docs/src/main/paradox/directives/dependencies.md index 5dbf7a7c..23828234 100644 --- a/docs/src/main/paradox/directives/dependencies.md +++ b/docs/src/main/paradox/directives/dependencies.md @@ -102,3 +102,53 @@ will be rendered as: artifact3="akka-http_$scala.binary.version$" version3="AkkaHttpVersion" } + +## Bill of Materials (BOM) for Maven and Gradle + +Similar to the symbolic version names above, [Maven BOMs](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms) can point to a BOM which specifies versions for dependencies and frees the local build from setting library versions for those dependencies. + +By specifying a `bomGroup`, `bomArtifact` and `bomVersionSymbols` the Maven and Gradle notations will show the notation to import the BOM and leave out the versions for the libraries using the listed symbols. If the BOM covers multiple different versions, list all symbols separated by commas. + +Note that the notation works just fine for sbt. + +This example (with empty lines for readability) + +``` +@@dependency[Maven,Gradle,sbt] { + bomGroup=com.typesafe.akka + bomArtifact=akka-with-http-bom_$scala.binary.version$ + bomVersionSymbols=AkkaVersion,AkkaHttpVersion + + symbol1=AkkaVersion + value1="2.6.13" + + symbol2="AkkaHttpVersion" + value2="10.2.2" + + group1="com.typesafe.akka" + artifact1="akka-stream_$scala.binary.version$" + version1="AkkaVersion" + + group2="com.typesafe.akka" + artifact2="akka-http_$scala.binary.version$" + version2="AkkaHttpVersion" +} +``` + +will be rendered as: + +@@dependency[Maven,Gradle,sbt] { + bomGroup=com.typesafe.akka + bomArtifact=akka-with-http-bom_$scala.binary.version$ + bomVersionSymbols=AkkaVersion,AkkaHttpVersion + symbol1=AkkaVersion + value1="2.6.13" + symbol2="AkkaHttpVersion" + value2="10.2.2" + group1="com.typesafe.akka" + artifact1="akka-stream_$scala.binary.version$" + version1="AkkaVersion" + group2="com.typesafe.akka" + artifact2="akka-http_$scala.binary.version$" + version2="AkkaHttpVersion" +} diff --git a/tests/src/test/scala/com/lightbend/paradox/markdown/DependencyDirectiveSpec.scala b/tests/src/test/scala/com/lightbend/paradox/markdown/DependencyDirectiveSpec.scala index 3e660a54..ab3c7ef5 100644 --- a/tests/src/test/scala/com/lightbend/paradox/markdown/DependencyDirectiveSpec.scala +++ b/tests/src/test/scala/com/lightbend/paradox/markdown/DependencyDirectiveSpec.scala @@ -51,21 +51,23 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { |<properties> | <scala.binary.version>2.12</scala.binary.version> |</properties> - |<dependency> - | <groupId>com.typesafe.akka</groupId> - | <artifactId>akka-http_$${scala.binary.version}</artifactId> - | <version>10.0.10</version> - |</dependency> + |<dependencies> + | <dependency> + | <groupId>com.typesafe.akka</groupId> + | <artifactId>akka-http_$${scala.binary.version}</artifactId> + | <version>10.0.10</version> + | </dependency> + |</dependencies> | |
Gradle
|
|
       |
-      |versions += [
+      |def versions = [
       |  ScalaBinary: "2.12"
       |]
       |dependencies {
-      |  compile group: 'com.typesafe.akka', name: "akka-http_$${versions.ScalaBinary}", version: '10.0.10'
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}:10.0.10"
       |}
       |
|
@@ -110,20 +112,61 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { |
|
       |
-      |<dependency>
-      |  <groupId>com.example</groupId>
-      |  <artifactId>domain</artifactId>
-      |  <version>0.1.0-RC2</version>
-      |  <classifier>assets</classifier>
-      |  <scope>runtime</scope>
-      |</dependency>
+ |<dependencies> + | <dependency> + | <groupId>com.example</groupId> + | <artifactId>domain</artifactId> + | <version>0.1.0-RC2</version> + | <classifier>assets</classifier> + | <scope>runtime</scope> + | </dependency> + |</dependencies> |
|
Gradle
|
|
       |
       |dependencies {
-      |  runtime group: 'com.example', name: 'domain', version: '0.1.0-RC2', classifier: 'assets'
+      |  runtime "com.example:domain:0.1.0-RC2:assets"
+      |}
+      |
+ |
+ |
""") + } + it should "render test scope" in { + markdown(""" + |@@dependency[sbt,Maven,Gradle] { + | group="com.example" + | artifact="domain" + | version="0.1.0-RC2" + | scope="test" + |}""") shouldEqual html(""" + |
+ |
sbt
+ |
+ |
+      |
+      |libraryDependencies += "com.example" % "domain" % "0.1.0-RC2" % Test
+ |
+ |
Maven
+ |
+ |
+      |
+      |<dependencies>
+      |  <dependency>
+      |    <groupId>com.example</groupId>
+      |    <artifactId>domain</artifactId>
+      |    <version>0.1.0-RC2</version>
+      |    <scope>test</scope>
+      |  </dependency>
+      |</dependencies>
+ |
+ |
Gradle
+ |
+ |
+      |
+      |dependencies {
+      |  testImplementation "com.example:domain:0.1.0-RC2"
       |}
       |
|
@@ -212,16 +255,18 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { |
|
       |
-      |<dependency>
-      |  <groupId>org.example</groupId>
-      |  <artifactId>foo_2.12</artifactId>
-      |  <version>0.1.0</version>
-      |</dependency>
-      |<dependency>
-      |  <groupId>org.example</groupId>
-      |  <artifactId>bar_2.12</artifactId>
-      |  <version>0.2.0</version>
-      |</dependency>
+      |<dependencies>
+      |  <dependency>
+      |    <groupId>org.example</groupId>
+      |    <artifactId>foo_2.12</artifactId>
+      |    <version>0.1.0</version>
+      |  </dependency>
+      |  <dependency>
+      |    <groupId>org.example</groupId>
+      |    <artifactId>bar_2.12</artifactId>
+      |    <version>0.2.0</version>
+      |  </dependency>
+      |</dependencies>
       |
|
|
gradle
@@ -229,8 +274,8 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { |
       |
       |dependencies {
-      |  compile group: 'org.example', name: 'foo_2.12', version: '0.1.0',
-      |  compile group: 'org.example', name: 'bar_2.12', version: '0.2.0'
+      |  implementation "org.example:foo_2.12:0.1.0"
+      |  implementation "org.example:bar_2.12:0.2.0"
       |}
       |
| @@ -263,22 +308,24 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { | <akka.http.version>10.1.0</akka.http.version> | <scala.binary.version>2.12</scala.binary.version> |</properties> - |<dependency> - | <groupId>com.typesafe.akka</groupId> - | <artifactId>akka-http_$${scala.binary.version}</artifactId> - | <version>$${akka.http.version}</version> - |</dependency> + |<dependencies> + | <dependency> + | <groupId>com.typesafe.akka</groupId> + | <artifactId>akka-http_$${scala.binary.version}</artifactId> + | <version>$${akka.http.version}</version> + | </dependency> + |</dependencies> | |
gradle
|
|
       |
-      |versions += [
+      |def versions = [
       |  AkkaHttpVersion: "10.1.0",
       |  ScalaBinary: "2.12"
       |]
       |dependencies {
-      |  compile group: 'com.typesafe.akka', name: "akka-http_$${versions.ScalaBinary}", version: versions.AkkaHttpVersion
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}:$${versions.AkkaHttpVersion}"
       |}
       |
|
@@ -320,32 +367,259 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec { | <akka.http.version>10.1.0</akka.http.version> | <scala.binary.version>2.12</scala.binary.version> |</properties> - |<dependency> - | <groupId>com.typesafe.akka</groupId> - | <artifactId>akka-stream_$${scala.binary.version}</artifactId> - | <version>$${akka.version}</version> - |</dependency> - |<dependency> - | <groupId>com.typesafe.akka</groupId> - | <artifactId>akka-http_$${scala.binary.version}</artifactId> - | <version>$${akka.http.version}</version> - |</dependency> + |<dependencies> + | <dependency> + | <groupId>com.typesafe.akka</groupId> + | <artifactId>akka-stream_$${scala.binary.version}</artifactId> + | <version>$${akka.version}</version> + | </dependency> + | <dependency> + | <groupId>com.typesafe.akka</groupId> + | <artifactId>akka-http_$${scala.binary.version}</artifactId> + | <version>$${akka.http.version}</version> + | </dependency> + |</dependencies> | |
gradle
|
|
       |
-      |versions += [
+      |def versions = [
       |  AkkaVersion: "2.5.29",
       |  AkkaHttpVersion: "10.1.0",
       |  ScalaBinary: "2.12"
       |]
       |dependencies {
-      |  compile group: 'com.typesafe.akka', name: "akka-stream_$${versions.ScalaBinary}", version: versions.AkkaVersion,
-      |  compile group: 'com.typesafe.akka', name: "akka-http_$${versions.ScalaBinary}", version: versions.AkkaHttpVersion
+      |  implementation "com.typesafe.akka:akka-stream_$${versions.ScalaBinary}:$${versions.AkkaVersion}"
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}:$${versions.AkkaHttpVersion}"
       |}
       |
|
|
""") } + + it should "render bom import" in { + markdown(""" + |@@dependency[sbt,Maven,gradle] { + | bomGroup="com.typesafe.akka" + | bomArtifact="akka-http-bom_$scala.binary.version$" + | bomVersionSymbols="AkkaHttpVersion" + | symbol="AkkaHttpVersion" + | value="10.1.0" + | group="com.typesafe.akka" + | artifact="akka-http_$scala.binary.version$" + | version="AkkaHttpVersion" + |}""") shouldEqual html(s""" + |
+ |
sbt
+ |
+ |
+      |
+      |val AkkaHttpVersion = "10.1.0"
+      |libraryDependencies += "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion
+ |
+ |
Maven
+ |
+ |
+      |
+      |<properties>
+      |  <scala.binary.version>2.12</scala.binary.version>
+      |</properties>
+      |<dependencyManagement>
+      |  <dependencies>
+      |    <dependency>
+      |      <groupId>com.typesafe.akka</groupId>
+      |      <artifactId>akka-http-bom_$${scala.binary.version}</artifactId>
+      |      <version>10.1.0</version>
+      |      <type>pom</type>
+      |      <scope>import</scope>
+      |    </dependency>
+      |  </dependencies>
+      |</dependencyManagement>
+      |<dependencies>
+      |  <dependency>
+      |    <groupId>com.typesafe.akka</groupId>
+      |    <artifactId>akka-http_$${scala.binary.version}</artifactId>
+      |  </dependency>
+      |</dependencies>
+ |
+ |
gradle
+ |
+ |
+      |
+      |def versions = [
+      |  ScalaBinary: "2.12"
+      |]
+      |dependencies {
+      |  implementation platform("com.typesafe.akka:akka-http-bom_$${versions.ScalaBinary}:10.1.0")
+      |
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}"
+      |}
+      |
+ |
+ |
""") + } + + it should "render multiple bom imports" in { + markdown(""" + |@@dependency[Maven,gradle] { + | bomGroup="com.typesafe.akka" + | bomArtifact="akka-bom_$scala.binary.version$" + | bomVersionSymbols="AkkaVersion" + | bomGroup2="com.typesafe.akka" + | bomArtifact2="akka-http-bom_$scala.binary.version$" + | bomVersionSymbols2="AkkaHttpVersion" + | symbol1="AkkaVersion" + | value1="2.6.12" + | group1="com.typesafe.akka" + | symbol2="AkkaHttpVersion" + | value2="10.1.0" + | artifact1="akka-stream_$scala.binary.version$" + | version1="AkkaVersion" + | group2="com.typesafe.akka" + | artifact2="akka-http_$scala.binary.version$" + | version2="AkkaHttpVersion" + |}""") shouldEqual html(s""" + |
+ |
Maven
+ |
+ |
+      |
+      |<properties>
+      |  <scala.binary.version>2.12</scala.binary.version>
+      |</properties>
+      |<dependencyManagement>
+      |  <dependencies>
+      |    <dependency>
+      |      <groupId>com.typesafe.akka</groupId>
+      |      <artifactId>akka-bom_$${scala.binary.version}</artifactId>
+      |      <version>2.6.12</version>
+      |      <type>pom</type>
+      |      <scope>import</scope>
+      |    </dependency>
+      |    <dependency>
+      |      <groupId>com.typesafe.akka</groupId>
+      |      <artifactId>akka-http-bom_$${scala.binary.version}</artifactId>
+      |      <version>10.1.0</version>
+      |      <type>pom</type>
+      |      <scope>import</scope>
+      |    </dependency>
+      |  </dependencies>
+      |</dependencyManagement>
+      |<dependencies>
+      |  <dependency>
+      |    <groupId>com.typesafe.akka</groupId>
+      |    <artifactId>akka-stream_$${scala.binary.version}</artifactId>
+      |  </dependency>
+      |  <dependency>
+      |    <groupId>com.typesafe.akka</groupId>
+      |    <artifactId>akka-http_$${scala.binary.version}</artifactId>
+      |  </dependency>
+      |</dependencies>
+ |
+ |
gradle
+ |
+ |
+      |
+      |def versions = [
+      |  ScalaBinary: "2.12"
+      |]
+      |dependencies {
+      |  implementation platform("com.typesafe.akka:akka-bom_$${versions.ScalaBinary}:2.6.12")
+      |  implementation platform("com.typesafe.akka:akka-http-bom_$${versions.ScalaBinary}:10.1.0")
+      |
+      |  implementation "com.typesafe.akka:akka-stream_$${versions.ScalaBinary}"
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}"
+      |}
+      |
+ |
+ |
""") + } + + it should "Maven: allow for multiple symbolic versions in one bom" in { + markdown(""" + |@@dependency[Maven] { + | bomGroup="com.typesafe.akka" + | bomArtifact="akka-bom_$scala.binary.version$" + | bomVersionSymbols="AkkaVersion,AkkaHttpVersion" + | symbol1="AkkaVersion" + | value1="2.6.12" + | group1="com.typesafe.akka" + | symbol2="AkkaHttpVersion" + | value2="10.1.0" + | artifact1="akka-stream_$scala.binary.version$" + | version1="AkkaVersion" + | group2="com.typesafe.akka" + | artifact2="akka-http_$scala.binary.version$" + | version2="AkkaHttpVersion" + |}""") shouldEqual html(s""" + |
+ |
Maven
+ |
+ |
+      |
+      |<properties>
+      |  <scala.binary.version>2.12</scala.binary.version>
+      |</properties>
+      |<dependencyManagement>
+      |  <dependencies>
+      |    <dependency>
+      |      <groupId>com.typesafe.akka</groupId>
+      |      <artifactId>akka-bom_$${scala.binary.version}</artifactId>
+      |      <version>2.6.12</version>
+      |      <type>pom</type>
+      |      <scope>import</scope>
+      |    </dependency>
+      |  </dependencies>
+      |</dependencyManagement>
+      |<dependencies>
+      |  <dependency>
+      |    <groupId>com.typesafe.akka</groupId>
+      |    <artifactId>akka-stream_$${scala.binary.version}</artifactId>
+      |  </dependency>
+      |  <dependency>
+      |    <groupId>com.typesafe.akka</groupId>
+      |    <artifactId>akka-http_$${scala.binary.version}</artifactId>
+      |  </dependency>
+      |</dependencies>
+ |
+ |
""") + } + + it should "Gradle: allow for multiple symbolic versions in one bom" in { + markdown(""" + |@@dependency[gradle] { + | bomGroup="com.typesafe.akka" + | bomArtifact="akka-bom_$scala.binary.version$" + | bomVersionSymbols="AkkaVersion,AkkaHttpVersion" + | symbol1="AkkaVersion" + | value1="2.6.12" + | group1="com.typesafe.akka" + | symbol2="AkkaHttpVersion" + | value2="10.1.0" + | artifact1="akka-stream_$scala.binary.version$" + | version1="AkkaVersion" + | group2="com.typesafe.akka" + | artifact2="akka-http_$scala.binary.version$" + | version2="AkkaHttpVersion" + |}""") shouldEqual html(s""" + |
+ |
gradle
+ |
+ |
+      |
+      |def versions = [
+      |  ScalaBinary: "2.12"
+      |]
+      |dependencies {
+      |  implementation platform("com.typesafe.akka:akka-bom_$${versions.ScalaBinary}:2.6.12")
+      |
+      |  implementation "com.typesafe.akka:akka-stream_$${versions.ScalaBinary}"
+      |  implementation "com.typesafe.akka:akka-http_$${versions.ScalaBinary}"
+      |}
+      |
+ |
+ |
""") + } + }