Migrate to Kotlin Gradle DSL

This commit is contained in:
Michael Bull 2018-09-24 22:13:47 +01:00
parent b93dd4457c
commit 80bd9dd692
6 changed files with 156 additions and 123 deletions

View File

@ -1,83 +0,0 @@
plugins {
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.2.70'
id 'org.jetbrains.dokka' version '0.9.17'
id 'com.github.ben-manes.versions' version '0.20.0'
id 'com.jfrog.bintray' version '1.8.4'
id 'net.researchgate.release' version '2.7.0'
}
description = 'A Result monad for modelling success or failure operations.'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation 'junit:junit:4.12'
testImplementation 'org.jetbrains.kotlin:kotlin-test-common'
testImplementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
dokka {
kotlinTasks { [ ] }
sourceDirs = sourceSets.main.kotlin.srcDirs
outputFormat = 'javadoc'
outputDirectory = "${docsDir}/javadoc"
}
task javadocJar(type: Jar, dependsOn: dokka) {
group = LifecycleBasePlugin.BUILD_GROUP
description = 'Assembles a jar archive containing the Javadoc API documentation.'
classifier = 'javadoc'
from dokka.outputDirectory
}
task sourcesJar(type: Jar) {
group = LifecycleBasePlugin.BUILD_GROUP
description = 'Assembles a jar archive containing the main classes with sources.'
classifier = 'sources'
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
}
}
}
bintray {
user = project.findProperty('bintrayUser') ?: ''
key = project.findProperty('bintrayKey') ?: ''
publications = [ 'mavenJava' ]
pkg {
repo = 'maven'
name = 'kotlin-result'
licenses = [ 'ISC' ]
vcsUrl = 'git@github.com:michaelbull/kotlin-result.git'
}
}
bintrayUpload.dependsOn build
bintrayUpload.dependsOn sourcesJar
bintrayUpload.dependsOn javadocJar
bintrayUpload.dependsOn generatePomFileForMavenJavaPublication
afterReleaseBuild.dependsOn bintrayUpload

111
build.gradle.kts Normal file
View File

@ -0,0 +1,111 @@
import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
import groovy.lang.Closure
import org.gradle.api.internal.HasConvention
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
description = "A Result monad for modelling success or failure operations."
plugins {
`maven-publish`
kotlin("jvm") version ("1.2.70")
id("org.jetbrains.dokka") version ("0.9.17")
id("com.github.ben-manes.versions") version ("0.20.0")
id("com.jfrog.bintray") version ("1.8.4")
id("net.researchgate.release") version ("2.7.0")
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("junit:junit:4.12")
testImplementation("org.jetbrains.kotlin:kotlin-test-common")
testImplementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("org.jetbrains.kotlin:kotlin-test")
}
val SourceSet.kotlin: SourceDirectorySet
get() = withConvention(KotlinSourceSet::class) { kotlin }
val compileKotlin by tasks.existing(KotlinCompile::class)
val compileTestKotlin by tasks.existing(KotlinCompile::class)
val dokka by tasks.existing(DokkaTask::class)
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
dokka {
kotlinTasks(closureOf<Any?> { emptyList() })
sourceDirs = sourceSets["main"].kotlin.srcDirs
outputFormat = "javadoc"
outputDirectory = "$buildDir/docs/javadoc"
}
val javadocJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Assembles a jar archive containing the Javadoc API documentation."
classifier = "javadoc"
dependsOn(dokka.get())
from(dokka.get().outputDirectory)
}
val sourcesJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Assembles a jar archive containing the main classes with sources."
classifier = "sources"
from(sourceSets["main"].allSource)
}
publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
artifact(javadocJar.get())
artifact(sourcesJar.get())
}
}
}
bintray {
user = project.findProperty("bintrayUser")?.toString() ?: ""
key = project.findProperty("bintrayKey")?.toString() ?: ""
setPublications("mavenJava")
pkg(closureOf<BintrayExtension.PackageConfig> {
repo = "maven"
name = "kotlin-result"
vcsUrl = "git@github.com:michaelbull/kotlin-result.git"
setLicenses("ISC")
})
}
val build by tasks.existing
val generatePomFileForMavenJavaPublication by tasks.existing(GenerateMavenPom::class)
val bintrayUpload by tasks.existing(BintrayUploadTask::class)
bintrayUpload {
dependsOn(build)
dependsOn(generatePomFileForMavenJavaPublication)
dependsOn(sourcesJar)
dependsOn(javadocJar)
}
val afterReleaseBuild by tasks.existing
afterReleaseBuild {
dependsOn(bintrayUpload)
}

View File

@ -1,35 +0,0 @@
plugins {
id 'application'
id 'org.jetbrains.kotlin.jvm'
}
mainClassName = 'io.ktor.server.netty.DevelopmentEngine'
repositories {
mavenCentral()
maven { url = "http://dl.bintray.com/kotlin/ktor" }
maven { url = "https://dl.bintray.com/kotlin/kotlinx" }
}
dependencies {
implementation project(":")
implementation "ch.qos.logback:logback-classic:$logbackVersion"
implementation "io.ktor:ktor-server-core:$ktorVersion"
implementation "io.ktor:ktor-server-netty:$ktorVersion"
implementation "io.ktor:ktor-gson:$ktorVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}

40
example/build.gradle.kts Normal file
View File

@ -0,0 +1,40 @@
import org.jetbrains.kotlin.gradle.dsl.Coroutines
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
application
kotlin("jvm")
}
application {
mainClassName = "io.ktor.server.netty.DevelopmentEngine"
}
repositories {
maven(url = "http://dl.bintray.com/kotlin/ktor")
maven(url = "https://dl.bintray.com/kotlin/kotlinx")
}
dependencies {
implementation(project(":"))
implementation(kotlin("stdlib-jdk8"))
implementation("ch.qos.logback:logback-classic:${ext["logbackVersion"]}")
implementation("io.ktor:ktor-server-core:${ext["ktorVersion"]}")
implementation("io.ktor:ktor-server-netty:${ext["ktorVersion"]}")
implementation("io.ktor:ktor-gson:${ext["ktorVersion"]}")
}
val compileKotlin by tasks.existing(KotlinCompile::class)
val compileTestKotlin by tasks.existing(KotlinCompile::class)
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental.coroutines = Coroutines.ENABLE
}

View File

@ -1,5 +0,0 @@
rootProject.name = 'kotlin-result'
include 'example'
enableFeaturePreview('STABLE_PUBLISHING')

5
settings.gradle.kts Normal file
View File

@ -0,0 +1,5 @@
enableFeaturePreview("STABLE_PUBLISHING")
rootProject.name = "kotlin-result"
include("example")