Last active
January 12, 2017 15:51
-
-
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
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
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 |
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
web: java $JAVA_OPTS -cp build/classes/*:build/libs/* app.Main |
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
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!" } | |
} | |
} |
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
.gradle | |
.idea | |
build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment