Skip to content

Commit

Permalink
(#78) upgrades dokka, adds to docs output, fixes link to deployed API…
Browse files Browse the repository at this point in the history
… docs
  • Loading branch information
willbuck committed Mar 19, 2021
1 parent ce184fa commit c867af6
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 23 deletions.
20 changes: 18 additions & 2 deletions build.gradle
Expand Up @@ -15,12 +15,28 @@ subprojects { Project subproject ->

apply plugin: "io.micronaut.build.internal.common"
apply plugin: "kotlin"
apply plugin: "org.jetbrains.dokka"
apply plugin: "io.micronaut.build.internal.dependency-updates"
apply plugin: "io.micronaut.build.internal.publishing"
}
repositories {
jcenter()
}

apply plugin: "io.micronaut.build.internal.docs"
apply plugin: "io.micronaut.build.internal.dependency-updates"
apply plugin: 'org.jetbrains.dokka'

tasks.named("dokkaHtmlMultiModule") {
outputDirectory.set(new File("${rootProject.buildDir}/docs/api"))
}

task renameDokkaRootFile(type: Copy) {
from "${rootProject.buildDir}/docs/api/-modules.html"
into "${rootProject.buildDir}/docs/api/"
rename { String fileName ->
fileName.replace("-modules", "index")
}
}
renameDokkaRootFile.dependsOn(dokkaHtmlMultiModule)

docs.dependsOn(subprojects.collect { it.tasks.findByName("dokka")})
docs.dependsOn(renameDokkaRootFile)
3 changes: 1 addition & 2 deletions gradle.properties
Expand Up @@ -7,9 +7,8 @@ groovyVersion=3.0.5
spockVersion=2.0-M3-groovy-3.0

kotlinVersion=1.4.30
# Did not upgrade to 1.4.2 due to https://youtrack.jetbrains.com/issue/KTOR-1286
ktorVersion=1.5.1
dokka_version=0.10.1
dokka_version=1.4.30
junitVersion=5.7.0

title=Micronaut Kotlin Integrations
Expand Down
10 changes: 1 addition & 9 deletions kotlin-extension-functions/build.gradle
Expand Up @@ -2,12 +2,9 @@ buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"
}
}
repositories {
jcenter() // or maven { url 'https://dl.bintray.com/kotlin/dokka' }
jcenter()
}

apply plugin: 'org.jetbrains.dokka'
Expand Down Expand Up @@ -50,9 +47,4 @@ dependencies {

test {
useJUnitPlatform()
}

dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/docs/api"
}
Expand Up @@ -207,7 +207,7 @@ inline fun <reified T> BeanDefinitionRegistry.findBeanDefinition(): BeanDefiniti
* @author Alejandro Gomez
* @since 1.0.0
*/
inline fun <reified T, reified Q : Annotation> BeanDefinitionRegistry.registerStereotypedSingleton(singleton: T, inject: Boolean): BeanDefinitionRegistry =
inline fun <reified T: Any, reified Q : Annotation> BeanDefinitionRegistry.registerStereotypedSingleton(singleton: T, inject: Boolean): BeanDefinitionRegistry =
registerSingleton(T::class.java, singleton, qualifierByStereotype<T, Q>(), inject)

/**
Expand All @@ -220,7 +220,7 @@ inline fun <reified T, reified Q : Annotation> BeanDefinitionRegistry.registerSt
* @author Alejandro Gomez
* @since 1.0.0
*/
inline fun <reified T, reified Q : Annotation> BeanDefinitionRegistry.registerStereotypedSingleton(singleton: T): BeanDefinitionRegistry =
inline fun <reified T: Any, reified Q: Annotation> BeanDefinitionRegistry.registerStereotypedSingleton(singleton: T): BeanDefinitionRegistry =
registerSingleton(T::class.java, singleton, qualifierByStereotype<T, Q>())

/**
Expand All @@ -232,5 +232,5 @@ inline fun <reified T, reified Q : Annotation> BeanDefinitionRegistry.registerSt
* @author Alejandro Gomez
* @since 1.0.0
*/
inline fun <reified T> BeanDefinitionRegistry.registerNotStereotypedSingleton(singleton: T): BeanDefinitionRegistry =
registerSingleton(T::class.java, singleton)
inline fun <reified T: Any> BeanDefinitionRegistry.registerNotStereotypedSingleton(singleton: T): BeanDefinitionRegistry =
registerSingleton(T::class.java, singleton)
Expand Up @@ -20,17 +20,33 @@ import io.micronaut.http.client.BlockingHttpClient

