This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from rewe-digital-incubator/alexa_plugin
Alexa plugin
- Loading branch information
Showing
31 changed files
with
580 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'kotlin' | ||
apply from: '../docu.gradle' | ||
|
||
group 'org.rewedigital.voice.dialog' | ||
version rootProject.ext.versions.alexa | ||
description 'The Alexa plugin for Dialog to write voice applications for Dialogflow and Alexa.' | ||
|
||
dependencies { | ||
implementation project(":core") | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" | ||
implementation "com.amazon.alexa:ask-sdk-core:2.11.2" | ||
} | ||
|
||
dokka { | ||
externalDocumentationLink { | ||
url = new URL("https://github.com/rewe-digital-incubator/${rootProject.name}/blob/master/docs/core/") | ||
packageListUrl = java.nio.file.Paths.get("$rootDir/docs/core/package-list").toUri().toURL() | ||
} | ||
} | ||
|
||
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { | ||
outputFormat = 'javadoc' | ||
outputDirectory = "$buildDir/javadoc" | ||
} | ||
|
||
apply from: '../publish.gradle' |
19 changes: 19 additions & 0 deletions
19
alexa-plugin/src/main/kotlin/org/rewedigital/dialog/alexa/MultiPlatformIntentHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.rewedigital.dialog.alexa | ||
|
||
import com.amazon.ask.dispatcher.request.handler.HandlerInput | ||
import com.amazon.ask.dispatcher.request.handler.RequestHandler | ||
import com.amazon.ask.model.Response | ||
import org.rewedigital.dialog.handler.DialogflowIntentHandler | ||
import java.util.* | ||
|
||
|
||
interface MultiPlatformIntentHandler : DialogflowIntentHandler, RequestHandler { | ||
|
||
override fun canHandle(input: HandlerInput) = canHandleAlexa(input) | ||
|
||
override fun handle(input: HandlerInput) = handleAlexa(input) | ||
|
||
fun canHandleAlexa(input: HandlerInput): Boolean | ||
|
||
fun handleAlexa(input: HandlerInput): Optional<Response> | ||
} |
13 changes: 13 additions & 0 deletions
13
alexa-plugin/src/main/kotlin/org/rewedigital/dialog/alexa/MultiPlatformRequestInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.rewedigital.dialog.alexa | ||
|
||
import com.amazon.ask.dispatcher.request.handler.HandlerInput | ||
import org.rewedigital.dialog.interceptors.RequestInterceptor | ||
|
||
|
||
interface MultiPlatformRequestInterceptor : RequestInterceptor, | ||
com.amazon.ask.dispatcher.request.interceptor.RequestInterceptor { | ||
|
||
override fun process(input: HandlerInput) = onAlexaRequest(input) | ||
|
||
fun onAlexaRequest(input: HandlerInput) | ||
} |
15 changes: 15 additions & 0 deletions
15
...a-plugin/src/main/kotlin/org/rewedigital/dialog/alexa/MultiPlatformResponseInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.rewedigital.dialog.alexa | ||
|
||
import com.amazon.ask.dispatcher.request.handler.HandlerInput | ||
import com.amazon.ask.model.Response | ||
import org.rewedigital.dialog.interceptors.ResponseInterceptor | ||
import java.util.* | ||
|
||
|
||
interface MultiPlatformResponseInterceptor : ResponseInterceptor, | ||
com.amazon.ask.dispatcher.request.interceptor.ResponseInterceptor { | ||
|
||
override fun process(input: HandlerInput, response: Optional<Response>) = onAlexaResponse(input, response) | ||
|
||
fun onAlexaResponse(input: HandlerInput, response: Optional<Response>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apply plugin: 'kotlin' | ||
apply plugin: 'kotlin-spring' | ||
apply from: '../docu.gradle' | ||
|
||
group 'org.rewedigital.voice.dialog' | ||
version rootProject.ext.versions.alexa | ||
description 'The Alexa plugin for the Spring plugin of Dialog.' | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-allopen:${rootProject.ext.versions.kotlin}") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':core') | ||
implementation project(':alexa-plugin') | ||
implementation project(':spring-plugin') | ||
|
||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' | ||
implementation 'org.jetbrains.kotlin:kotlin-reflect' | ||
implementation 'org.springframework:spring-context:5.1.4.RELEASE' | ||
implementation 'com.amazon.alexa:ask-sdk-core:2.11.2' | ||
} | ||
|
||
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { | ||
outputFormat = 'javadoc' | ||
outputDirectory = "$buildDir/javadoc" | ||
} | ||
|
||
apply from: '../publish.gradle' |
29 changes: 29 additions & 0 deletions
29
...-spring-plugin/src/main/kotlin/org/rewedigital/dialog/alexa/spring/IntentHandlerConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.rewedigital.dialog.alexa.spring | ||
|
||
import com.amazon.ask.dispatcher.request.handler.RequestHandler | ||
import org.rewedigital.dialog.spring.annotations.IntentHandler | ||
import org.springframework.context.ApplicationContext | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import java.lang.instrument.IllegalClassFormatException | ||
|
||
|
||
@Configuration | ||
class IntentHandlerConfig { | ||
|
||
data class IntentHandlerHolder(val intentHandlers: List<RequestHandler>) | ||
|
||
@Bean | ||
fun provideIntentHandlerHolder(context: ApplicationContext): IntentHandlerHolder { | ||
|
||
val allIntentHandler = | ||
context | ||
.getBeanNamesForAnnotation(IntentHandler::class.java) | ||
.map { | ||
context.getBean(it) as? RequestHandler | ||
?: throw IllegalClassFormatException("Your IntentHandler must implement the interface MultiPlatformIntentHandler") | ||
} | ||
|
||
return IntentHandlerHolder(allIntentHandler) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
alexa-spring-plugin/src/main/kotlin/org/rewedigital/dialog/alexa/spring/InterceptorConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.rewedigital.dialog.alexa.spring | ||
|
||
import com.amazon.ask.dispatcher.request.interceptor.RequestInterceptor | ||
import com.amazon.ask.dispatcher.request.interceptor.ResponseInterceptor | ||
import org.rewedigital.dialog.spring.annotations.Interceptor | ||
import org.springframework.context.ApplicationContext | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
|
||
@Configuration | ||
class InterceptorConfig { | ||
|
||
data class InterceptorHolder( | ||
val requestInterceptors: List<RequestInterceptor>, | ||
val responseInterceptors: List<ResponseInterceptor> | ||
) | ||
|
||
@Bean | ||
fun provideInterceptorHolder(context: ApplicationContext): InterceptorHolder { | ||
|
||
val requestInterceptors = mutableListOf<RequestInterceptor>() | ||
val responseInterceptors = mutableListOf<ResponseInterceptor>() | ||
|
||
context.getBeanNamesForAnnotation(Interceptor::class.java) | ||
.forEach { beanName -> | ||
context.getBean(beanName) | ||
.also { bean -> | ||
if (bean is RequestInterceptor) { | ||
requestInterceptors.add(bean) | ||
} | ||
if (bean is ResponseInterceptor) { | ||
responseInterceptors.add(bean) | ||
} | ||
} | ||
} | ||
|
||
return InterceptorHolder(requestInterceptors, responseInterceptors) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
alexa-spring-plugin/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.rewedigital.dialog.alexa.spring.IntentHandlerConfig,org.rewedigital.dialog.alexa.spring.InterceptorConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
apply plugin: 'kotlin' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.novoda.bintray-release' | ||
apply from: '../docu.gradle' | ||
|
||
group "org.rewedigital.voice" | ||
version "${rootProject.ext.versions.core}" | ||
group 'org.rewedigital.voice:dialog' | ||
version rootProject.ext.versions.core | ||
description 'Dialog is a Dialogflow v2 API implementation written in Kotlin. With some great optional extensions you can use to write your own voice applications fast.' | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" | ||
|
@@ -15,71 +14,4 @@ task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { | |
outputDirectory = "$buildDir/javadoc" | ||
} | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
archiveClassifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { | ||
archiveClassifier = 'javadoc' | ||
from "$buildDir/javadoc" | ||
} | ||
|
||
publishing.publications { | ||
core(MavenPublication) { | ||
groupId = "org.rewedigital.voice" | ||
artifactId = "dialog" | ||
version = "${rootProject.ext.versions.core}" | ||
artifact sourcesJar { | ||
archiveClassifier = 'sources' | ||
} | ||
artifact javadocJar { | ||
archiveClassifier = 'javadoc' | ||
} | ||
from components.java | ||
pom { | ||
name = 'dialog' | ||
description = 'Dialog is a Dialogflow v2 API implementation written in Kotlin. With some great optional extensions you can use to write your own voice application fast.' | ||
url = 'https://github.com/rewe-digital-incubator/dialog' | ||
licenses { | ||
license { | ||
name = 'MIT License' | ||
url = 'https://opensource.org/licenses/MIT' | ||
distribution = 'repo' | ||
} | ||
} | ||
developers { | ||
// TODO use the MAINTAINERS file | ||
developer { | ||
name = 'Volkmar Vogel' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
name = 'René Kilczan' | ||
email = '[email protected]' | ||
} | ||
} | ||
|
||
scm { | ||
connection = 'scm:git:git://github.com/rewe-digital-incubator/dialog.git' | ||
developerConnection = 'scm:git:git://github.com/rewe-digital-incubator/dialog.git' | ||
url = 'https://github.com/rewe-digital-incubator/dialog' | ||
} | ||
} | ||
} | ||
} | ||
|
||
publish { | ||
userOrg = 'rewe-digital' | ||
groupId = 'org.rewedigital.voice' | ||
artifactId = 'core' | ||
repoName = 'dialog' | ||
publishVersion = rootProject.ext.versions.core | ||
desc = 'Dialog is a Dialogflow v2 API implementation written in Kotlin. With some great optional extensions you can use to write your own voice applications fast.' | ||
website = 'https://github.com/rewe-digital-incubator/dialog' | ||
licences = ['MIT'] | ||
bintrayUser = project.properties['bintray.user'] | ||
bintrayKey = project.properties['bintray.apikey'] | ||
dryRun = false | ||
publications = ['core'] | ||
} | ||
apply from: '../publish.gradle' |
Oops, something went wrong.