|
1 |
| -# [Codecov](https://codecov.io) Gradle Example |
2 |
| -[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle?ref=badge_shield) |
| 1 | +# [Codecov](https://codecov.io) Java Gradle Example |
| 2 | +[](https://app.codecov.io/github/codecov/example-java-gradle) |
| 3 | +[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle?ref=badge_shield) |
3 | 4 |
|
| 5 | +This example repository shows how Codecov can be integrated with a simple java-gradle project. It uses **GitHub Actions** and **CircleCI** as CI/CD providers and **Jacoco** as the coverage provider. |
4 | 6 |
|
5 |
| -## Guide |
6 |
| -### Travis Setup |
7 |
| - |
8 |
| -Add to your `.travis.yml` file. |
9 |
| -```yml |
10 |
| -language: java |
11 |
| -jdk: |
12 |
| - - oraclejdk8 |
13 |
| -before_script: |
14 |
| - - chmod +x gradlew |
15 |
| -script: |
16 |
| - - ./gradlew check |
17 |
| - - ./gradlew codeCoverageReport |
18 |
| -after_success: |
19 |
| - - bash <(curl -s https://codecov.io/bash) |
20 |
| -``` |
21 |
| -
|
22 |
| -### Produce Coverage Reports |
23 |
| -1. Add Jacoco Plugin to your `build.gradle`. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L5) |
24 |
| -2. Set Jacoco to export xml. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L18-L23) |
25 |
| -3. Execute your tests as normal |
26 |
| -4. Call `gradle jacocoTestReport` to generate report. [See here](https://github.com/codecov/example-gradle/blob/65f88382659cf17c8693c3079941a12c8d004f03/circle.yml#L3) |
27 |
| - |
28 |
| -### FAQ |
29 |
| -- Q: Do you support Multi-module projects?<br/>A:Update your parent (root) `build.gradle`: |
30 |
| -```groovy |
31 |
| -allprojects { |
32 |
| - apply plugin: 'java' |
33 |
| - apply plugin: 'maven' |
34 |
| - apply plugin: 'jacoco' |
35 |
| -
|
36 |
| - sourceCompatibility = 1.8 |
37 |
| - targetCompatibility = 1.8 |
38 |
| -
|
39 |
| - repositories { |
40 |
| - mavenLocal() |
41 |
| - mavenCentral() |
42 |
| - jcenter() |
43 |
| -
|
44 |
| - maven { url "http://repo1.maven.org/maven2/" } |
45 |
| - } |
46 |
| -} |
47 |
| -
|
48 |
| -subprojects { |
49 |
| - dependencies { |
50 |
| - ... |
51 |
| - } |
52 |
| -
|
53 |
| - test.useTestNG() |
54 |
| -} |
55 |
| -
|
56 |
| -task codeCoverageReport(type: JacocoReport) { |
57 |
| - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") |
58 |
| -
|
59 |
| - subprojects.each { |
60 |
| - sourceSets it.sourceSets.main |
61 |
| - } |
62 |
| -
|
63 |
| - reports { |
64 |
| - xml.enabled true |
65 |
| - xml.destination file("${buildDir}/reports/jacoco/report.xml") |
66 |
| - html.enabled false |
67 |
| - csv.enabled false |
68 |
| - } |
69 |
| -} |
70 |
| -
|
71 |
| -codeCoverageReport.dependsOn { |
72 |
| - subprojects*.test |
73 |
| -} |
74 |
| -``` |
75 |
| - |
76 |
| -## Caveats |
77 |
| -### Private Repo |
78 |
| -Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending `-t <your upload token>` to you where you upload reports. |
| 7 | +For more information, please see the links below. |
79 | 8 |
|
80 | 9 | ## Links
|
| 10 | +- [Quick Start](https://docs.codecov.com/docs/quick-start) |
| 11 | +- [GitHub Tutorial](https://docs.codecov.com/docs/github-tutorial) |
81 | 12 | - [Community Boards](https://community.codecov.io)
|
82 | 13 | - [Support](https://codecov.io/support)
|
83 | 14 | - [Documentation](https://docs.codecov.io)
|
84 | 15 |
|
85 | 16 |
|
86 | 17 | ## License
|
87 |
| -[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle?ref=badge_large) |
| 18 | +[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle?ref=badge_large) |
0 commit comments