Skip to content

Instantly share code, notes, and snippets.

@kenichi-odo
Last active January 12, 2017 15:51
Show Gist options
  • Save kenichi-odo/4724fbe3b5a1705331d60f0a12ddd691 to your computer and use it in GitHub Desktop.
Save kenichi-odo/4724fbe3b5a1705331d60f0a12ddd691 to your computer and use it in GitHub Desktop.
Spark Framework + Kotlinで書いたGradleプロジェクトをHerokuにデプロイする ref: http://qiita.com/kenichi_odo/items/e266fbc8cf939feca8b0
apply plugin: 'kotlin'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.0.6'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.sparkjava:spark-core:+'
compile 'org.slf4j:slf4j-simple:+' // Failed to load classで怒られるので入れる
}
// ライブラリのコピー
task copyToLib(type: Copy) {
into "$buildDir/libs"
from(configurations.compile)
}
// Herokuから実行されるタスク
task stage(dependsOn: ['clean', 'build', 'copyToLib'])
build.mustRunAfter clean
web: java $JAVA_OPTS -cp build/classes/*:build/libs/* app.Main
package app
import spark.Spark
import spark.Spark.*
object Main {
@JvmStatic fun main(args: Array<String>) {
System.getenv("PORT")?.let {
Spark.port(it.toInt())
}
get("/") { req, res -> "Hello World!" }
}
}
.gradle
.idea
build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment