Compare commits
No commits in common. "master" and "0.1.4-dep" have entirely different histories.
23 changed files with 314 additions and 585 deletions
17
.build.yml
17
.build.yml
|
@ -1,7 +1,6 @@
|
||||||
image: ubuntu/lts
|
image: alpine/edge
|
||||||
packages:
|
packages:
|
||||||
- openjdk-21-jdk-headless
|
- openjdk11
|
||||||
- rsync
|
|
||||||
secrets:
|
secrets:
|
||||||
- 2c7f4f4a-a9c9-47e2-a432-b8a060d01381
|
- 2c7f4f4a-a9c9-47e2-a432-b8a060d01381
|
||||||
sources:
|
sources:
|
||||||
|
@ -9,14 +8,4 @@ sources:
|
||||||
tasks:
|
tasks:
|
||||||
- test: |
|
- test: |
|
||||||
cd slackbot
|
cd slackbot
|
||||||
./gradlew test
|
./gradlew test
|
||||||
- build: |
|
|
||||||
cd slackbot
|
|
||||||
./gradlew shadowJar
|
|
||||||
- deploy: |
|
|
||||||
cd slackbot
|
|
||||||
sshopts="ssh -o StrictHostKeyChecking=no"
|
|
||||||
ssh -o StrictHostKeyChecking=no slackbot@anthonycicchetti.com mv slackbot.jar slackbot.jar.bak-`date -I`
|
|
||||||
rsync ./build/libs/slackmemes-`cat VERSION`-all.jar slackbot@anthonycicchetti.com:slackbot.jar
|
|
||||||
- restartservice: |
|
|
||||||
ssh slackbot@anthonycicchetti.com sudo /bin/systemctl restart slackbot
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
# Project exclude paths
|
# Project exclude paths
|
||||||
/.gradle/
|
/.gradle/
|
||||||
/build/
|
/build/
|
||||||
/.idea/
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.4.0
|
0.1.4
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.com.gradleup.shadow)
|
id("com.github.johnrengelman.shadow") version Versions.com_github_johnrengelman_shadow_gradle_plugin
|
||||||
alias(libs.plugins.org.jetbrains.kotlin.jvm)
|
id("de.fayard.buildSrcVersions") version Versions.de_fayard_buildsrcversions_gradle_plugin
|
||||||
alias(libs.plugins.org.jetbrains.kotlin.plugin.serialization)
|
kotlin("jvm") version Versions.org_jetbrains_kotlin_jvm_gradle_plugin
|
||||||
application
|
application
|
||||||
`jvm-test-suite`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.anthonycicchetti"
|
group = "com.anthonycicchetti"
|
||||||
|
@ -14,42 +15,29 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
constraints {
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
implementation("org.apache.logging.log4j:log4j-core:_") {
|
implementation(Libs.javalin)
|
||||||
version {
|
implementation(Libs.slf4j_simple)
|
||||||
strictly("[2.17, 3[")
|
implementation(Libs.jackson_databind)
|
||||||
prefer("2.17.0")
|
implementation(Libs.jackson_module_kotlin)
|
||||||
}
|
implementation(Libs.swagger_core)
|
||||||
because("CVE-2021-44228, CVE-2021-45046, CVE-2021-45105: Log4j vulnerable to remote code execution and other critical security vulnerabilities")
|
implementation(Libs.kotlin_openapi3_dsl)
|
||||||
}
|
implementation(Libs.swagger_ui)
|
||||||
}
|
|
||||||
implementation(libs.javalin)
|
|
||||||
implementation(libs.javalin.openapi)
|
|
||||||
implementation(libs.slf4j.simple)
|
|
||||||
implementation(libs.swagger.core)
|
|
||||||
implementation(libs.swagger.ui)
|
|
||||||
implementation(libs.slack.api.model.kotlin.extension)
|
|
||||||
implementation(libs.ktor.client.core)
|
|
||||||
implementation(libs.ktor.client.cio)
|
|
||||||
implementation(KotlinX.serialization.json)
|
|
||||||
|
|
||||||
testImplementation(libs.junit.jupiter)
|
testImplementation(Libs.junit_jupiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set("com.anthonycicchetti.slackbot.MainKt")
|
mainClassName = "com.anthonycicchetti.slackbot.MainKt"
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
tasks.withType<KotlinCompile> {
|
||||||
toolchain {
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
languageVersion = JavaLanguageVersion.of(21)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testing {
|
tasks.withType<Test> {
|
||||||
suites {
|
useJUnitPlatform()
|
||||||
val test by getting(JvmTestSuite::class) {
|
testLogging {
|
||||||
useJUnitJupiter()
|
events("passed", "skipped", "failed")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
buildSrc/.gitignore
vendored
Normal file
3
buildSrc/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
.gradle/
|
||||||
|
build/
|
6
buildSrc/build.gradle.kts
Normal file
6
buildSrc/build.gradle.kts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
0
buildSrc/settings.gradle.kts
Normal file
0
buildSrc/settings.gradle.kts
Normal file
77
buildSrc/src/main/kotlin/Libs.kt
Normal file
77
buildSrc/src/main/kotlin/Libs.kt
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
import kotlin.String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by https://github.com/jmfayard/buildSrcVersions
|
||||||
|
*
|
||||||
|
* Update this file with
|
||||||
|
* `$ ./gradlew buildSrcVersions`
|
||||||
|
*/
|
||||||
|
object Libs {
|
||||||
|
/**
|
||||||
|
* https://kotlinlang.org/
|
||||||
|
*/
|
||||||
|
const val kotlin_scripting_compiler_embeddable: String =
|
||||||
|
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" +
|
||||||
|
Versions.org_jetbrains_kotlin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://kotlinlang.org/
|
||||||
|
*/
|
||||||
|
const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:" +
|
||||||
|
Versions.org_jetbrains_kotlin
|
||||||
|
|
||||||
|
const val com_github_johnrengelman_shadow_gradle_plugin: String =
|
||||||
|
"com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:" +
|
||||||
|
Versions.com_github_johnrengelman_shadow_gradle_plugin
|
||||||
|
|
||||||
|
const val de_fayard_buildsrcversions_gradle_plugin: String =
|
||||||
|
"de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" +
|
||||||
|
Versions.de_fayard_buildsrcversions_gradle_plugin
|
||||||
|
|
||||||
|
const val org_jetbrains_kotlin_jvm_gradle_plugin: String =
|
||||||
|
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:" +
|
||||||
|
Versions.org_jetbrains_kotlin_jvm_gradle_plugin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/FasterXML/jackson-module-kotlin
|
||||||
|
*/
|
||||||
|
const val jackson_module_kotlin: String =
|
||||||
|
"com.fasterxml.jackson.module:jackson-module-kotlin:" + Versions.jackson_module_kotlin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/derveloper/kotlin-openapi3-dsl
|
||||||
|
*/
|
||||||
|
const val kotlin_openapi3_dsl: String = "cc.vileda:kotlin-openapi3-dsl:" +
|
||||||
|
Versions.kotlin_openapi3_dsl
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://github.com/FasterXML/jackson
|
||||||
|
*/
|
||||||
|
const val jackson_databind: String = "com.fasterxml.jackson.core:jackson-databind:" +
|
||||||
|
Versions.jackson_databind
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://junit.org/junit5/
|
||||||
|
*/
|
||||||
|
const val junit_jupiter: String = "org.junit.jupiter:junit-jupiter:" + Versions.junit_jupiter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://www.slf4j.org
|
||||||
|
*/
|
||||||
|
const val slf4j_simple: String = "org.slf4j:slf4j-simple:" + Versions.slf4j_simple
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/swagger-api/swagger-core
|
||||||
|
*/
|
||||||
|
const val swagger_core: String = "io.swagger.core.v3:swagger-core:" + Versions.swagger_core
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://webjars.org
|
||||||
|
*/
|
||||||
|
const val swagger_ui: String = "org.webjars:swagger-ui:" + Versions.swagger_ui
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://javalin.io
|
||||||
|
*/
|
||||||
|
const val javalin: String = "io.javalin:javalin:" + Versions.javalin
|
||||||
|
}
|
54
buildSrc/src/main/kotlin/Versions.kt
Normal file
54
buildSrc/src/main/kotlin/Versions.kt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import kotlin.String
|
||||||
|
import org.gradle.plugin.use.PluginDependenciesSpec
|
||||||
|
import org.gradle.plugin.use.PluginDependencySpec
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by https://github.com/jmfayard/buildSrcVersions
|
||||||
|
*
|
||||||
|
* Find which updates are available by running
|
||||||
|
* `$ ./gradlew buildSrcVersions`
|
||||||
|
* This will only update the comments.
|
||||||
|
*
|
||||||
|
* YOU are responsible for updating manually the dependency version.
|
||||||
|
*/
|
||||||
|
object Versions {
|
||||||
|
const val org_jetbrains_kotlin: String = "1.3.61" // available: "1.3.61"
|
||||||
|
|
||||||
|
const val com_github_johnrengelman_shadow_gradle_plugin: String = "5.2.0"
|
||||||
|
// available: "5.2.0"
|
||||||
|
|
||||||
|
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0"
|
||||||
|
|
||||||
|
const val org_jetbrains_kotlin_jvm_gradle_plugin: String = "1.3.61" // available: "1.3.61"
|
||||||
|
|
||||||
|
const val jackson_module_kotlin: String = "2.10.1" // available: "2.10.1"
|
||||||
|
|
||||||
|
const val kotlin_openapi3_dsl: String = "0.20.2"
|
||||||
|
|
||||||
|
const val jackson_databind: String = "2.10.1" // available: "2.10.1"
|
||||||
|
|
||||||
|
const val junit_jupiter: String = "5.5.2"
|
||||||
|
|
||||||
|
const val slf4j_simple: String = "1.7.30" // available: "1.7.30"
|
||||||
|
|
||||||
|
const val swagger_core: String = "2.1.0" // available: "2.1.0"
|
||||||
|
|
||||||
|
const val swagger_ui: String = "3.24.3" // available: "3.24.3"
|
||||||
|
|
||||||
|
const val javalin: String = "3.6.0" // available: "3.6.0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current version: "5.6.2"
|
||||||
|
* See issue 19: How to update Gradle itself?
|
||||||
|
* https://github.com/jmfayard/buildSrcVersions/issues/19
|
||||||
|
*/
|
||||||
|
const val gradleLatestVersion: String = "6.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See issue #47: how to update buildSrcVersions itself
|
||||||
|
* https://github.com/jmfayard/buildSrcVersions/issues/47
|
||||||
|
*/
|
||||||
|
val PluginDependenciesSpec.buildSrcVersions: PluginDependencySpec
|
||||||
|
inline get() =
|
||||||
|
id("de.fayard.buildSrcVersions").version(Versions.de_fayard_buildsrcversions_gradle_plugin)
|
|
@ -1,165 +0,0 @@
|
||||||
## Generated by $ ./gradlew refreshVersionsCatalog
|
|
||||||
|
|
||||||
[plugins]
|
|
||||||
|
|
||||||
org-jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
org-jetbrains-kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
org-gradle-kotlin-kotlin-dsl = { id = "org.gradle.kotlin.kotlin-dsl", version = "5.1.2" }
|
|
||||||
|
|
||||||
com-gradleup-shadow = { id = "com.gradleup.shadow", version = "9.0.0-beta8" }
|
|
||||||
|
|
||||||
[versions]
|
|
||||||
|
|
||||||
kotlin = "2.1.10"
|
|
||||||
## ⬆ = "2.1.20-Beta1"
|
|
||||||
## ⬆ = "2.1.20-Beta2"
|
|
||||||
|
|
||||||
ktor = "3.1.0"
|
|
||||||
|
|
||||||
kotlinx-serialization = "1.8.0"
|
|
||||||
|
|
||||||
junit-jupiter = "5.11.4"
|
|
||||||
## ⬆ = "5.12.0-M1"
|
|
||||||
## ⬆ = "5.12.0-RC1"
|
|
||||||
## ⬆ = "5.12.0-RC2"
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
|
|
||||||
javalin = "io.javalin:javalin:4.6.8"
|
|
||||||
## ⬆ :5.0.0.RC0"
|
|
||||||
## ⬆ :5.0.0.RC1"
|
|
||||||
## ⬆ :5.0.0.RC2"
|
|
||||||
## ⬆ :5.0.0"
|
|
||||||
## ⬆ :5.0.1"
|
|
||||||
## ⬆ :5.1.0"
|
|
||||||
## ⬆ :5.1.1"
|
|
||||||
## ⬆ :5.1.2"
|
|
||||||
## ⬆ :5.1.3"
|
|
||||||
## ⬆ :5.1.4"
|
|
||||||
## ⬆ :5.2.0"
|
|
||||||
## ⬆ :5.3.0"
|
|
||||||
## ⬆ :5.3.1"
|
|
||||||
## ⬆ :5.3.2"
|
|
||||||
## ⬆ :5.4.0"
|
|
||||||
## ⬆ :5.4.1"
|
|
||||||
## ⬆ :5.4.2"
|
|
||||||
## ⬆ :5.5.0"
|
|
||||||
## ⬆ :5.6.0"
|
|
||||||
## ⬆ :5.6.1"
|
|
||||||
## ⬆ :5.6.2"
|
|
||||||
## ⬆ :5.6.3"
|
|
||||||
## ⬆ :5.6.4"
|
|
||||||
## ⬆ :5.6.5"
|
|
||||||
## ⬆ :6.0.0-beta.1"
|
|
||||||
## ⬆ :6.0.0-beta.2"
|
|
||||||
## ⬆ :6.0.0-beta.3"
|
|
||||||
## ⬆ :6.0.0-beta.4"
|
|
||||||
## ⬆ :6.0.0"
|
|
||||||
## ⬆ :6.0.1"
|
|
||||||
## ⬆ :6.1.0"
|
|
||||||
## ⬆ :6.1.1"
|
|
||||||
## ⬆ :6.1.2"
|
|
||||||
## ⬆ :6.1.3"
|
|
||||||
## ⬆ :6.1.4"
|
|
||||||
## ⬆ :6.1.6"
|
|
||||||
## ⬆ :6.2.0"
|
|
||||||
## ⬆ :6.3.0"
|
|
||||||
## ⬆ :6.4.0"
|
|
||||||
|
|
||||||
javalin-openapi = "io.javalin:javalin-openapi:4.6.8"
|
|
||||||
|
|
||||||
slf4j-simple = "org.slf4j:slf4j-simple:1.7.36"
|
|
||||||
## ⬆ :1.8.0-alpha0"
|
|
||||||
## ⬆ :1.8.0-alpha1"
|
|
||||||
## ⬆ :1.8.0-alpha2"
|
|
||||||
## ⬆ :1.8.0-beta0"
|
|
||||||
## ⬆ :1.8.0-beta1"
|
|
||||||
## ⬆ :1.8.0-beta2"
|
|
||||||
## ⬆ :1.8.0-beta4"
|
|
||||||
## ⬆ :2.0.0-alpha0"
|
|
||||||
## ⬆ :2.0.0-alpha1"
|
|
||||||
## ⬆ :2.0.0-alpha2"
|
|
||||||
## ⬆ :2.0.0-alpha3"
|
|
||||||
## ⬆ :2.0.0-alpha4"
|
|
||||||
## ⬆ :2.0.0-alpha5"
|
|
||||||
## ⬆ :2.0.0-alpha6"
|
|
||||||
## ⬆ :2.0.0-alpha7"
|
|
||||||
## ⬆ :2.0.0-beta0"
|
|
||||||
## ⬆ :2.0.0-beta1"
|
|
||||||
## ⬆ :2.0.0"
|
|
||||||
## ⬆ :2.0.1"
|
|
||||||
## ⬆ :2.0.2"
|
|
||||||
## ⬆ :2.0.3"
|
|
||||||
## ⬆ :2.0.4"
|
|
||||||
## ⬆ :2.0.5"
|
|
||||||
## ⬆ :2.0.6"
|
|
||||||
## ⬆ :2.0.7"
|
|
||||||
## ⬆ :2.0.8"
|
|
||||||
## ⬆ :2.0.9"
|
|
||||||
## ⬆ :2.0.10"
|
|
||||||
## ⬆ :2.0.11"
|
|
||||||
## ⬆ :2.0.12"
|
|
||||||
## ⬆ :2.0.13"
|
|
||||||
## ⬆ :2.0.14"
|
|
||||||
## ⬆ :2.0.15"
|
|
||||||
## ⬆ :2.0.16"
|
|
||||||
## ⬆ :2.1.0-alpha0"
|
|
||||||
## ⬆ :2.1.0-alpha1"
|
|
||||||
|
|
||||||
swagger-core = "io.swagger.core.v3:swagger-core:2.2.28"
|
|
||||||
|
|
||||||
swagger-ui = "org.webjars:swagger-ui:4.19.1"
|
|
||||||
## ⬆ :5.0.0"
|
|
||||||
## ⬆ :5.1.0"
|
|
||||||
## ⬆ :5.1.2"
|
|
||||||
## ⬆ :5.1.3"
|
|
||||||
## ⬆ :5.2.0"
|
|
||||||
## ⬆ :5.3.1"
|
|
||||||
## ⬆ :5.4.2"
|
|
||||||
## ⬆ :5.5.0"
|
|
||||||
## ⬆ :5.6.1"
|
|
||||||
## ⬆ :5.7.2"
|
|
||||||
## ⬆ :5.9.0"
|
|
||||||
## ⬆ :5.10.3"
|
|
||||||
## ⬆ :5.11.8"
|
|
||||||
## ⬆ :5.11.9"
|
|
||||||
## ⬆ :5.11.10"
|
|
||||||
## ⬆ :5.12.0"
|
|
||||||
## ⬆ :5.12.2"
|
|
||||||
## ⬆ :5.13.0"
|
|
||||||
## ⬆ :5.14.0"
|
|
||||||
## ⬆ :5.15.0"
|
|
||||||
## ⬆ :5.15.1"
|
|
||||||
## ⬆ :5.15.2"
|
|
||||||
## ⬆ :5.15.2-1"
|
|
||||||
## ⬆ :5.17.0"
|
|
||||||
## ⬆ :5.17.1"
|
|
||||||
## ⬆ :5.17.2"
|
|
||||||
## ⬆ :5.17.6"
|
|
||||||
## ⬆ :5.17.7"
|
|
||||||
## ⬆ :5.17.11"
|
|
||||||
## ⬆ :5.17.14"
|
|
||||||
## ⬆ :5.18.0"
|
|
||||||
## ⬆ :5.18.1"
|
|
||||||
## ⬆ :5.18.2"
|
|
||||||
## ⬆ :5.18.3"
|
|
||||||
|
|
||||||
slack-api-model-kotlin-extension = "com.slack.api:slack-api-model-kotlin-extension:1.45.2"
|
|
||||||
|
|
||||||
kotlin-build-tools-impl = { module = "org.jetbrains.kotlin:kotlin-build-tools-impl" }
|
|
||||||
|
|
||||||
kotlin-scripting-compiler-embeddable = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-compiler-embeddable", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
kotlin-serialization-compiler-plugin-embeddable = { group = "org.jetbrains.kotlin", name = "kotlin-serialization-compiler-plugin-embeddable", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }
|
|
||||||
|
|
||||||
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
|
|
||||||
|
|
||||||
ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
|
|
||||||
|
|
||||||
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
|
||||||
|
|
||||||
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit-jupiter" }
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
266
gradlew
vendored
266
gradlew
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -17,113 +17,78 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
@ -132,7 +97,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
@ -140,101 +105,84 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
warn "Could not query maximum file descriptor limit"
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
esac
|
fi
|
||||||
case $MAX_FD in #(
|
ulimit -n $MAX_FD
|
||||||
'' | soft) :;; #(
|
if [ $? -ne 0 ] ; then
|
||||||
*)
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
ulimit -n "$MAX_FD" ||
|
fi
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
else
|
||||||
esac
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
SEP=""
|
||||||
for arg do
|
for dir in $ROOTDIRSRAW ; do
|
||||||
if
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
case $arg in #(
|
SEP="|"
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Escape application args
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
save () {
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
# double quotes to make sure that they get re-expanded; and
|
echo " "
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
set -- \
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
then
|
cd "$(dirname "$0")"
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
37
gradlew.bat
vendored
37
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -25,13 +25,10 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@ -40,7 +37,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -54,7 +51,7 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
@ -64,26 +61,38 @@ echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
|
@ -0,0 +1 @@
|
||||||
|
rootProject.name = 'slackmemes'
|
|
@ -1,19 +0,0 @@
|
||||||
rootProject.name = "slackmemes"
|
|
||||||
|
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
plugins {
|
|
||||||
id("de.fayard.refreshVersions") version "0.60.5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("de.fayard.refreshVersions")
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshVersions {
|
|
||||||
file("build/tmp/refreshVersions").mkdirs()
|
|
||||||
versionsPropertiesFile = file("build/tmp/refreshVersions/versions.properties")
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.anthonycicchetti.slackbot
|
package com.anthonycicchetti.slackbot
|
||||||
|
|
||||||
import com.anthonycicchetti.slackbot.osrs.ApiItem
|
import com.anthonycicchetti.slackbot.utility.Commands
|
||||||
import com.anthonycicchetti.slackbot.osrs.getOsrsItemPrice
|
import com.anthonycicchetti.slackbot.utility.RespObj
|
||||||
import com.anthonycicchetti.slackbot.osrs.getOsrsItemByName
|
import com.anthonycicchetti.slackbot.utility.TextResponse
|
||||||
import com.anthonycicchetti.slackbot.utility.*
|
|
||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import io.javalin.Javalin
|
import io.javalin.Javalin
|
||||||
import io.javalin.plugin.openapi.OpenApiOptions
|
import io.javalin.plugin.openapi.OpenApiOptions
|
||||||
|
@ -14,9 +13,7 @@ import io.javalin.plugin.openapi.ui.SwaggerOptions
|
||||||
import io.swagger.v3.oas.models.OpenAPI
|
import io.swagger.v3.oas.models.OpenAPI
|
||||||
import io.swagger.v3.oas.models.info.Info
|
import io.swagger.v3.oas.models.info.Info
|
||||||
import io.swagger.v3.oas.models.servers.Server
|
import io.swagger.v3.oas.models.servers.Server
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.util.*
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
|
@ -26,9 +23,9 @@ fun main() {
|
||||||
config.registerPlugin(OpenApiPlugin(createOpenApiOptions()))
|
config.registerPlugin(OpenApiPlugin(createOpenApiOptions()))
|
||||||
config.enableWebjars()
|
config.enableWebjars()
|
||||||
config.enableCorsForAllOrigins()
|
config.enableCorsForAllOrigins()
|
||||||
config.requestLogger { ctx, ms ->
|
config.requestLogger {ctx, ms ->
|
||||||
logger.info("Took ${ms.roundToInt()} to process ${ctx.req.requestURL}")
|
logger.info("Took ${ms.roundToInt()} to process ${ctx.req.requestURL}")
|
||||||
}
|
}
|
||||||
}.start(7000)
|
}.start(7000)
|
||||||
with(app) {
|
with(app) {
|
||||||
options("/*", documented(document().ignore()) {})
|
options("/*", documented(document().ignore()) {})
|
||||||
|
@ -55,32 +52,16 @@ fun main() {
|
||||||
it.summary = "POST for UPPERCASING"
|
it.summary = "POST for UPPERCASING"
|
||||||
}.body<String>().json<TextResponse>("200")) { ctx ->
|
}.body<String>().json<TextResponse>("200")) { ctx ->
|
||||||
logger.info("Uppercase: Received request from ${ctx.req.requestURL}")
|
logger.info("Uppercase: Received request from ${ctx.req.requestURL}")
|
||||||
ctx.json(TextResponse(200, ctx.body().uppercase(Locale.getDefault())))
|
ctx.json(TextResponse(200, ctx.body().toUpperCase()))
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/api/v1/claptext", documented(document().operation {
|
post("/api/v1/claptext", documented(document().operation {
|
||||||
it.description = "Responds \uD83D\uDC4F with \uD83D\uDC4F the \uD83D\uDC4F claptext \uD83D\uDC4F version"
|
it.description = "Responds \uD83D\uDC4F with \uD83D\uDC4F the \uD83D\uDC4F claptext \uD83D\uDC4F version"
|
||||||
it.summary = "POST \uD83D\uDC4F for \uD83D\uDC4F claptext"
|
it.summary = "POST \uD83D\uDC4F for \uD83D\uDC4F claptext"
|
||||||
}.body<String>().json<TextResponse>("200")) { ctx ->
|
}.body<String>().json<TextResponse>("200")) {ctx ->
|
||||||
logger.info("Claptext: Received request from ${ctx.req.requestURL}")
|
logger.info("Claptext: Received request from ${ctx.req.requestURL}")
|
||||||
ctx.json(TextResponse(200, ctx.body().toClapText()))
|
ctx.json(TextResponse(200, ctx.body().toClapText()))
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/api/v1/osrsitem", documented(document().operation {
|
|
||||||
it.description = "Accepts an OSRS item name and searches for its prices on the wiki"
|
|
||||||
it.summary = "POST for OSRS Price"
|
|
||||||
}.body<String>().json<BlockResponse>("200")) { ctx ->
|
|
||||||
runBlocking {
|
|
||||||
logger.info("OSRS Item: Received request for ${ctx.body()}")
|
|
||||||
val item: ApiItem? = getOsrsItemByName(ctx.body())
|
|
||||||
if (item == null) {
|
|
||||||
ctx.json(notFoundItem)
|
|
||||||
} else {
|
|
||||||
val itemPrices = getOsrsItemPrice(item)
|
|
||||||
ctx.json((BlockResponse(200, item.name, itemPrices.high, itemPrices.low)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +98,6 @@ private fun String?.processToCommand(): Commands {
|
||||||
"/spongemock2" -> Commands.Spongebob
|
"/spongemock2" -> Commands.Spongebob
|
||||||
"/uppercase" -> Commands.Uppercase
|
"/uppercase" -> Commands.Uppercase
|
||||||
"/clapback" -> Commands.Claptext
|
"/clapback" -> Commands.Claptext
|
||||||
"/osrsitem" -> Commands.OsrsItem
|
|
||||||
else -> Commands.Error
|
else -> Commands.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,28 +109,12 @@ private fun sendResponse(ctx: Context, respObj: RespObj) {
|
||||||
Commands.Spongebob -> {
|
Commands.Spongebob -> {
|
||||||
put("text", respObj.text.toSpongemock()); put("response_type", "in_channel")
|
put("text", respObj.text.toSpongemock()); put("response_type", "in_channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands.Uppercase -> {
|
Commands.Uppercase -> {
|
||||||
put("text", respObj.text.uppercase(Locale.getDefault())); put("response_type", "in_channel")
|
put("text", respObj.text.toUpperCase()); put("response_type", "in_channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands.Claptext -> {
|
Commands.Claptext -> {
|
||||||
put("text", respObj.text.toClapText()); put("response_type", "in_channel")
|
put("text", respObj.text.toClapText()); put("response_type", "in_channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands.OsrsItem -> runBlocking {
|
|
||||||
val item = getOsrsItemByName(respObj.text)
|
|
||||||
val itemPricesBlock: BlockResponse = if (item == null) {
|
|
||||||
notFoundItem
|
|
||||||
} else {
|
|
||||||
val itemPrices = getOsrsItemPrice(item)
|
|
||||||
BlockResponse(200, item.name, itemPrices.high, itemPrices.low)
|
|
||||||
}
|
|
||||||
val logger = LoggerFactory.getLogger("sendResponse")
|
|
||||||
logger.info(itemPricesBlock.response)
|
|
||||||
put("blocks", itemPricesBlock.response); put("response_type", "in_channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
Commands.Error -> {
|
Commands.Error -> {
|
||||||
put("text", respObj.text); put("response_type", "ephemeral")
|
put("text", respObj.text); put("response_type", "ephemeral")
|
||||||
}
|
}
|
||||||
|
@ -163,7 +127,7 @@ private fun sendResponse(ctx: Context, respObj: RespObj) {
|
||||||
private fun createOpenApiOptions(): OpenApiOptions {
|
private fun createOpenApiOptions(): OpenApiOptions {
|
||||||
val o = {
|
val o = {
|
||||||
OpenAPI()
|
OpenAPI()
|
||||||
.info(Info().version("0.3.0").description("Slackbot Open API documentation"))
|
.info(Info().version("0.1.2").description("Slackbot Open API documentation"))
|
||||||
.addServersItem(Server().url("https://acicchetti.dev/"))
|
.addServersItem(Server().url("https://acicchetti.dev/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,17 @@ fun String.toSpongemock(): String {
|
||||||
.map { word ->
|
.map { word ->
|
||||||
word.mapIndexed { index, char ->
|
word.mapIndexed { index, char ->
|
||||||
if (!index.isOdd()) {
|
if (!index.isOdd()) {
|
||||||
char.uppercaseChar()
|
char.toUpperCase()
|
||||||
} else {
|
} else {
|
||||||
char.lowercaseChar()
|
char.toLowerCase()
|
||||||
}
|
}
|
||||||
}.joinToString("")
|
}.joinToString("")
|
||||||
}.joinToString(" ")
|
}.joinToString(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toClapText(): String {
|
fun String.toClapText(): String {
|
||||||
with(
|
with(this
|
||||||
this
|
.split(' ')) {
|
||||||
.split(' ')
|
|
||||||
) {
|
|
||||||
if (this.size == 1) {
|
if (this.size == 1) {
|
||||||
return "\uD83D\uDC4F ${this[0]} \uD83D\uDC4F"
|
return "\uD83D\uDC4F ${this[0]} \uD83D\uDC4F"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
package com.anthonycicchetti.slackbot.osrs
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import io.ktor.client.*
|
|
||||||
import io.ktor.client.request.*
|
|
||||||
import io.ktor.client.statement.*
|
|
||||||
import io.ktor.client.call.*
|
|
||||||
import io.ktor.client.engine.cio.*
|
|
||||||
import io.ktor.client.plugins.*
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import org.slf4j.Logger
|
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
|
|
||||||
val logger: Logger by lazy { LoggerFactory.getLogger("ItemMapper") }
|
|
||||||
val mapper: ObjectMapper by lazy { ObjectMapper() }
|
|
||||||
|
|
||||||
val client = HttpClient(CIO) {
|
|
||||||
install(UserAgent) {
|
|
||||||
agent = "private_slackbot - @AnthonyCicc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun getItemList(): List<ApiItem> {
|
|
||||||
val response = client.get("https://prices.runescape.wiki/api/v1/osrs/mapping")
|
|
||||||
return when (response.status.value) {
|
|
||||||
in 200..299 -> {
|
|
||||||
logger.info("Got item mappings")
|
|
||||||
Json.decodeFromString(response.body())
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
logger.info("Could not get item mappings")
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun getOsrsItemByName(itemName: String): ApiItem? =
|
|
||||||
getItemList().firstOrNull { item: ApiItem -> item.name.lowercase() == itemName.lowercase() }
|
|
||||||
|
|
||||||
suspend fun getOsrsItemPrice(item: ApiItem): Item {
|
|
||||||
val response = client
|
|
||||||
.get("https://prices.runescape.wiki/api/v1/osrs/latest")
|
|
||||||
return when (response.status.value) {
|
|
||||||
in 200..299 -> {
|
|
||||||
val r: Resp = Json.decodeFromString(response.body())
|
|
||||||
r.data.getOrDefault(item.id.toString(), Item())
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
logger.warn("Couldn't find Item with ID ${item.id}")
|
|
||||||
Item()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
private data class Resp(
|
|
||||||
val data: Map<String, Item> = emptyMap(),
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class Item(
|
|
||||||
val low: Int = 0,
|
|
||||||
val lowTime: Long = 0L,
|
|
||||||
val high: Int = 0,
|
|
||||||
val highTime: Long = 0L,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ApiItem(
|
|
||||||
val examine: String = "Empty Examine Text",
|
|
||||||
val id: Int = 0,
|
|
||||||
val members: Boolean = false,
|
|
||||||
val lowalch: Int = 0,
|
|
||||||
val limit: Int = 0,
|
|
||||||
val highalch: Int = 0,
|
|
||||||
val name: String = "Empty Name",
|
|
||||||
val value: Int = 0,
|
|
||||||
) {
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.anthonycicchetti.slackbot.utility
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
|
||||||
import com.slack.api.model.kotlin_extension.block.withBlocks
|
|
||||||
import java.text.NumberFormat
|
|
||||||
|
|
||||||
data class BlockResponse(val status: Int = 200, val itemName: String, val highVal: Int, val lowVal: Int) {
|
|
||||||
val response: String
|
|
||||||
init {
|
|
||||||
val mapper = ObjectMapper()
|
|
||||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
|
||||||
val resp = run {
|
|
||||||
withBlocks {
|
|
||||||
section { markdownText("Item Found: ${itemName}") }
|
|
||||||
divider()
|
|
||||||
section { markdownText(":chart_with_upwards_trend:: ${NumberFormat.getNumberInstance().format(highVal)}") }
|
|
||||||
section { markdownText(":chart_with_downwards_trend:: ${NumberFormat.getNumberInstance().format(lowVal)}") }
|
|
||||||
divider()
|
|
||||||
section { markdownText("<https://oldschool.runescape.wiki/?search=${itemName.replace(' ', '+')}&title=Special%3ASearch&go=Go|Wiki Search>")}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response = mapper.writeValueAsString(resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val notFoundItem = BlockResponse(200, "Item Not Found", 0, 0 )
|
|
|
@ -12,6 +12,5 @@ sealed class Commands {
|
||||||
object Spongebob : Commands()
|
object Spongebob : Commands()
|
||||||
object Uppercase : Commands()
|
object Uppercase : Commands()
|
||||||
object Claptext : Commands()
|
object Claptext : Commands()
|
||||||
object OsrsItem : Commands()
|
|
||||||
object Error : Commands()
|
object Error : Commands()
|
||||||
}
|
}
|
|
@ -66,8 +66,7 @@ internal class TransformationsTest {
|
||||||
@Test
|
@Test
|
||||||
fun `Claptext works with multiple words`() {
|
fun `Claptext works with multiple words`() {
|
||||||
val actual = "Find a dentist in Boston your a grown man"
|
val actual = "Find a dentist in Boston your a grown man"
|
||||||
val expected =
|
val expected = "Find \uD83D\uDC4F a \uD83D\uDC4F dentist \uD83D\uDC4F in \uD83D\uDC4F Boston \uD83D\uDC4F your \uD83D\uDC4F a \uD83D\uDC4F grown \uD83D\uDC4F man"
|
||||||
"Find \uD83D\uDC4F a \uD83D\uDC4F dentist \uD83D\uDC4F in \uD83D\uDC4F Boston \uD83D\uDC4F your \uD83D\uDC4F a \uD83D\uDC4F grown \uD83D\uDC4F man"
|
|
||||||
|
|
||||||
assertEquals(expected, actual.toClapText())
|
assertEquals(expected, actual.toClapText())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue