Skip to content

Commit

Permalink
Use 'dotted' convention for maven properties (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
raboof authored Feb 18, 2020
1 parent 02380eb commit accfaa4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective("

def mvn(group: String, artifact: String, version: String, scope: Option[String], classifier: Option[String]): String = {
val elements =
Seq("groupId" -> group, "artifactId" -> artifact, "version" -> { if (symbols.contains(version)) s"$${$version}" else version }) ++
Seq("groupId" -> group, "artifactId" -> artifact, "version" -> { if (symbols.contains(version)) s"$${${dotted(version)}}" else version }) ++
classifier.map("classifier" -> _) ++ scope.map("scope" -> _)
elements.map {
case (element, value) => s" <$element>$value</$element>"
Expand Down Expand Up @@ -825,7 +825,7 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective("
case "maven" | "Maven" | "mvn" =>
val symbolProperties = if (symbols.isEmpty) "" else
symbolPostfixes.map { sp =>
val symb = s"""${requiredCoordinate(VersionSymbol + sp)}"""
val symb = s"""${dotted(requiredCoordinate(VersionSymbol + sp))}"""
s""" &lt;$symb&gt;${requiredCoordinate(VersionValue + sp)}&lt;/$symb&gt;"""
}.mkString("&lt;properties&gt;\n", "\n", "\n&lt;/properties&gt;\n")
val artifacts = dependencyPostfixes.map { dp =>
Expand All @@ -848,6 +848,8 @@ case class DependencyDirective(ctx: Writer.Context) extends LeafBlockDirective("
}
printer.print("""</dl>""")
}

def dotted(symbol: String): String = symbol.replaceAll("(.)([A-Z])", "$1.$2").toLowerCase
}

case class IncludeDirective(ctx: Writer.Context) extends LeafBlockDirective("include") with SourceDirective {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec {
|<pre class="prettyprint">
|<code class="language-xml">
|&lt;properties&gt;
| &lt;AkkaHttpVersion&gt;10.1.0&lt;/AkkaHttpVersion&gt;
| &lt;akka.http.version&gt;10.1.0&lt;/akka.http.version&gt;
|&lt;/properties&gt;
|&lt;dependency&gt;
| &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt;
| &lt;artifactId&gt;akka-http_2.12&lt;/artifactId&gt;
| &lt;version&gt;$${AkkaHttpVersion}&lt;/version&gt;
| &lt;version&gt;$${akka.http.version}&lt;/version&gt;
|&lt;/dependency&gt;</code></pre>
|</dd>
|<dt>gradle</dt>
Expand Down Expand Up @@ -308,18 +308,18 @@ class DependencyDirectiveSpec extends MarkdownBaseSpec {
|<pre class="prettyprint">
|<code class="language-xml">
|&lt;properties&gt;
| &lt;AkkaVersion&gt;2.5.29&lt;/AkkaVersion&gt;
| &lt;AkkaHttpVersion&gt;10.1.0&lt;/AkkaHttpVersion&gt;
| &lt;akka.version&gt;2.5.29&lt;/akka.version&gt;
| &lt;akka.http.version&gt;10.1.0&lt;/akka.http.version&gt;
|&lt;/properties&gt;
|&lt;dependency&gt;
| &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt;
| &lt;artifactId&gt;akka-stream_2.12&lt;/artifactId&gt;
| &lt;version&gt;$${AkkaVersion}&lt;/version&gt;
| &lt;version&gt;$${akka.version}&lt;/version&gt;
|&lt;/dependency&gt;
|&lt;dependency&gt;
| &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt;
| &lt;artifactId&gt;akka-http_2.12&lt;/artifactId&gt;
| &lt;version&gt;$${AkkaHttpVersion}&lt;/version&gt;
| &lt;version&gt;$${akka.http.version}&lt;/version&gt;
|&lt;/dependency&gt;</code></pre>
|</dd>
|<dt>gradle</dt>
Expand Down

0 comments on commit accfaa4

Please sign in to comment.