Skip to content

Commit

Permalink
Map the runtime scope to runtimeOnly for doc snippets (#298)
Browse files Browse the repository at this point in the history
Fixes #293
  • Loading branch information
timyates committed Mar 18, 2022
1 parent b45e1c0 commit ab7a21d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class BuildDependencyMacro extends InlineMacroProcessor implements ValueAtAttrib
return 'testImplementation'
case 'test':
return 'testImplementation'
break
case 'runtime':
return 'runtimeOnly'
case 'provided':
return 'developmentOnly'
default: return s
Expand Down
18 changes: 18 additions & 0 deletions src/test/groovy/io/micronaut/docs/BuildDependencyMacroSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ class BuildDependencyMacroSpec extends Specification {
content.contains('implementation(<span class="hljs-string">"io.micronaut:micronaut-function-aws-alexa")')
}

void "runtime scope is mapped to runtimeOnly in Gradle and kept in Maven"() {
when:
String content = BuildDependencyMacro.contentForTargetAndAttributes("micronaut-function-aws-alexa", [scope: 'runtime'])

then:
content.contains('data-lang="gradle">runtimeOnly')

and: 'only one gradle version is shown'
!content.contains('data-lang="gradle-groovy">runtimeOnly')
!content.contains('data-lang="gradle-kotlin">runtimeOnly')

and: 'snippet is kotlin compatible. It contains parenthesis and double quotes'
content.contains('runtimeOnly(<span class="hljs-string">"io.micronaut:micronaut-function-aws-alexa")')

and: 'maven snippet has correct scope'
content.contains('&lt;scope&gt;runtime&lt;/scope&gt;')
}

void "version appears after the 2nd column for gradle"() {
when:
def content = BuildDependencyMacro.contentForTargetAndAttributes("artifactId", ["text": 'version="1.2.3"'])
Expand Down

0 comments on commit ab7a21d

Please sign in to comment.