Created
September 21, 2017 08:53
-
-
Save bradynpoulsen/7343d92defa87b8f793910496ce62b4d to your computer and use it in GitHub Desktop.
Gradle build scripts in Kotlin
This file contains hidden or 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
import org.gradle.jvm.tasks.Jar | |
plugins { | |
application | |
kotlin(module = "jvm") | |
} | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
compile(kotlin(module = "stdlib")) | |
compile("com.squareup.okio:okio:1.13.0") | |
} | |
// Define the configuration for the application convention | |
application { | |
mainClassName = "io.bdawg.kotlin.gradlekt.EntrypointKt" | |
} | |
// Defining my own execution task | |
val customRun by tasks.creating(JavaExec::class) { | |
main = "io.bdawg.kotlin.gradlekt.EntrypointKt" | |
classpath = java.sourceSets["main"].runtimeClasspath | |
} | |
// Creating a single fat jar including all dependencies | |
val fatJar by tasks.creating(Jar::class) { | |
baseName = "${project.name}-fat" | |
manifest { | |
attributes["Main-Class"] = "io.bdawg.kotlin.gradlekt.EntrypointKt" | |
} | |
// Import all of our runtime dependencies | |
from(configurations.runtime.map { if (it.isDirectory) it else zipTree(it) }) | |
// Import our project classes using the gradle-provided `jar` task | |
with(tasks["jar"] as CopySpec) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment