├── .github └── workflows │ └── enforce-license-compliance.yml ├── .travis.yml ├── LICENSE.md ├── README.md ├── pom.xml └── src ├── main └── kotlin │ └── org │ └── jacoco │ └── examples │ └── maven │ └── kotlin │ ├── HelloWorld.kt │ └── Utils.kt └── test └── kotlin └── org └── jacoco └── examples └── maven └── kotlin ├── HelloWorldTest.kt └── UtilsTest.kt /.github/workflows/enforce-license-compliance.yml: -------------------------------------------------------------------------------- 1 | name: Enforce License Compliance 2 | 3 | on: 4 | pull_request: 5 | branches: [main, master] 6 | 7 | jobs: 8 | enforce-license-compliance: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: 'Enforce License Compliance' 12 | uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main 13 | with: 14 | fossa_api_key: ${{ secrets.FOSSA_API_KEY }} 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | after_success: 4 | - bash <(curl -s https://codecov.io/bash) 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Codecov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This Repo is not current. 2 | We recommend following https://github.com/codecov/kotlin-standard at this time. 3 | 4 | ---- 5 | 6 | # [Codecov][1] Kotlin Example 7 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-kotlin.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-kotlin?ref=badge_shield) 8 | 9 | ## Guide 10 | 11 | **Using gradle?** See [gradle example](https://github.com/codecov/example-gradle) 12 | 13 | ### Travis Setup 14 | 15 | Add to your `.travis.yml` file. 16 | ```yml 17 | language: java 18 | after_success: 19 | - bash <(curl -s https://codecov.io/bash) 20 | ``` 21 | ### Produce Coverage Reports 22 | #### Add Jacoco plugin 23 | ```xml 24 | 25 | org.jacoco 26 | jacoco-maven-plugin 27 | 0.7.9 28 | 29 | 30 | 31 | prepare-agent 32 | 33 | 34 | 35 | report 36 | test 37 | 38 | report 39 | 40 | 41 | 42 | 43 | ``` 44 | ## Caveats 45 | ### Private Repos 46 | Add to your `.travis.yml` file. 47 | ```yml 48 | after_success: 49 | - bash <(curl -s https://codecov.io/bash) -t uuid-repo-token 50 | ``` 51 | 52 | ### Coverage Data Beyond the EOF 53 | 54 | Kotlin coverage reports may include extra line data that exceeds the real length of the file. Codecov will fix this by extracting the file length from every `.kt` file and append it ot the report. 55 | 56 | 57 | 1. More documentation at https://docs.codecov.io 58 | 2. Configure codecov through the `codecov.yml` https://docs.codecov.io/docs/codecov-yaml 59 | 60 | We are happy to help if you have any questions. Please contact email our Support at [support@codecov.io](mailto:support@codecov.io) 61 | 62 | [1]: https://codecov.io/ 63 | 64 | 65 | ## License 66 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-kotlin.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-kotlin?ref=badge_large) 67 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 14 | 4.0.0 15 | 16 | org.jacoco 17 | org.jacoco.examples.maven.kotlin 18 | 1.1-SNAPSHOT 19 | jar 20 | 21 | JaCoCo Maven plug-in example for Kotlin project 22 | http://www.eclemma.org/jacoco 23 | 24 | 25 | 1.2.71 26 | 27 | 28 | 29 | 30 | org.jetbrains.kotlin 31 | kotlin-stdlib-jre8 32 | ${kotlin.version} 33 | 34 | 35 | junit 36 | junit 37 | 4.13 38 | test 39 | 40 | 41 | 42 | 43 | src/main/kotlin 44 | src/test/kotlin 45 | 46 | 47 | org.jetbrains.kotlin 48 | kotlin-maven-plugin 49 | ${kotlin.version} 50 | 51 | 52 | compile 53 | compile 54 | 55 | compile 56 | 57 | 58 | 59 | test-compile 60 | test-compile 61 | 62 | test-compile 63 | 64 | 65 | 66 | 67 | 68 | org.jacoco 69 | jacoco-maven-plugin 70 | 0.8.5 71 | 72 | 73 | 74 | prepare-agent 75 | 76 | 77 | 78 | report 79 | test 80 | 81 | report 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | jetbrains-all 92 | http://repository.jetbrains.com/all 93 | 94 | 95 | 96 | 97 | 98 | jetbrains-all 99 | http://repository.jetbrains.com/all 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/main/kotlin/org/jacoco/examples/maven/kotlin/HelloWorld.kt: -------------------------------------------------------------------------------- 1 | package org.jacoco.examples.maven.kotlin 2 | 3 | class HelloWorld { 4 | 5 | fun getMessage(bigger: Boolean): String { 6 | if (bigger) { 7 | return "Hello Universe!"; 8 | } else { 9 | return "Hello World!"; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/kotlin/org/jacoco/examples/maven/kotlin/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.jacoco.examples.maven.kotlin 2 | 3 | fun foo(): String { 4 | return "bar" 5 | } 6 | 7 | val String.doubleLen: Int 8 | get() = 2 * length 9 | 10 | val Int.doubleStr: String 11 | get() = toString() + toString() 12 | 13 | fun bar(x: Double): String { 14 | if (x < 0.0) { 15 | return "negative!" 16 | } 17 | if (x > 0.0) { 18 | return "positive!" 19 | } 20 | return "flat zero!" 21 | } 22 | 23 | fun myFun(): String { 24 | fun myInnerFun(): Double { 25 | return 3.14 26 | } 27 | return myInnerFun().toInt().doubleStr 28 | } 29 | -------------------------------------------------------------------------------- /src/test/kotlin/org/jacoco/examples/maven/kotlin/HelloWorldTest.kt: -------------------------------------------------------------------------------- 1 | package org.jacoco.examples.maven.kotlin 2 | 3 | import org.junit.Assert 4 | import org.junit.Test 5 | 6 | class HelloWorldTest { 7 | 8 | @Test 9 | fun testAssert() { 10 | Assert.assertEquals("Hello World!", HelloWorld().getMessage(false)) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/kotlin/org/jacoco/examples/maven/kotlin/UtilsTest.kt: -------------------------------------------------------------------------------- 1 | package org.jacoco.examples.maven.kotlin 2 | 3 | import org.junit.Assert 4 | import org.junit.Test 5 | 6 | class UtilsTest { 7 | 8 | @Test 9 | fun testFoo() { 10 | Assert.assertEquals("bar", foo()) 11 | } 12 | 13 | @Test 14 | fun testDoubleLen() { 15 | Assert.assertEquals(12, "length".doubleLen) 16 | } 17 | 18 | @Test 19 | fun testDoubleStr() { 20 | Assert.assertEquals("4242", 42.doubleStr) 21 | } 22 | 23 | @Test 24 | fun testBar1() { 25 | Assert.assertEquals("negative!", bar(-100.31)) 26 | } 27 | 28 | @Test 29 | fun testBar2() { 30 | Assert.assertEquals("positive!", bar(1.23)) 31 | } 32 | 33 | @Test 34 | fun testBar3() { 35 | Assert.assertEquals("flat zero!", bar(0.0)) 36 | } 37 | 38 | @Test 39 | fun testBar4() { 40 | Assert.assertEquals("flat zero!", bar(-0.0)) 41 | } 42 | 43 | @Test 44 | fun testMyFun() { 45 | Assert.assertEquals("33", myFun()) 46 | } 47 | } 48 | --------------------------------------------------------------------------------