1- buildscript {
2- ext.javadocDir = file(" $buildDir /docs/javadoc" )
3- }
1+ import org.jetbrains.dokka.gradle.DokkaTask
2+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+ import java.net.URL
4+
5+ val javadocDir = file(" $buildDir /docs/javadoc" )
46
57plugins {
6- id( " kotlin " )
8+ kotlin( " jvm " )
79 id(" org.jetbrains.dokka" )
810 id(" objectbox-publish" )
911}
1012
1113// Note: use release flag instead of sourceCompatibility and targetCompatibility to ensure only JDK 8 API is used.
1214// https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation
13- tasks.withType( JavaCompile ).configureEach {
15+ tasks.withType< JavaCompile > {
1416 options.release.set(8 )
1517}
1618
17- tasks.withType(org.jetbrains.kotlin.gradle.tasks. KotlinCompile ).configureEach {
19+ tasks.withType< KotlinCompile > {
1820 kotlinOptions {
1921 // Produce Java 8 byte code, would default to Java 6.
2022 jvmTarget = " 1.8"
@@ -28,53 +30,56 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
2830 }
2931}
3032
31- tasks.named(" dokkaHtml" ) {
33+ tasks.named< DokkaTask > (" dokkaHtml" ) {
3234 outputDirectory.set(javadocDir)
3335
34- dokkaSourceSets {
35- configureEach {
36- // Fix "Can't find node by signature": have to manually point to dependencies.
37- // https://github.com/Kotlin/dokka/wiki/faq#dokka-complains-about-cant-find-node-by-signature-
38- externalDocumentationLink {
39- // Point to web javadoc for objectbox-java packages.
40- url.set(new URL (" https://objectbox.io/docfiles/java/current/" ))
41- // Note: Using JDK 9+ package-list is now called element-list.
42- packageListUrl.set(new URL (" https://objectbox.io/docfiles/java/current/element-list" ))
43- }
36+ dokkaSourceSets.configureEach {
37+ // Fix "Can't find node by signature": have to manually point to dependencies.
38+ // https://github.com/Kotlin/dokka/wiki/faq#dokka-complains-about-cant-find-node-by-signature-
39+ externalDocumentationLink {
40+ // Point to web javadoc for objectbox-java packages.
41+ url.set(URL (" https://objectbox.io/docfiles/java/current/" ))
42+ // Note: Using JDK 9+ package-list is now called element-list.
43+ packageListUrl.set(URL (" https://objectbox.io/docfiles/java/current/element-list" ))
4444 }
4545 }
4646}
4747
48- tasks.register( ' javadocJar ' , Jar ) {
49- dependsOn tasks.named(" dokkaHtml" )
50- group = ' build'
51- archiveClassifier.set(' javadoc' )
52- from " $ javadocDir"
48+ val javadocJar by tasks.registering( Jar :: class ) {
49+ dependsOn( tasks.named(" dokkaHtml" ) )
50+ group = " build"
51+ archiveClassifier.set(" javadoc" )
52+ from( javadocDir)
5353}
5454
55- tasks.register( ' sourcesJar ' , Jar ) {
56- group = ' build'
57- archiveClassifier.set(' sources' )
58- from sourceSets.main.allSource
55+ val sourcesJar by tasks.registering( Jar :: class ) {
56+ group = " build"
57+ archiveClassifier.set(" sources" )
58+ from( sourceSets.main.get(). allSource)
5959}
6060
61+ val coroutinesVersion: String by rootProject.extra
62+ val kotlinVersion: String by rootProject.extra
63+
6164dependencies {
62- implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion "
65+ implementation( " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion " )
6366 // Note: compileOnly as we do not want to require library users to use coroutines.
64- compileOnly " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion "
67+ compileOnly( " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
6568
66- api project(' :objectbox-java' )
69+ api( project(" :objectbox-java" ) )
6770}
6871
6972// Set project-specific properties.
70- publishing.publications {
71- mavenJava(MavenPublication ) {
72- from components.java
73- artifact sourcesJar
74- artifact javadocJar
75- pom {
76- name = ' ObjectBox Kotlin'
77- description = ' ObjectBox is a fast NoSQL database for Objects'
73+ publishing {
74+ publications {
75+ getByName<MavenPublication >(" mavenJava" ) {
76+ from(components[" java" ])
77+ artifact(sourcesJar)
78+ artifact(javadocJar)
79+ pom {
80+ name.set(" ObjectBox Kotlin" )
81+ description.set(" ObjectBox is a fast NoSQL database for Objects" )
82+ }
7883 }
7984 }
8085}
0 commit comments