/**
* Shortcut to create an argument of the given type
*
* @param T The argument type
* @return An [Argument<T>]
* @author Will Buck
* @since 1.0.0
*/
inline fun <reified T: Any> argumentOf(): Argument<T> = Argument.of(T::class.java)

/**
* Shortcut to create an argument of a list of the given type
* Shortcut to create an argument of a list the given type
*
* @param T The argument type
* @return An [Argument<List<<T>>]
* @author Will Buck
* @since 1.0.0
*/
inline fun <reified T: Any> argumentOfList(): Argument<List<T>> = Argument.listOf(T::class.java)

/**
* Perform an HTTP request for the given request object emitting the full HTTP response from returned
* Publisher and converting the response body to the specified type.
*
* @param T The argument type
* @param request The [HttpRequest] you want to perform
* @return The response from the client as an instance of T
* @author Will Buck
* @since 1.0.0
*/
// tag::clientFunctionSingle[]
inline fun <reified T: Any> BlockingHttpClient.retrieveObject(request: HttpRequest<Any>): T =
Expand All @@ -40,8 +56,14 @@ inline fun <reified T: Any> BlockingHttpClient.retrieveObject(request: HttpReque
/**
* Perform an HTTP request for the given request object emitting the full HTTP response from returned
* Publisher and converting the response body to a list of the specified type.
*
* @param T The argument type
* @param request The [HttpRequest] you want to perform
* @return The response from the client as an instance of List<T>
* @author Will Buck
* @since 1.0.0
*/
// tag::clientFunctionList[]
inline fun <reified T: Any> BlockingHttpClient.retrieveList(request: HttpRequest<Any>): List<T> =
retrieve(request, argumentOfList<T>())
// end::clientFunctionList[]
// end::clientFunctionList[]
Expand Up @@ -18,7 +18,15 @@ package io.micronaut.runtime
import io.micronaut.context.ApplicationContext

/**
* Top level function acting as a Kotlin shortcut allowing to write `startApplication<Foo>(args) { // Initializer function }`
* instead of `Micronaut.build(*args).mainClass(Foo::class.java).apply({ // Initializer }).start()`.
*
* @param T The application class
* @param args The arguments
* @param initializer Some function you want to apply to the build
* @return The [ApplicationContext]
* @author Will Buck
* @since 2.3.1
*/
// tag:startApplication
inline fun <reified T : Any> startApplication(vararg args: String, initializer: Micronaut.() -> Unit = {}): ApplicationContext {
Expand Down Expand Up @@ -53,7 +61,13 @@ inline fun <reified T> Micronaut.mainClass(): Micronaut = mainClass(T::class.jav

/**
* Extension for [Micronaut.mapError] providing a `mapError<FooException>(mapper)` variant.
*
* @param T The throwable error type
* @param mapper the mapping function
* @return The [Micronaut] entrypoint class
* @author Will Buck
* @since 2.3.1
*/
inline fun <reified T : Throwable> Micronaut.mapError(noinline mapper: (T) -> Int): Micronaut {
return this.mapError(T::class.java, mapper)
}
}
3 changes: 2 additions & 1 deletion kotlin-runtime/build.gradle
@@ -1,4 +1,5 @@
apply plugin:"kotlin-kapt"
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
Expand Down
3 changes: 2 additions & 1 deletion ktor/build.gradle
@@ -1,4 +1,5 @@
apply plugin:"kotlin-kapt"
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
Expand Down
2 changes: 1 addition & 1 deletion src/main/docs/guide/extensionFunctions.adoc
Expand Up @@ -41,7 +41,7 @@ fun main(args: Array<String>) {

NOTE: You will need to import the functions like this: `import io.micronaut.kotlin.FUNCTION_NAME`

Full documentation of the provided extension functions can be found via https://micronaut-projects.github.io/micronaut-kotlin/latest/api/[the dokka docs for this project].
Full documentation of the provided extension functions can be found via https://micronaut-projects.github.io/micronaut-kotlin/latest/api/index.html[the dokka docs for this project].

WARNING: Do be aware when defining extension functions in this project or your own, an extension that shadows a member function may have unexpected behavior, and does not throw a compiler error but rather warns.
See https://discuss.kotlinlang.org/t/why-is-shadowed-extension-not-an-error/7209/11[this Kotlin discussion topic] for the latest information.

0 comments on commit c867af6

Please sign in to comment.