Browse Source

Add task for building coverage, make travis report it

tags/v0.2.1
Chris Smith 5 years ago
parent
commit
39ffbb4bb0
2 changed files with 56 additions and 28 deletions
  1. 8
    1
      .travis.yml
  2. 48
    27
      build.gradle.kts

+ 8
- 1
.travis.yml View File

@@ -3,4 +3,11 @@ language: java
3 3
 jdk:
4 4
   - oraclejdk8
5 5
   - oraclejdk9
6
-  - oraclejdk11
6
+  - oraclejdk11
7
+before_install:
8
+  - chmod +x gradlew
9
+script:
10
+  - ./gradlew test
11
+  - ./gradlew codeCoverageReport
12
+after_success:
13
+  - bash <(curl -s https://codecov.io/bash)

+ 48
- 27
build.gradle.kts View File

@@ -5,14 +5,26 @@ group = "com.dmdirc.ktirc"
5 5
 
6 6
 plugins {
7 7
     `maven-publish`
8
-    `jacoco`
8
+    jacoco
9 9
     kotlin("jvm") version "1.3.20"
10 10
     id("com.jfrog.bintray") version "1.8.4"
11 11
 }
12 12
 
13
+jacoco {
14
+    toolVersion = "0.8.3"
15
+}
16
+
13 17
 configurations {
14 18
     create("itestImplementation") { extendsFrom(getByName("testImplementation")) }
15 19
     create("itestRuntime") { extendsFrom(getByName("testRuntime")) }
20
+
21
+    all {
22
+        resolutionStrategy.eachDependency {
23
+            if (requested.group == "org.jetbrains.kotlin") {
24
+                useVersion("1.3.20")
25
+            }
26
+        }
27
+    }
16 28
 }
17 29
 
18 30
 repositories {
@@ -45,39 +57,48 @@ java {
45 57
     }
46 58
 }
47 59
 
48
-task<Test>("itest") {
49
-    group = "verification"
50
-    testClassesDirs = sourceSets["itest"].output.classesDirs
51
-    classpath = sourceSets["itest"].runtimeClasspath
52
-}
60
+tasks {
61
+    create<Test>("itest") {
62
+        group = "verification"
63
+        testClassesDirs = sourceSets["itest"].output.classesDirs
64
+        classpath = sourceSets["itest"].runtimeClasspath
65
+    }
53 66
 
54
-task<Jar>("sourceJar") {
55
-    description = "Creates a JAR that contains the source code."
56
-    from(sourceSets["main"].allSource)
57
-    archiveClassifier.set("sources")
58
-}
67
+    create<Jar>("sourceJar") {
68
+        description = "Creates a JAR that contains the source code."
69
+        from(sourceSets["main"].allSource)
70
+        archiveClassifier.set("sources")
71
+    }
59 72
 
60
-tasks.withType<Wrapper> {
61
-    gradleVersion = "5.1.1"
62
-}
73
+    create<JacocoReport>("codeCoverageReport") {
74
+        executionData(fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec"))
75
+
76
+        sourceSets(sourceSets["main"])
63 77
 
64
-tasks.withType<KotlinCompile> {
65
-    kotlinOptions {
66
-        jvmTarget = "1.8"
78
+        reports {
79
+            xml.isEnabled = true
80
+            xml.destination = File("$buildDir/reports/jacoco/report.xml")
81
+            html.isEnabled = true
82
+            csv.isEnabled = false
83
+        }
84
+
85
+        dependsOn("test")
67 86
     }
68
-}
69 87
 
70
-tasks.withType<Test> {
71
-    useJUnitPlatform()
72
-    testLogging {
73
-        events("passed", "skipped", "failed")
88
+    withType<Wrapper> {
89
+        gradleVersion = "5.1.1"
90
+    }
91
+
92
+    withType<KotlinCompile> {
93
+        kotlinOptions {
94
+            jvmTarget = "1.8"
95
+        }
74 96
     }
75
-}
76 97
 
77
-configurations.all {
78
-    resolutionStrategy.eachDependency {
79
-        if (requested.group == "org.jetbrains.kotlin") {
80
-            useVersion("1.3.20")
98
+    withType<Test> {
99
+        useJUnitPlatform()
100
+        testLogging {
101
+            events("passed", "skipped", "failed")
81 102
         }
82 103
     }
83 104
 }

Loading…
Cancel
Save