Skip to content

Commit fb75e96

Browse files
authored
Update gradle scripts to Kotlin DSL (#27)
1 parent 5ff9a56 commit fb75e96

File tree

23 files changed

+598
-590
lines changed

23 files changed

+598
-590
lines changed

build.gradle

Lines changed: 0 additions & 90 deletions
This file was deleted.

build.gradle.kts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import org.jetbrains.dokka.gradle.DokkaTask
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
/*
5+
* Copyright 2020 Appmattus Limited
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
plugins {
21+
kotlin("jvm") version "1.3.72" apply false
22+
kotlin("plugin.serialization") version "1.3.72"
23+
id("org.jetbrains.dokka") version "0.10.1"
24+
}
25+
26+
buildscript {
27+
repositories {
28+
google()
29+
}
30+
dependencies {
31+
classpath("com.android.tools.build:gradle:4.0.1")
32+
}
33+
}
34+
35+
subprojects {
36+
repositories {
37+
google()
38+
jcenter()
39+
mavenCentral()
40+
}
41+
42+
tasks.withType<KotlinCompile> {
43+
kotlinOptions {
44+
jvmTarget = "1.8"
45+
allWarningsAsErrors = true
46+
}
47+
}
48+
}
49+
50+
tasks.register<Delete>("clean") {
51+
delete(rootProject.buildDir)
52+
}
53+
54+
apply(from = "$rootDir/gradle/scripts/detekt.gradle.kts")
55+
apply(from = "$rootDir/gradle/scripts/dependencyUpdates.gradle.kts")
56+
57+
val dokka = tasks.named<DokkaTask>("dokka") {
58+
outputFormat = "html"
59+
outputDirectory = "$buildDir/reports/dokka"
60+
61+
subProjects = listOf(
62+
"layercache",
63+
"layercache-cache2k",
64+
"layercache-ehcache",
65+
"layercache-serializer",
66+
"layercache-android",
67+
"layercache-android-encryption",
68+
"layercache-android-livedata"
69+
)
70+
71+
configuration {
72+
skipDeprecated = true
73+
74+
sourceLink {
75+
path = "$rootDir"
76+
url = "https://github.com/appmattus/layercache/blob/main/"
77+
lineSuffix = "#L"
78+
}
79+
}
80+
}
81+
82+
tasks.register("check") {
83+
finalizedBy(dokka)
84+
}

dokka.gradle

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,26 @@
1414
* limitations under the License.
1515
*/
1616

17-
apply plugin: 'org.jetbrains.dokka'
17+
import org.jetbrains.dokka.gradle.DokkaPlugin
18+
import org.jetbrains.dokka.gradle.DokkaTask
1819

19-
dokka {
20-
outputFormat = 'html'
21-
//noinspection GroovyAssignabilityCheck
22-
outputDirectory = "$buildDir/docs/javadoc"
20+
buildscript {
21+
repositories {
22+
jcenter()
23+
}
24+
dependencies {
25+
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1")
26+
}
27+
}
28+
29+
apply<DokkaPlugin>()
30+
31+
val dokka = tasks.named<DokkaTask>("dokka") {
32+
outputFormat = "html"
33+
outputDirectory = "$buildDir/reports/dokka"
2334

2435
configuration {
25-
cacheRoot = 'default'
36+
cacheRoot = "default"
2637
skipDeprecated = true
2738

2839
sourceLink {
@@ -33,7 +44,9 @@ dokka {
3344
}
3445
}
3546

36-
task dokkaJar(type: Jar, dependsOn: dokka) {
47+
tasks.register<Jar>("dokkaJar") {
48+
dependsOn(dokka)
49+
3750
archiveClassifier.set("javadoc")
38-
from "$buildDir/docs/javadoc"
51+
from("$buildDir/reports/dokka")
3952
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2020 Appmattus Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply<JacocoPlugin>()
18+
19+
val jacocoTask = tasks.register<JacocoReport>("jacocoTestReport") {
20+
dependsOn(tasks.named("testDebugUnitTest"))
21+
22+
reports {
23+
html.isEnabled = true
24+
xml.isEnabled = true
25+
csv.isEnabled = false
26+
}
27+
28+
val fileFilter = listOf(
29+
"**/R.class", "**/R\$*.class", "**/BuildConfig.*", "**/Manifest*.*", "**/*Test*.*",
30+
"android/**/*.*"
31+
)
32+
val debugTree = fileTree("${project.buildDir}/intermediates/javac/debug") {
33+
exclude(fileFilter)
34+
}
35+
36+
val mainSrc = "${project.projectDir}/src/main/kotlin"
37+
38+
sourceDirectories.setFrom(files(listOf(mainSrc)))
39+
classDirectories.setFrom(files(listOf(debugTree)))
40+
executionData.setFrom(fileTree(project.buildDir) {
41+
include(listOf("jacoco/testDebugUnitTest.exec"))
42+
})
43+
}
44+
45+
tasks.named("check") {
46+
finalizedBy(jacocoTask)
47+
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
apply plugin: 'jacoco'
17+
apply<JacocoPlugin>()
1818

19-
jacocoTestReport {
19+
val jacocoTask = tasks.withType<JacocoReport> {
2020
reports {
21-
xml.enabled true
22-
html.enabled true
23-
csv.enabled false
21+
html.isEnabled = true
22+
xml.isEnabled = true
23+
csv.isEnabled = false
2424
}
2525
}
2626

27-
check { finalizedBy jacocoTestReport }
27+
tasks.named("check") {
28+
finalizedBy(jacocoTask)
29+
}

jacoco-android.gradle

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)